Blame SOURCES/satyr-0.13-unwind-minor-refactoring.patch

f41043
From f8be518c5d8534f8724c752c6ad95b3e61460a7b Mon Sep 17 00:00:00 2001
f41043
From: Martin Milata <mmilata@redhat.com>
f41043
Date: Mon, 24 Nov 2014 14:34:09 +0100
f41043
Subject: [PATCH 2/5] unwind: minor refactoring
f41043
f41043
Related to abrt/abrt#829.
f41043
f41043
Signed-off-by: Martin Milata <mmilata@redhat.com>
f41043
---
f41043
 lib/core_unwind.c          |  2 +-
f41043
 lib/core_unwind_elfutils.c | 24 +++++++++++++++---------
f41043
 lib/internal_unwind.h      |  6 ++++++
f41043
 3 files changed, 22 insertions(+), 10 deletions(-)
f41043
f41043
diff --git a/lib/core_unwind.c b/lib/core_unwind.c
f41043
index 8b7cc22..48d5ca5 100644
f41043
--- a/lib/core_unwind.c
f41043
+++ b/lib/core_unwind.c
f41043
@@ -127,7 +127,7 @@ find_elf_core (Dwfl_Module *mod, void **userdata, const char *modname,
f41043
 }
f41043
 
f41043
 /* Do not use debuginfo files at all. */
f41043
-static int
f41043
+int
f41043
 find_debuginfo_none (Dwfl_Module *mod, void **userdata, const char *modname,
f41043
                      GElf_Addr base, const char *file_name,
f41043
                      const char *debuglink_file, GElf_Word debuglink_crc,
f41043
diff --git a/lib/core_unwind_elfutils.c b/lib/core_unwind_elfutils.c
f41043
index bbd4813..8351ebf 100644
f41043
--- a/lib/core_unwind_elfutils.c
f41043
+++ b/lib/core_unwind_elfutils.c
f41043
@@ -77,6 +77,19 @@ frame_callback(Dwfl_Frame *frame, void *data)
f41043
     return DWARF_CB_OK;
f41043
 }
f41043
 
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
+    {
f41043
+        struct sr_core_frame *old_frame = thread->frames;
f41043
+        thread->frames = old_frame->next;
f41043
+        sr_core_frame_free(old_frame);
f41043
+        frame_arg->nframes--;
f41043
+    }
f41043
+}
f41043
+
f41043
 static int
f41043
 unwind_thread(Dwfl_Thread *thread, void *data)
f41043
 {
f41043
@@ -86,7 +99,7 @@ unwind_thread(Dwfl_Thread *thread, void *data)
f41043
     struct sr_core_thread *result = sr_core_thread_new();
f41043
     if (!result)
f41043
     {
f41043
-        set_error("Failed to initialize stacktrace memory");
f41043
+        set_error("Failed to initialize thread memory");
f41043
         return DWARF_CB_ABORT;
f41043
     }
f41043
     result->id = (int64_t)dwfl_thread_tid(thread);
f41043
@@ -121,14 +134,7 @@ unwind_thread(Dwfl_Thread *thread, void *data)
f41043
         goto abort;
f41043
     }
f41043
 
f41043
-    /* Truncate the stacktrace to FRAME_LIMIT least recent frames. */
f41043
-    while (result->frames && frame_arg.nframes > FRAME_LIMIT)
f41043
-    {
f41043
-        struct sr_core_frame *old_frame = result->frames;
f41043
-        result->frames = old_frame->next;
f41043
-        sr_core_frame_free(old_frame);
f41043
-        frame_arg.nframes--;
f41043
-    }
f41043
+    truncate_long_thread(result, &frame_arg);
f41043
 
f41043
     *thread_arg->threads_tail = result;
f41043
     thread_arg->threads_tail = &result->next;
f41043
diff --git a/lib/internal_unwind.h b/lib/internal_unwind.h
f41043
index 2c9abb7..84261c6 100644
f41043
--- a/lib/internal_unwind.h
f41043
+++ b/lib/internal_unwind.h
f41043
@@ -96,4 +96,10 @@ resolve_frame(Dwfl *dwfl, Dwarf_Addr ip, bool minus_one);
f41043
 short
f41043
 get_signal_number(Elf *e, const char *elf_file);
f41043
 
f41043
+int
f41043
+find_debuginfo_none (Dwfl_Module *mod, void **userdata, const char *modname,
f41043
+                     GElf_Addr base, const char *file_name,
f41043
+                     const char *debuglink_file, GElf_Word debuglink_crc,
f41043
+                     char **debuginfo_file_name);
f41043
+
f41043
 #endif /* SATYR_INTERNAL_UNWIND_H */
f41043
-- 
f41043
2.4.3
f41043