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

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