From 22deda33c6464e403aaf3d979eb2ca28af937417 Mon Sep 17 00:00:00 2001 From: Thomas De Schampheleire Date: Thu, 6 Nov 2014 13:59:04 +0100 Subject: [PATCH] stack trace support: fix check on symbol name presence The output format of the stack trace is supposed to be different depending on whether symbol names are available in the build. However, the check only verified the validity of the pointer, not of the string pointed to (which could be empty). This commit fixes the check so that the original output: mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x5e000 > /lib/libc-2.10.1.so(_IO_file_doallocate+0x8c) [0x68a38] > /lib/libc-2.10.1.so(_IO_doallocbuf+0x6c) [0x78574] > /lib/libc-2.10.1.so(_IO_file_overflow+0x184) [0x7763c] > /lib/libc-2.10.1.so(_IO_file_xsputn+0x88) [0x76aac] > /lib/libc-2.10.1.so(_IO_puts+0xc8) [0x6b64c] > /bin/busybox(+0x0) [0x62c60] > /bin/busybox(+0x0) [0x4940] > /bin/busybox(+0x0) [0x499c] > /bin/busybox(+0x0) [0x4e08] > /lib/libc-2.10.1.so(__libc_init_first+0x30c) [0x1f84c] > /lib/libc-2.10.1.so(__libc_start_main+0xd8) [0x1f9f8] becomes: mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x5e000 > /lib/libc-2.10.1.so(_IO_file_doallocate+0x8c) [0x68a38] > /lib/libc-2.10.1.so(_IO_doallocbuf+0x6c) [0x78574] > /lib/libc-2.10.1.so(_IO_file_overflow+0x184) [0x7763c] > /lib/libc-2.10.1.so(_IO_file_xsputn+0x88) [0x76aac] > /lib/libc-2.10.1.so(_IO_puts+0xc8) [0x6b64c] > /bin/busybox() [0x62c60] > /bin/busybox() [0x4940] > /bin/busybox() [0x499c] > /bin/busybox() [0x4e08] > /lib/libc-2.10.1.so(__libc_init_first+0x30c) [0x1f84c] > /lib/libc-2.10.1.so(__libc_start_main+0xd8) [0x1f9f8] Signed-off-by: Thomas De Schampheleire Acked-by: Masatake YAMATO --- unwind.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unwind.c b/unwind.c index 5b060083..6f422a1c 100644 --- a/unwind.c +++ b/unwind.c @@ -427,7 +427,7 @@ print_call_cb(void *dummy, unw_word_t function_offset, unsigned long true_offset) { - if (symbol_name) + if (symbol_name && (symbol_name[0] != '\0')) tprintf(STACK_ENTRY_SYMBOL_FMT); else if (binary_filename) tprintf(STACK_ENTRY_NOSYMBOL_FMT); -- 2.34.1