Reading this: Scala Native on the Playdate - #11 by dave
aha! I forgot that in the elf we have it compiled to 0x0 and then we relocate to either 0x6xxx or 0x9xxx at load time. So the correct lookup there is
info line *0x1aa4b
:
Turns out the symbolizer from the SDK is not taking this in to account, and the one I was using had a bug when passing the arguments to arm-none-eabi-addr2line
here is a modified version of the symbolizer
import re
import subprocess
import click
"""
SETUP:
1. pip3 install click
2. make sure arm-none-eabi-addr2line is in your $PATH
USAGE:
python3 firmware_symbolizer.py crashlog.txt game.elf
"""
@click.command()
@click.argument("crashlog", type=click.Path(exists=True))
@click.argument("elf", type=click.Path(exists=True))
def symbolize(crashlog, elf):
cl_contents = open(crashlog, "r").read()
cl_blocks = re.split(r"\n\n", cl_contents)
for block in cl_blocks:
matches = re.search(r"lr:([0-9a-f]{8})\s+pc:([0-9a-f]{8})", block)
if matches:
print(block, "\n")
lr = matches.group(1)
pc = matches.group(2)
lr_num = int(lr, 16)
pc_num = int(pc, 16)
lr_num = lr_num & 0x0FFFFFFF
pc_num = pc_num & 0x0FFFFFFF
print("lr: {} -> {}".format(hex(int(lr, 16)), lr_num))
lr = hex(lr_num)
pc = hex(pc_num)
cmd = f"arm-none-eabi-addr2line -f -i -p -e {elf} {pc} {lr}"
print(cmd)
stack = subprocess.check_output(cmd, shell=True).decode("ASCII")
print(stack)
if __name__ == "__main__":
symbolize()