From: Timo Sirainen Date: Tue, 27 Dec 2022 15:44:28 +0000 (-0500) Subject: lib: libc backtrace_append() - Remove directory paths from binary names X-Git-Tag: 2.4.0~3233 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a100cc1b1dd3f101bf367873b1b75595b144a3a;p=thirdparty%2Fdovecot%2Fcore.git lib: libc backtrace_append() - Remove directory paths from binary names The backtrace unnecessarily contained directory paths, causing the backtrace to become excessively large just repeating the directories. This change is only for libc backtrace, not for libunwind backtrace. --- diff --git a/src/lib/backtrace-string.c b/src/lib/backtrace-string.c index a2806a47fb..b50827c381 100644 --- a/src/lib/backtrace-string.c +++ b/src/lib/backtrace-string.c @@ -83,8 +83,18 @@ static int backtrace_append_libc(string_t *str) /* out of memory case */ str_printfa(str, "0x%p", stack[i]); } else if (str_len(str) != str_orig_size || - !str_begins_with(strings[i], BACKTRACE_SKIP_PREFIX)) - str_append(str, strings[i]); + !str_begins_with(strings[i], BACKTRACE_SKIP_PREFIX)) { + /* String often contains a full path to the binary, + followed by the function name. The path causes the + backtrace to be excessively large and we don't + especially care about it, so just skip over it. */ + const char *suffix = strrchr(strings[i], '/'); + if (suffix != NULL) + suffix++; + else + suffix = strings[i]; + str_append(str, suffix); + } } free(strings); return 0;