feat: tools: add address parser

This commit is contained in:
Paul Pan 2024-06-15 00:11:18 +08:00
parent 7757a174ce
commit e3be1c56cd

17
tools/parse_backtrace.sh Executable file
View File

@ -0,0 +1,17 @@
#!/bin/bash
if [[ $# -ne 1 ]]; then
echo "Usage: $0 <ELF_FILE>"
exit 1
fi
ELF_FILE=$1
while IFS= read -r line; do
if [[ $line =~ PC:\ VirtAddr\((0x[0-9a-fA-F]+)\) ]]; then
pc_address=${BASH_REMATCH[1]}
pc_function_info=$(addr2line -Cfpe "$ELF_FILE" "$pc_address")
line=$(echo "$line" | sed -E "s#FP: .*#$pc_function_info#")
fi
echo "$line"
done