ChCore-exercise/lab4/scripts/create_gdbinit.sh
2021-05-16 18:27:01 +08:00

22 lines
574 B
Bash
Executable File

#!/bin/bash
TEST=$1
cat << EOF > .gdbinit
set architecture aarch64
target remote localhost:1234
define add-symbol-file-auto
# Parse .text address to temp file
shell echo set \\\$text_address=\$(readelf -WS \$arg0 | grep .text | awk '{ print "0x"\$5 }') >/tmp/temp_gdb_text_address.txt
# Source .text address
source /tmp/temp_gdb_text_address.txt
# Clean tempfile
shell rm -f /tmp/temp_gdb_text_address.txt
# Load symbol table
add-symbol-file \$arg0 \$text_address
end
add-symbol-file-auto ./build/kernel.img
add-symbol-file-auto ./user/build/ramdisk/$1.bin
EOF