Skip to content

Commit

Permalink
tools/trap: Fix issues in symbol while printing call stack details
Browse files Browse the repository at this point in the history
- This patch fixes the issue of missing letters of symbol name
while printing the assert log.
- Earlier, we were not printing symbol when addr2line was not avaliable
but now, we print symbol name irrespective of addr2line output.
- As c++ symbol length are very big, so, we print it in specific
format [first 20 chars ... last 20 chars].

Before:
Stack_address	 Symbol_address	 Symbol_location  Symbol_name		File_name
 User stack
Symbol not found for address: 0xe16f049
Symbol not found for address: 0xe17f490
Symbol not found for address: 0xe16e9a9
Symbol not found for address: 0xe16e9df
Symbol not found for address: 0xe16eb37
0x6028bbd4	 0xe16e491	 common binary    hello_main            /root/tizenrt/apps/examples/hello/hello_main.c:70
0x6028bbe0	 0xe16e4ad	 common binary    helloxx_main          /root/tizenrt/apps/examples/helloxx/helloxx_main.cxx:152
0x6028bbe8	 0xe169a19	 common binary    task_startup          /root/tizenrt/lib/libc/sched/task_startup.c:123 (discriminator 3)
0x6028bbf0	 0xe019ba9	 kernel binary    task_star             /root/tizenrt/os/kernel/task/task_start.c:162

After:
Stack_address	 Symbol_address	 Symbol location  Symbol_name                                    File_name
 User stack
0x6028bbb4	 0xe16f049	 common binary    __cxxabiv1::__class_...~__class_type_info()    File not found
0x6028bbb8	 0xe17f490	 common binary    typeinfo for unsigned __int128 const*          File not found
0x6028bbc0	 0xe16e9a9	 common binary    __cxa_free_dependent_exception                 File not found
0x6028bbc8	 0xe16e9df	 common binary    _GLOBAL__sub_I__ZN9__gnu_cxx9__freeresEv       File not found
0x6028bbd0	 0xe16eb37	 common binary    __cxa_init_primary_exception                   File not found
0x6028bbd4	 0xe16e491	 common binary    hello_main                                     /root/tizenrt/apps/examples/hello/hello_main.c:70
0x6028bbe0	 0xe16e4ad	 common binary    helloxx_main                                   /root/tizenrt/apps/examples/helloxx/helloxx_main.cxx:152
0x6028bbe8	 0xe169a19	 common binary    task_startup                                   /root/tizenrt/lib/libc/sched/task_startup.c:123 (discriminator 3)
0x6028bbf0	 0xe019ba9	 kernel binary    task_start                                     /root/tizenrt/os/kernel/task/task_start.c:162

Signed-off-by: neel-samsung <[email protected]>
  • Loading branch information
neel-samsung authored and kishore-sn committed Feb 5, 2025
1 parent bd81382 commit 9a3c239
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
6 changes: 3 additions & 3 deletions tools/trap/cli/logParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ def parse_call_stack(self):
stack_val = 0x00000000
current_line = ""

print('\nStack_address\t Symbol_address\t Symbol_location Symbol_name\t\tFile_name')
print('Stack_address\t Symbol_address\t Symbol location {: <45} File_name'.format("Symbol_name"))

# Parse the contents based on tokens in log file.
with open(self.log_file) as searchfile:
Expand Down Expand Up @@ -580,7 +580,7 @@ def print_wrong_sp(self):
if (self.is_kernel_text_address(hex(stack_val))):
if (format_print):
print('\t- SP is out of the stack range. Debug symbols corresponding to the wrong stack pointer addresses are given below:')
print('Stack_address\t Symbol_address\t Symbol location Symbol_name\t\tFile_name')
print('Stack_address\t Symbol_address\t Symbol location {: <45} File_name'.format("Symbol_name"))
format_print = False
#If yes, print it's corresponding symbol
utils.print_symbol(stack_addr, stack_val, 0, self.bin_path, self.app_name)
Expand All @@ -589,7 +589,7 @@ def print_wrong_sp(self):
if (is_app_symbol):
if (format_print):
print('\t- SP is out of the stack range. Debug symbols corresponding to the wrong stack pointer addresses are given below:')
print('Stack_address\t Symbol_address\t Symbol location Symbol_name\t\tFile_name')
print('Stack_address\t Symbol_address\t Symbol location {: <45} File_name'.format("Symbol_name"))
format_print = False
#If yes, print it's corresponding symbol
if not self.xip_enabled:
Expand Down
18 changes: 4 additions & 14 deletions tools/trap/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,23 +93,13 @@ def print_symbol(stack_addr, search_addr, is_app_symbol, bin_path, app_name):
break
else:
if (is_app_symbol):
pos = (asymbol_lookup_table[is_app_symbol][mid - 1][1]).find('\t')
sname = (asymbol_lookup_table[is_app_symbol][mid - 1][1])[:pos]
sname = (asymbol_lookup_table[is_app_symbol][mid - 1][1])
fname = subprocess.getoutput("arm-none-eabi-addr2line -e " + bin_path + app_name[is_app_symbol - 1] + "_dbg " + hex(search_addr))
if ":?" in fname:
print('Symbol not found for address: {0}'.format(hex(search_addr)))
return
else:
print("{:8}\t {:8}\t {} binary {:20} {}".format(hex(stack_addr), hex(search_addr), app_name[is_app_symbol - 1], sname, fname))
print("{:8}\t {:8}\t {} binary {: <45} {}".format(hex(stack_addr), hex(search_addr), app_name[is_app_symbol - 1], (sname[:20] + "..." + sname[-20:]) if len(sname) > 40 else sname, "File not found" if ":?" in fname else fname))
else:
pos = (ksymbol_lookup_table[mid - 1][1]).find('\t')
sname = (ksymbol_lookup_table[mid - 1][1])[:pos]
sname = (ksymbol_lookup_table[mid - 1][1])
fname = subprocess.getoutput("arm-none-eabi-addr2line -e " + bin_path + "tinyara.axf " + hex(search_addr))
if ":?" in fname:
print('Symbol not found for address: {0}'.format(hex(search_addr)))
return
else:
print("{:8}\t {:8}\t kernel binary {:20} {}".format(hex(stack_addr), hex(search_addr), sname, fname))
print("{:8}\t {:8}\t kernel binary {: <45} {}".format(hex(stack_addr), hex(search_addr), (sname[:20] + "..." + sname[-20:]) if len(sname) > 40 else sname , "File not found" if ":?" in fname else fname))
break

if (search_addr < addr):
Expand Down

0 comments on commit 9a3c239

Please sign in to comment.