Skip to content

Commit 274c3fa

Browse files
committed
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
1 parent 73cfc7b commit 274c3fa

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

tools/debug_tools/crash_log_parser/crash_log_parser.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,17 @@ def main(crash_log, elfhelper):
130130

131131
elif eachline.startswith("PC"):
132132
pc_val = parse_line_for_register(eachline)
133-
pc_name = elfhelper.function_name_for_addr(int(pc_val, 16))
133+
if elfhelper:
134+
pc_name = elfhelper.function_name_for_addr(int(pc_val, 16))
135+
else:
136+
pc_name = "<unknown-symbol>"
134137

135138
elif eachline.startswith("LR"):
136139
lr_val = parse_line_for_register(eachline)
137-
lr_name = elfhelper.function_name_for_addr(int(lr_val, 16))
140+
if elfhelper:
141+
lr_name = elfhelper.function_name_for_addr(int(lr_val, 16))
142+
else:
143+
lr_name = "<unknown-symbol>"
138144

139145
elif eachline.startswith("SP"):
140146
sp_val = parse_line_for_register(eachline)
@@ -181,20 +187,27 @@ def main(crash_log, elfhelper):
181187
parser.add_argument(metavar='CRASH LOG', type=argparse.FileType('rb', 0),
182188
dest='crashlog',help='path to crash log file')
183189
parser.add_argument(metavar='ELF FILE', type=argparse.FileType('rb', 0),
184-
dest='elffile',help='path to elf file')
190+
nargs='?',const=None,dest='elffile',help='path to elf file')
185191
parser.add_argument(metavar='MAP FILE', type=argparse.FileType('rb', 0),
186-
dest='mapfile',help='path to map file')
192+
nargs='?',const=None,dest='mapfile',help='path to map file')
187193

188194
# get and validate arguments
189195
args = parser.parse_args()
190-
191-
elfhelper = ElfHelper(args.elffile, args.mapfile)
196+
197+
# if both the ELF and MAP files are present, the addresses can be converted to symbol names
198+
if args.elffile and args.mapfile:
199+
elfhelper = ElfHelper(args.elffile, args.mapfile)
200+
else:
201+
print("ELF or MAP file missing, logging raw values.")
202+
elfhelper = None
192203

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

196207
#close all files
197-
args.elffile.close()
198-
args.mapfile.close()
208+
if args.elffile:
209+
args.elffile.close()
210+
if args.mapfile:
211+
args.mapfile.close()
199212
args.crashlog.close()
200213

0 commit comments

Comments
 (0)