tools: crash_log_parser: make ELF and MAP parameters optional

On some bug reports the customer is providing only the raw
crash dump but not the ELF and MAP files. Those files are
needed to decode the addresses into symbol names, but the
extremely useful fault reason can still be decoded even
without them.

By making the ELF and MAP arguments optional, one can now
decode the raw dump content into something such as:

--8<--8<--
ELF or MAP file missing, logging raw values.

Crash Info:
	Crash location = <unknown-symbol> [0x000091F4] (based on PC value)
	Caller location = <unknown-symbol> [0x00018E39] (based on LR value)
	Stack Pointer at the time of crash = [200091E8]
	Target and Fault Info:
		Processor Arch: ARM-V7M or above
		Processor Variant: C24
		Forced exception, a fault with configurable priority has been escalated to HardFault
		The processor has attempted to execute an undefined instruction
pull/7174/head
Tero Jääskö 2018-06-08 12:39:25 +03:00
parent 73cfc7baea
commit 274c3fa690
1 changed files with 21 additions and 8 deletions

View File

@ -130,11 +130,17 @@ def main(crash_log, elfhelper):
elif eachline.startswith("PC"):
pc_val = parse_line_for_register(eachline)
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)
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)
@ -181,20 +187,27 @@ if __name__ == '__main__':
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()
# 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
if args.elffile:
args.elffile.close()
if args.mapfile:
args.mapfile.close()
args.crashlog.close()