diff options
author | Petr Machata <pmachata@redhat.com> | 2013-01-06 17:16:24 +0100 |
---|---|---|
committer | Petr Machata <pmachata@redhat.com> | 2013-03-08 22:55:30 +0100 |
commit | af1e603fa8afd1ed0f1819a984c57311efbc7f1f (patch) | |
tree | ba9c2f773d804ab0591cb61a41cfee8a296e8bd6 /proc.c | |
parent | f9f3df4c9e232dc06b769daa5edf489675c5cdfc (diff) | |
download | ltrace-af1e603fa8afd1ed0f1819a984c57311efbc7f1f.tar.gz |
Tolarate failures in initialization of unwinding
Output should verify whether unwinding was properly initialized. Said
initialization should be skipped altogether unless requested on
command line.
Diffstat (limited to 'proc.c')
-rw-r--r-- | proc.c | 22 |
1 files changed, 18 insertions, 4 deletions
@@ -38,6 +38,7 @@ #include "breakpoint.h" #include "debug.h" #include "fetch.h" +#include "options.h" #include "proc.h" #include "value_dict.h" @@ -105,8 +106,10 @@ static void destroy_unwind(struct process *proc) { #if defined(HAVE_LIBUNWIND) - _UPT_destroy(proc->unwind_priv); - unw_destroy_addr_space(proc->unwind_as); + if (proc->unwind_priv != NULL) + _UPT_destroy(proc->unwind_priv); + if (proc->unwind_as != NULL) + unw_destroy_addr_space(proc->unwind_as); #endif /* defined(HAVE_LIBUNWIND) */ } @@ -148,11 +151,22 @@ process_bare_init(struct process *proc, const char *filename, proc->breakpoints = NULL; } + if (options.bt_depth > 0) { #if defined(HAVE_LIBUNWIND) - proc->unwind_priv = _UPT_create(pid); - proc->unwind_as = unw_create_addr_space(&_UPT_accessors, 0); + proc->unwind_priv = _UPT_create(pid); + proc->unwind_as = unw_create_addr_space(&_UPT_accessors, 0); #endif /* defined(HAVE_LIBUNWIND) */ + if (proc->unwind_priv == NULL || proc->unwind_as == NULL) { + fprintf(stderr, + "Couldn't initialize unwinding " + "for process %d\n", proc->pid); + destroy_unwind(proc); + proc->unwind_priv = NULL; + proc->unwind_as = NULL; + } + } + return 0; } |