Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues in TRAP #6639

Merged
merged 2 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 6 additions & 30 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 Expand Up @@ -800,44 +800,20 @@ def parse_log(self):
# print current running task List
self.print_task_list()

# Function to format logs and delete the timestamp (format-|xxxxxxxxx|) if it consists of timestamp at the start of each log line
# Function to format logs and delete the timestamp (supported formats-|xxxxxxxxx| and [xxxxxxxxx]) if it consists of timestamp at the start of each log line
def format_log_file(self):

# Delete unwanted logs (if any) and timestamp at the start of each line
with open(self.log_file, "r") as f:
data = f.readlines()
with open(self.log_file, "w") as f:
assertinlog = 0 #Truncate logs only if assert has occured. For other type of crashes, no need to truncate
trunc = True # False if log line is to be retained, True otherwise
current_line=""
data = iter(data)
for line in data:
if partition_string in line:
f.write(line)
line = next(data)
f.write(line)
current_line = line
line = next(data)
f.write(line)
continue
if 'Assertion failed at file:' in line and current_line == assertion_details:
assertinlog = assertinlog + 1
if assertinlog == 2:
# Truncate logs after first crash dump (repeated assert case)
break
if assertinlog == 1:
# Truncate logs before first crash dump
if 'Assertion failed at file:' in line and current_line == assertion_details:
trunc = False
if trunc:
# Do not write line and move to the next line
continue

delete_idx = 0
# Timestamp present if line starts with '|'
if line[0] == '|':
if line[0] == '|' or line[0] == '[':
for idx in range(1, len(line)):
if '|' == line[idx]:
if '|' == line[idx] or ']' == line[idx]:
delete_idx = idx + 1
break
if line[delete_idx] == ' ': # Check for trailing white spaces
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