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