Signed-off-by: Martin Milata <[email protected]>
---
lib/core_stacktrace.h | 2 +-
lib/core_unwind_libunwind.c | 20 ++++++++++++++++++--
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/lib/core_stacktrace.h b/lib/core_stacktrace.h
index 0552475..ac0804d 100644
--- a/lib/core_stacktrace.h
+++ b/lib/core_stacktrace.h
@@ -41,7 +41,7 @@ struct sr_json_value;
struct sr_core_stacktrace
{
/** Signal number. */
- uint8_t signal;
+ uint16_t signal;
char *executable;
diff --git a/lib/core_unwind_libunwind.c b/lib/core_unwind_libunwind.c
index 06734a3..29805da 100644
--- a/lib/core_unwind_libunwind.c
+++ b/lib/core_unwind_libunwind.c
@@ -429,6 +429,23 @@ unwind_thread(struct UCD_info *ui,
return thread;
}
+static int
+get_signal_number(struct UCD_info *ui)
+{
+ int tnum, nthreads = _UCD_get_num_threads(ui);
+ for (tnum = 0; tnum < nthreads; ++tnum)
+ {
+ _UCD_select_thread(ui, tnum);
+ int signo = _UCD_get_cursig(ui);
+
+ /* Return first nonzero signal, gdb/bfd seem to work this way. */
+ if (signo)
+ return signo;
+ }
+
+ return 0;
+}
+
struct sr_core_stacktrace *
sr_parse_coredump(const char *core_file,
const char *exe_file,
@@ -491,8 +508,7 @@ sr_parse_coredump(const char *core_file,
}
stacktrace->executable = realpath(exe_file, NULL);
- /* FIXME: determine signal */
- stacktrace->signal = 0;
+ stacktrace->signal = get_signal_number(ui);
/* FIXME: is this the best we can do? */
stacktrace->crash_thread = stacktrace->threads;
--
1.7.11.7