AX.25 Terminal Node Controller (TNC)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

53 lines
1.4 KiB

#!/usr/bin/env python3
import argparse
import glob
import os
import subprocess
import sys
def find_elf():
elfs = glob.glob('.pioenvs/*/*.elf')
if len(elfs) == 0:
raise ValueError('No .elf files found in .pioenvs/*')
elif len(elfs) == 1:
return elfs[0]
else:
raise ValueError('Multiple .elf files found in .pioenvs, specify --elf')
def decode(line, args):
line = line.strip()
if line.startswith('Backtrace: '):
line = line.split(': ', 1)[1]
# Backtrace: 0x4008c9e4:0x3ffd0610 0x4008cc15:0x3ffd0630 0x400d9f87:0x3ffd0650 0x400f3feb:0x3ffd0680 0x40120113:0x3ffd06a0 0x40120163:0x3ffd0730 0x400887f5:0x3ffd0760
part = line.split()
addr = [x.split(':')[0] for x in part]
cmnd = [args.tool, '-aipfC', '-e', args.elf] + addr
print(' '.join(cmnd))
#outs = subprocess.check_output(cmnd, encoding='utf-8')
outs = subprocess.check_output(cmnd)
for outp in outs.splitlines():
print(outp)
def run():
parser = argparse.ArgumentParser()
parser.add_argument('-t', '--tool', default=os.path.expanduser('~/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-addr2line'))
parser.add_argument('-e', '--elf', default='')
args = parser.parse_args()
if not args.elf:
args.elf = find_elf()
for line in sys.stdin.readlines():
decode(line, args)
if __name__ == '__main__':
sys.exit(run())