]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: tools: don't emit "+0" for symbol names which exactly match known ones
authorWilly Tarreau <w@1wt.eu>
Wed, 10 Sep 2025 08:27:07 +0000 (10:27 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 10 Sep 2025 08:44:33 +0000 (10:44 +0200)
resolve_sym_name() knows a number of symbols, but when one exactly matches
(e.g. a task's handler), it systematically displays the offset behind it
("+0"). Let's only show the offset when non-zero. This can be backported
as this is helpful for debugging.

src/tools.c

index 1615ef2ae0341686cefa3ca5f1eaa9fd13cfb2a8..e6a07677023b526b71d3cef448cab87760b75165 100644 (file)
@@ -5699,7 +5699,9 @@ const void *resolve_sym_name(struct buffer *buf, const char *pfx, const void *ad
         * may have a close match. Otherwise we report an offset relative to main.
         */
        if (best_idx >= 0) {
-               chunk_appendf(buf, "%s+%#lx", fcts[best_idx].name, (long)best_dist);
+               chunk_appendf(buf, "%s", fcts[best_idx].name);
+               if (best_dist)
+                       chunk_appendf(buf, "+%#lx", (long)best_dist);
                return best_dist == 0 ? addr : NULL;
        }
        else if ((void*)addr < (void*)main)