tiny_os/tools/parse_backtrace.sh

18 lines
323 B
Bash
Raw Permalink Normal View History

2024-06-15 00:11:18 +08:00
#!/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
addr=${BASH_REMATCH[1]}
func=$(addr2line -Cfpe "$ELF_FILE" "$addr")
line+=" $func"
2024-06-15 00:11:18 +08:00
fi
echo "$line"
done