tiny_os/tools/parse_backtrace.sh

18 lines
392 B
Bash
Executable File

#!/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