| #!/bin/bash |
| |
| # usage: ./tools/backtrace/lk_backtrace.sh "/mtkeda/Bach/mt6297/20180310/arm/buildroot-2018.02/output/host/bin/arm-linux" "out/tmp/lk.elf" 0x42009D60 0x420111A1 0x4200E617 0x4200055F 0x4200AD3F 0x4200A74B 0x4200A731 0x4204A228 |
| CROSS=$1 |
| ADDR2LINE=$CROSS-addr2line |
| LK_ELF=$2 |
| |
| if [ "$#" -le "2" ]; then |
| echo "Usage: $0 <cross prefix> <lk elf> <address list>" |
| exit |
| fi |
| |
| # $3 is address list |
| shift 2 |
| |
| RED_PAT="\033[37;41m" |
| BLUE_PAT="\033[37;44m" |
| RESET_PAT="\033[0m" |
| |
| echo "" |
| echo "LK ELF: $LK_ELF" |
| echo "Find Address: $*" |
| |
| echo "---------------- backtrace -------------" |
| out=`$ADDR2LINE -e $LK_ELF -f -i $*` |
| while read -r fname; do |
| addr=$1 |
| read file |
| shift |
| echo -e "[$RED_PAT$addr$RESET_PAT]: $BLUE_PAT$fname$RESET_PAT, $file" |
| if [ "$#" -eq 0 ]; then |
| break |
| fi |
| done <<< "$out" |
| echo "-------------------------- -------------" |
| echo "" |