diff options
author | Rob Clark <[email protected]> | 2017-04-04 13:01:56 -0400 |
---|---|---|
committer | Rob Clark <[email protected]> | 2017-04-07 08:23:02 -0400 |
commit | 3b32ec3ba65deefedfe74e594872e675d34a310a (patch) | |
tree | bb4c0a515d95749db7ab69b57db3c3a81ae5a38e /src | |
parent | 91dfa021254d5ea1c607f4f514414c2130fac208 (diff) |
gallium/util: tweak backtrace format with libunwind
To work with addr2line.sh we also need the relative offset within the
DSO. And addr2line.sh gets confused by the leading stackframe number.
Signed-off-by: Rob Clark <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/auxiliary/util/u_debug_stack.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/gallium/auxiliary/util/u_debug_stack.c b/src/gallium/auxiliary/util/u_debug_stack.c index a5829316e40..7013807b6b2 100644 --- a/src/gallium/auxiliary/util/u_debug_stack.c +++ b/src/gallium/auxiliary/util/u_debug_stack.c @@ -143,15 +143,19 @@ frame_ip(const struct debug_stack_frame *frame) } static const char * -frame_filename(const struct debug_stack_frame *frame) +frame_info(const struct debug_stack_frame *frame, unsigned *offset) { Dl_info dlinfo; + const void *addr = frame_ip(frame); - if (dladdr(frame_ip(frame), &dlinfo) && dlinfo.dli_fname && - *dlinfo.dli_fname) - return dlinfo.dli_fname; + if (dladdr(addr, &dlinfo) && dlinfo.dli_fname && + *dlinfo.dli_fname) { + *offset = (unsigned)((uintptr_t)addr - (uintptr_t)dlinfo.dli_fbase); + return dlinfo.dli_fname; + } + *offset = 0; return "?"; } @@ -159,13 +163,14 @@ void debug_backtrace_dump(const struct debug_stack_frame *backtrace, unsigned nr_frames) { - unsigned i; + unsigned i, offset; + const char *filename; for (i = 0; i < nr_frames; ++i) { if (!backtrace[i].start_ip) break; - debug_printf("\t%u: %s (%s+0x%x) [%p]\n", i, - frame_filename(&backtrace[i]), + filename = frame_info(&backtrace[i], &offset); + debug_printf("\t%s(+0x%x) (%s+0x%x) [%p]\n", filename, offset, backtrace[i].procname, backtrace[i].off, frame_ip(&backtrace[i])); } @@ -176,13 +181,14 @@ debug_backtrace_print(FILE *f, const struct debug_stack_frame *backtrace, unsigned nr_frames) { - unsigned i; + unsigned i, offset; + const char *filename; for (i = 0; i < nr_frames; ++i) { if (!backtrace[i].start_ip) break; - fprintf(f, "\t%u: %s (%s+0x%x) [%p]\n", i, - frame_filename(&backtrace[i]), + filename = frame_info(&backtrace[i], &offset); + fprintf(f, "\t%s(+0x%x) (%s+0x%x) [%p]\n", filename, offset, backtrace[i].procname, backtrace[i].off, frame_ip(&backtrace[i])); } |