]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Pull request #4040: helpers: increase buffer space for function names, allow printing...
authorYurii Chalov -X (ychalov - SOFTSERVE INC at Cisco) <ychalov@cisco.com>
Mon, 9 Oct 2023 13:58:28 +0000 (13:58 +0000)
committerOleksii Shumeiko -X (oshumeik - SOFTSERVE INC at Cisco) <oshumeik@cisco.com>
Mon, 9 Oct 2023 13:58:28 +0000 (13:58 +0000)
Merge in SNORT/snort3 from ~YCHALOV/snort3:backtrace_buffer_space to master

Squashed commit of the following:

commit 4a228b16da04e83b4749e84b310e4b2716936b3e
Author: Yurii Chalov <ychalov@cisco.com>
Date:   Wed Oct 4 21:20:37 2023 +0200

    helpers: increase buffer space for function names, allow printing truncated names

src/helpers/process.cc

index a7b4c098b60f9135d56263842d853a2414a2f607..9987593f502000419aac4dea061533af82ebafb3 100644 (file)
@@ -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)