Blame SOURCES/satyr-0.13-Honor-frame-number-limit-in-GDB-core-unwinder.patch

f41043
From d94a7b5c516c0446d1c49e8446707a64b4b45148 Mon Sep 17 00:00:00 2001
f41043
From: Jakub Filak <jfilak@redhat.com>
f41043
Date: Tue, 2 Aug 2016 08:50:10 +0200
f41043
Subject: [PATCH] Honor frame number limit in GDB core unwinder
f41043
f41043
Related to #1260074
f41043
f41043
Signed-off-by: Jakub Filak <jfilak@redhat.com>
f41043
---
f41043
 lib/core_unwind.c          | 15 +++++++++++++++
f41043
 lib/core_unwind_elfutils.c |  6 ++----
f41043
 lib/internal_unwind.h      |  5 +++++
f41043
 3 files changed, 22 insertions(+), 4 deletions(-)
f41043
f41043
diff --git a/lib/core_unwind.c b/lib/core_unwind.c
f41043
index b8c0235..05b94a5 100644
f41043
--- a/lib/core_unwind.c
f41043
+++ b/lib/core_unwind.c
f41043
@@ -429,6 +429,8 @@ sr_core_stacktrace_from_gdb(const char *gdb_output, const char *core_file,
f41043
     {
f41043
         struct sr_core_thread *core_thread = sr_core_thread_new();
f41043
 
f41043
+        unsigned long nframes = CORE_STACKTRACE_FRAME_LIMIT;
f41043
+        struct sr_gdb_frame *top_frame = gdb_thread->frames;
f41043
         for (struct sr_gdb_frame *gdb_frame = gdb_thread->frames;
f41043
              gdb_frame;
f41043
              gdb_frame = gdb_frame->next)
f41043
@@ -436,6 +438,19 @@ sr_core_stacktrace_from_gdb(const char *gdb_output, const char *core_file,
f41043
             if (gdb_frame->signal_handler_called)
f41043
                 continue;
f41043
 
f41043
+            if (nframes)
f41043
+                --nframes;
f41043
+            else
f41043
+                top_frame = top_frame->next;
f41043
+        }
f41043
+
f41043
+        for (struct sr_gdb_frame *gdb_frame = top_frame;
f41043
+             gdb_frame;
f41043
+             gdb_frame = gdb_frame->next)
f41043
+        {
f41043
+            if (gdb_frame->signal_handler_called)
f41043
+                continue;
f41043
+
f41043
             struct sr_core_frame *core_frame = resolve_frame(ch->dwfl,
f41043
                     gdb_frame->address, false);
f41043
 
f41043
diff --git a/lib/core_unwind_elfutils.c b/lib/core_unwind_elfutils.c
f41043
index 1482dba..d273a03 100644
f41043
--- a/lib/core_unwind_elfutils.c
f41043
+++ b/lib/core_unwind_elfutils.c
f41043
@@ -33,8 +33,6 @@
f41043
 #include <sys/ptrace.h>
f41043
 #include <sys/wait.h>
f41043
 
f41043
-#define FRAME_LIMIT 256
f41043
-
f41043
 struct frame_callback_arg
f41043
 {
f41043
     struct sr_core_frame **frames_tail;
f41043
@@ -84,8 +82,8 @@ frame_callback(Dwfl_Frame *frame, void *data)
f41043
 static void
f41043
 truncate_long_thread(struct sr_core_thread *thread, struct frame_callback_arg *frame_arg)
f41043
 {
f41043
-    /* Truncate the stacktrace to FRAME_LIMIT least recent frames. */
f41043
-    while (thread->frames && frame_arg->nframes > FRAME_LIMIT)
f41043
+    /* Truncate the stacktrace to CORE_STACKTRACE_FRAME_LIMIT least recent frames. */
f41043
+    while (thread->frames && frame_arg->nframes > CORE_STACKTRACE_FRAME_LIMIT)
f41043
     {
f41043
         struct sr_core_frame *old_frame = thread->frames;
f41043
         thread->frames = old_frame->next;
f41043
diff --git a/lib/internal_unwind.h b/lib/internal_unwind.h
f41043
index 84261c6..b9e162a 100644
f41043
--- a/lib/internal_unwind.h
f41043
+++ b/lib/internal_unwind.h
f41043
@@ -66,6 +66,11 @@ _set_error(char **error_msg, const char *fmt, ...) __sr_printf(2, 3);
f41043
         }                                    \
f41043
     } while(0)
f41043
 
f41043
+/* This macro is used as a limit for the number of function frames included in
f41043
+ * every single thread of a core stacktrace generated by satyr.
f41043
+ */
f41043
+#define CORE_STACKTRACE_FRAME_LIMIT 256
f41043
+
f41043
 struct exe_mapping_data
f41043
 {
f41043
     uint64_t start;
f41043
-- 
f41043
2.17.1
f41043