mirror of
https://github.com/rcore-os/rCore.git
synced 2024-11-21 23:56:18 +04:00
Add addr2line tool for annotating backtrace
This commit is contained in:
parent
e3262698be
commit
5350ecb09f
@ -5,6 +5,7 @@
|
||||
# make doc Generate docs
|
||||
# make asm Open the deassemble file of the last build
|
||||
# make header Open 'objdump -h' of the last build
|
||||
# make addr2line Use addr2line to recover line info in backtrace
|
||||
# make clean Clean
|
||||
#
|
||||
# Options:
|
||||
@ -262,3 +263,7 @@ install: $(bin)
|
||||
## baudrate no more than 600000
|
||||
@python3 ../tools/k210/kflash.py $(bin) -b 600000
|
||||
endif
|
||||
|
||||
.PHONY:
|
||||
addr2line:
|
||||
@python3 ../tools/addr2line.py $(prefix)addr2line $(arch)
|
||||
|
19
tools/addr2line.py
Normal file
19
tools/addr2line.py
Normal file
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
print('Paste backtrace here, and then input EOF(Ctrl-D or Ctrl-Z) to get annotated backtrace.')
|
||||
lines = sys.stdin.readlines()
|
||||
addrline = sys.argv[1]
|
||||
arch = sys.argv[2]
|
||||
print('--------------------------------------')
|
||||
for line in lines:
|
||||
match = re.search('(#[0-9]+ )(0x[0-9A-F]+)( fp 0x[0-9A-F]+)', line)
|
||||
if match:
|
||||
addr = match.group(2)
|
||||
process = subprocess.run([addrline, '-e', 'target/{0}/debug/rcore'.format(arch), '-f', '-C', addr], capture_output=True)
|
||||
res = process.stdout.decode('utf-8')
|
||||
print('{0}{1}{3} {2}'.format(match.group(1), match.group(2), res.strip(), match.group(3)))
|
||||
else:
|
||||
print(line, end='')
|
Loading…
Reference in New Issue
Block a user