summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Clementi <luca.clementi@gmail.com>2014-01-03 22:05:03 -0800
committerChanho Park <chanho61.park@samsung.com>2014-08-22 20:38:24 +0900
commit9c90cdba352e1cb9dbfae3659c71664dba4b3904 (patch)
tree0e094656709717c783e4657d45836f919773c594
parent5fc7b8674b59bd6e2c8ff734f4e5362df8795617 (diff)
downloadltrace-9c90cdba352e1cb9dbfae3659c71664dba4b3904.tar.gz
ltrace-9c90cdba352e1cb9dbfae3659c71664dba4b3904.tar.bz2
ltrace-9c90cdba352e1cb9dbfae3659c71664dba4b3904.zip
check return value of unw_get_reg and unw_get_proc_name
Before printng the current procedure name and IP verify their validity
-rw-r--r--output.c16
-rw-r--r--proc.c5
-rw-r--r--proc.h1
3 files changed, 13 insertions, 9 deletions
diff --git a/output.c b/output.c
index 82b6a5e..f804cd0 100644
--- a/output.c
+++ b/output.c
@@ -661,9 +661,11 @@ output_right(enum tof type, struct process *proc, struct library_symbol *libsym,
!= sizeof(arch_addr_t))]);
unw_init_remote(&cursor, proc->unwind_as, proc->unwind_priv);
while (unwind_depth) {
- unw_get_reg(&cursor, UNW_REG_IP, (unw_word_t *) &ip);
- unw_get_proc_name(&cursor, fn_name, sizeof(fn_name),
- (unw_word_t *) &function_offset);
+
+ if (unw_get_reg(&cursor, UNW_REG_IP, (unw_word_t *) &ip)) {
+ fprintf(options.output, " > stacktrace_error\n");
+ continue;
+ }
/* We are looking for the library with the base address
* closest to the current ip. */
@@ -683,8 +685,14 @@ output_right(enum tof type, struct process *proc, struct library_symbol *libsym,
lib = lib->next;
}
- fprintf(options.output, " > %s(%s+0x%p) [%p]\n",
+ own_retval = unw_get_proc_name(&cursor, fn_name, sizeof(fn_name),
+ (unw_word_t *) &function_offset);
+ if ((own_retval == 0) || (own_retval == -UNW_ENOMEM))
+ fprintf(options.output, " > %s(%s+%p) [%p]\n",
lib_name, fn_name, function_offset, ip);
+ else
+ fprintf(options.output, " > %s(??\?) [%p]\n",
+ lib_name, ip);
if (unw_step(&cursor) <= 0)
break;
diff --git a/proc.c b/proc.c
index 11755b0..97bcb60 100644
--- a/proc.c
+++ b/proc.c
@@ -29,11 +29,6 @@
#include <stdlib.h>
#include <string.h>
-#if defined(HAVE_LIBUNWIND)
-#include <libunwind.h>
-#include <libunwind-ptrace.h>
-#endif /* defined(HAVE_LIBUNWIND) */
-
#include "backend.h"
#include "breakpoint.h"
#include "debug.h"
diff --git a/proc.h b/proc.h
index 64f8fe2..35943c3 100644
--- a/proc.h
+++ b/proc.h
@@ -30,6 +30,7 @@
#if defined(HAVE_LIBUNWIND)
# include <libunwind.h>
+# include <libunwind-ptrace.h>
#endif /* defined(HAVE_LIBUNWIND) */
#include "ltrace.h"