Skip to content

Commit 989b02e

Browse files
committed
MINOR: debug: place a magic pattern at the beginning of post_mortem
In order to ease finding of the post_mortem struct in core dumps, let's make it start with a recognizable pattern of exactly 32 chars (to preserve alignment): "POST-MORTEM STARTS HERE+7654321\0" It can then be found like this from gdb: (gdb) find 0x000000012345678, 0x0000000100000000, 'P','O','S','T','-','M','O','R','T','E','M' 0xcfd300 <post_mortem> 1 pattern found. Or easier with any other more practical tool (who as ever used "find" in gdb, given that it cannot iterate over maps and is 100% useless?).
1 parent fba48e1 commit 989b02e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/debug.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ struct post_mortem_component {
9898
*/
9999
struct post_mortem {
100100
/* platform-specific information */
101+
char post_mortem_magic[32]; // "POST-MORTEM STARTS HERE+7654321\0"
101102
struct {
102103
struct utsname utsname; // OS name+ver+arch+hostname
103104
char hw_vendor[64]; // hardware/hypervisor vendor when known
@@ -2511,6 +2512,10 @@ static void feed_post_mortem_linux()
25112512

25122513
static int feed_post_mortem()
25132514
{
2515+
/* write an easily identifiable magic at the beginning of the struct */
2516+
strncpy(post_mortem.post_mortem_magic,
2517+
"POST-MORTEM STARTS HERE+7654321\0",
2518+
sizeof(post_mortem.post_mortem_magic));
25142519
/* kernel type, version and arch */
25152520
uname(&post_mortem.platform.utsname);
25162521

0 commit comments

Comments
 (0)