Skip to content

tools: crash_log_parser: make ELF and MAP parameters optional #7174

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

Merged
Merged
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
29 changes: 21 additions & 8 deletions tools/debug_tools/crash_log_parser/crash_log_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,17 @@ def main(crash_log, elfhelper):

elif eachline.startswith("PC"):
pc_val = parse_line_for_register(eachline)
pc_name = elfhelper.function_name_for_addr(int(pc_val, 16))
if elfhelper:
pc_name = elfhelper.function_name_for_addr(int(pc_val, 16))
else:
pc_name = "<unknown-symbol>"

elif eachline.startswith("LR"):
lr_val = parse_line_for_register(eachline)
lr_name = elfhelper.function_name_for_addr(int(lr_val, 16))
if elfhelper:
lr_name = elfhelper.function_name_for_addr(int(lr_val, 16))
else:
lr_name = "<unknown-symbol>"

elif eachline.startswith("SP"):
sp_val = parse_line_for_register(eachline)
Expand Down Expand Up @@ -181,20 +187,27 @@ def main(crash_log, elfhelper):
parser.add_argument(metavar='CRASH LOG', type=argparse.FileType('rb', 0),
dest='crashlog',help='path to crash log file')
parser.add_argument(metavar='ELF FILE', type=argparse.FileType('rb', 0),
dest='elffile',help='path to elf file')
nargs='?',const=None,dest='elffile',help='path to elf file')
parser.add_argument(metavar='MAP FILE', type=argparse.FileType('rb', 0),
dest='mapfile',help='path to map file')
nargs='?',const=None,dest='mapfile',help='path to map file')

# get and validate arguments
args = parser.parse_args()

elfhelper = ElfHelper(args.elffile, args.mapfile)

# if both the ELF and MAP files are present, the addresses can be converted to symbol names
if args.elffile and args.mapfile:
elfhelper = ElfHelper(args.elffile, args.mapfile)
else:
print("ELF or MAP file missing, logging raw values.")
elfhelper = None

# parse input and write to output
main(args.crashlog, elfhelper)

#close all files
args.elffile.close()
args.mapfile.close()
if args.elffile:
args.elffile.close()
if args.mapfile:
args.mapfile.close()
args.crashlog.close()