From a88a3482b5a6315258761b9f80fd6a7e086c1462 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 23 Nov 2023 08:26:52 +0100 Subject: [PATCH] MINOR: debug: dump the mapping of the libs into post_mortem Having the libs and their addresses listed in the post_mortem struct is also helpful. Sometimes it helps notice that one version is not the expected one, e.g. due to some LD_LIBRARY_PATH. We don't emit it on "show dev" however since that's already available via "show libs". --- src/debug.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/debug.c b/src/debug.c index 837061505..f964e7e20 100644 --- a/src/debug.c +++ b/src/debug.c @@ -106,6 +106,11 @@ struct post_mortem { } thread_info[MAX_THREADS]; #endif } process; + +#if defined(HA_HAVE_DUMP_LIBS) + /* information about dynamic shared libraries involved */ + char *libs; // dump of one addr / path per line, or NULL +#endif } post_mortem ALIGNED(256) = { }; /* Points to a copy of the buffer where the dump functions should write, when @@ -2147,11 +2152,26 @@ static int feed_post_mortem() if (strcmp(post_mortem.platform.utsname.sysname, "Linux") == 0) feed_post_mortem_linux(); +#if defined(HA_HAVE_DUMP_LIBS) + chunk_reset(&trash); + if (dump_libs(&trash, 1)) + post_mortem.libs = strdup(trash.area); +#endif + return ERR_NONE; } REGISTER_POST_CHECK(feed_post_mortem); +static void deinit_post_mortem(void) +{ +#if defined(HA_HAVE_DUMP_LIBS) + ha_free(&post_mortem.libs); +#endif +} + +REGISTER_POST_DEINIT(deinit_post_mortem); + #ifdef USE_THREAD /* init code is called one at a time so let's collect all per-thread info on * the last starting thread. These info are not critical anyway and there's no