Skip to content

Commit

Permalink
i#7046: Validate the contents of the Linux memory dump file. (#7092)
Browse files Browse the repository at this point in the history
Set postcmd to use "readelf -a" to dump the contents of Linux memory
dump file.

Replace suite/tests/client-interface/memory_dump_test.expect with
suite/tests/client-interface/memory_dump_test.templatex which validates
the contents of the output of "readelf -a".

Issue: #7046
  • Loading branch information
ivankyluk authored Nov 26, 2024
1 parent 5e6429b commit 4a2301b
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 5 deletions.
6 changes: 6 additions & 0 deletions suite/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2647,6 +2647,12 @@ if (NOT ANDROID) # TODO i#38: Port test to Android.
client-interface/attach_blocking.runall "" "" "")
endif ()
if (X64 AND (LINUX OR WIN32))
if (LINUX)
set(client.memory_dump_test_runcmp "${CMAKE_CURRENT_SOURCE_DIR}/runmulti.cmake")
set(client.memory_dump_test_precmd "rm@${PROJECT_BINARY_DIR}/logs/simple_app.*.elf")
set(client.memory_dump_test_postcmd "${READELF_EXECUTABLE}@-a@${PROJECT_BINARY_DIR}/logs/simple_app.*.elf")
set(client.memory_dump_test_expectbase "memory_dump_test")
endif ()
tobuild_ci(client.memory_dump_test client-interface/memory_dump_test.c "" "" "")
endif ()
endif ()
Expand Down
1 change: 0 additions & 1 deletion suite/tests/client-interface/memory_dump_test.dll.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ event_nudge(void *drcontext, uint64 arg)
#endif
if (!dr_create_memory_dump(&spec))
dr_fprintf(STDERR, "Error: failed to create memory dump.\n");
// TODO i#7046: Verify the content of the output file.
return;
}
dr_fprintf(STDERR, "Error: unexpected nudge event!\n");
Expand Down
4 changes: 0 additions & 4 deletions suite/tests/client-interface/memory_dump_test.expect

This file was deleted.

41 changes: 41 additions & 0 deletions suite/tests/client-interface/memory_dump_test.templatex
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
thank you for testing memory dump
thread init
nudge delivered 1
Hello, world!
#ifdef LINUX
#undef UNIX
ELF Header:
Magic: 7f 45 4c 46 02 01 01 03 00 00 00 00 00 00 00 00.*
Class: ELF64
Data: 2's complement, little endian
Version: 1 \(current\)
OS/ABI: UNIX - GNU
ABI Version: 0
Type: CORE \(Core file\)
Machine: .*
Version: 0x1
Entry point address: 0x0
Start of program headers: 64 \(bytes into file\)
Start of section headers: [0-9]+ \(bytes into file\)
Flags: 0x0
Size of this header: 64 \(bytes\)
Size of program headers: 56 \(bytes\)
Number of program headers: 1
Size of section headers: 64 \(bytes\)
Number of section headers: [0-9]+
Section header string table index: [0-9]+
.*
Section Headers:
.*\[Nr\] Name Type Address Offset
Size EntSize Flags Link Info Align
.* shstrtab STRTAB.*
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
NOTE.*
.*
Displaying notes found at file offset 0x[0-9a-f]+ with length 0x[0-9a-f]+:
Owner.*Data size.*Description
CORE.*NT_PRSTATUS.*\(prstatus structure\)
CORE.*NT_FPREGSET.*\(floating point registers\)
#endif

0 comments on commit 4a2301b

Please sign in to comment.