From b9ff650a2286978e0901cab2c5735482bfc45b7b Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Fri, 23 Mar 2012 21:00:28 +0100 Subject: [PATCH] Add _UCD_get_pid and _UCD_get_cursig These let you get the pid and the current signal from the coredump. This isn't strictly unwind related, but these are trivial to implement as we have the info, and you almost always want these when you're printing a backtrace from a core file. --- include/libunwind-coredump.h | 2 ++ src/coredump/_UCD_create.c | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/libunwind-coredump.h b/include/libunwind-coredump.h index 38385498..a44536f1 100644 --- a/include/libunwind-coredump.h +++ b/include/libunwind-coredump.h @@ -40,6 +40,8 @@ struct UCD_info; extern struct UCD_info *_UCD_create(const char *filename); extern void _UCD_destroy(struct UCD_info *); +extern pid_t _UCD_get_pid(struct UCD_info *); +extern int _UCD_get_cursig(struct UCD_info *); extern int _UCD_add_backing_file_at_segment(struct UCD_info *, int phdr_no, const char *filename); extern int _UCD_add_backing_file_at_vaddr(struct UCD_info *, unsigned long vaddr, diff --git a/src/coredump/_UCD_create.c b/src/coredump/_UCD_create.c index 00117f36..ec0dfb54 100644 --- a/src/coredump/_UCD_create.c +++ b/src/coredump/_UCD_create.c @@ -276,6 +276,16 @@ _UCD_create(const char *filename) return NULL; } +pid_t _UCD_get_pid(struct UCD_info *ui) +{ + return ui->prstatus->pr_pid; +} + +int _UCD_get_cursig(struct UCD_info *ui) +{ + return ui->prstatus->pr_cursig; +} + int _UCD_add_backing_file_at_segment(struct UCD_info *ui, int phdr_no, const char *filename) { if ((unsigned)phdr_no >= ui->phdrs_count)