From: Yurii Chalov -X (ychalov - SOFTSERVE INC at Cisco) Date: Mon, 9 Oct 2023 13:58:28 +0000 (+0000) Subject: Pull request #4040: helpers: increase buffer space for function names, allow printing... X-Git-Tag: 3.1.72.0~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8887c87416b0ce2ce82fad3a6b6bc5fa288dd923;p=thirdparty%2Fsnort3.git Pull request #4040: helpers: increase buffer space for function names, allow printing truncated names Merge in SNORT/snort3 from ~YCHALOV/snort3:backtrace_buffer_space to master Squashed commit of the following: commit 4a228b16da04e83b4749e84b310e4b2716936b3e Author: Yurii Chalov Date: Wed Oct 4 21:20:37 2023 +0200 helpers: increase buffer space for function names, allow printing truncated names --- diff --git a/src/helpers/process.cc b/src/helpers/process.cc index a7b4c098b..9987593f5 100644 --- a/src/helpers/process.cc +++ b/src/helpers/process.cc @@ -226,12 +226,24 @@ static void print_backtrace(SigSafePrinter& ssp) ssp.printf(" #%u 0x%x", frame_num, pc); - char sym[256]; + char sym[1024]; unw_word_t offset; - if ((ret = unw_get_proc_name(&cursor, sym, sizeof(sym), &offset)) == 0) - ssp.printf(" in %s+0x%x", sym, offset); - else - ssp.printf(" unw_get_proc_name failed: %s (%d)", unw_strerror(ret), ret); + ret = unw_get_proc_name(&cursor, sym, sizeof(sym), &offset); + switch (-ret) + { + case 0: + // fallthrough + case UNW_ENOMEM: + ssp.printf(" in %s+0x%x", sym, offset); + break; + case UNW_ENOINFO: + // fallthrough + case UNW_EUNSPEC: + // fallthrough + default: + ssp.printf(" unw_get_proc_name failed: %s (%d)", unw_strerror(ret), ret); + break; + } Dl_info dlinfo; if (dladdr((void *)(uintptr_t)(pip.start_ip + offset), &dlinfo)