mfabik / rpms / satyr

Forked from rpms/satyr 3 years ago
Clone

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

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