From 989b02e1930d7ecd1a728c3d18ccfba095cdd636 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 24 Oct 2024 11:56:07 +0200 Subject: [PATCH] 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 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?). --- src/debug.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/debug.c b/src/debug.c index 0d569d6c88..6e5148e300 100644 --- a/src/debug.c +++ b/src/debug.c @@ -98,6 +98,7 @@ struct post_mortem_component { */ struct post_mortem { /* platform-specific information */ + char post_mortem_magic[32]; // "POST-MORTEM STARTS HERE+7654321\0" struct { struct utsname utsname; // OS name+ver+arch+hostname char hw_vendor[64]; // hardware/hypervisor vendor when known @@ -2511,6 +2512,10 @@ static void feed_post_mortem_linux() static int feed_post_mortem() { + /* write an easily identifiable magic at the beginning of the struct */ + strncpy(post_mortem.post_mortem_magic, + "POST-MORTEM STARTS HERE+7654321\0", + sizeof(post_mortem.post_mortem_magic)); /* kernel type, version and arch */ uname(&post_mortem.platform.utsname);