diff options
author | Nicholas Piggin <npiggin@gmail.com> | 2018-02-02 15:34:08 +1000 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2018-02-08 18:21:42 -0600 |
commit | 3a7422851bc345971773c4d22881199b7911da33 (patch) | |
tree | 5e7a5f9817a2aa68e561731986f3c07e1fb7a223 /core/stack.c | |
parent | 85a1de35cbe47618e9d4104880f182121806af4d (diff) | |
download | skiboot-3a7422851bc345971773c4d22881199b7911da33.zip skiboot-3a7422851bc345971773c4d22881199b7911da33.tar.gz skiboot-3a7422851bc345971773c4d22881199b7911da33.tar.bz2 |
core/utils: add snprintf_symbol
get_symbol is difficult to use. Add snprintf_symbol helper which
prints a symbol into a buffer with length, and returns the number
of bytes used, similarly to snprintf. Use this in the stack dumping
code rather than open-coding it.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'core/stack.c')
-rw-r--r-- | core/stack.c | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/core/stack.c b/core/stack.c index af4d37d..e04a4dd 100644 --- a/core/stack.c +++ b/core/stack.c @@ -59,8 +59,7 @@ void __print_backtrace(unsigned int pir, static char bt_text_buf[4096]; int i, l = 0, max; char *buf = out_buf; - unsigned long bottom, top, tbot, ttop, saddr = 0; - char *sym = NULL, *sym_end = NULL; + unsigned long bottom, top, tbot, ttop; char mark; if (!out_buf) { @@ -82,20 +81,12 @@ void __print_backtrace(unsigned int pir, mark = '*'; else mark = ' '; - if (symbols) - saddr = get_symbol(entries->pc, &sym, &sym_end); - else - saddr = 0; l += snprintf(buf + l, max - l, " S: %016lx R: %016lx %c ", entries->sp, entries->pc, mark); - while(saddr && sym < sym_end && l < max) - buf[l++] = *(sym++); - if (sym && l < max) - l += snprintf(buf + l, max - l, "+0x%lx\n", - entries->pc - saddr); - else - l += snprintf(buf + l, max - l, "\n"); + if (symbols) + l += snprintf_symbol(buf + l, max - l, entries->pc); + l += snprintf(buf + l, max - l, "\n"); entries++; } if (!out_buf) |