]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: debug: dump the mapping of the libs into post_mortem
authorWilly Tarreau <w@1wt.eu>
Thu, 23 Nov 2023 07:26:52 +0000 (08:26 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 23 Nov 2023 14:39:21 +0000 (15:39 +0100)
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

index 837061505df788a29c358e1008084176621c3780..f964e7e201214f36f0ec06fb238d34d2082d9243 100644 (file)
@@ -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