diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2021-09-07 02:14:32 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-07 12:58:46 +0200 |
commit | 783a58dbc77a5af99d979bcdbf64a97e43ca9be8 (patch) | |
tree | 46cd5c8112e94cff6a9174a01f3b191a5275a7f7 /Meta/debug-kernel.sh | |
parent | fe2e25edad8c2c9ee1b071fc8ef6cd0f8584d0b5 (diff) | |
download | serenity-783a58dbc77a5af99d979bcdbf64a97e43ca9be8.zip |
Toolchain: Build aarch64-gdb for cross-debugging on x86
Diffstat (limited to 'Meta/debug-kernel.sh')
-rwxr-xr-x | Meta/debug-kernel.sh | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/Meta/debug-kernel.sh b/Meta/debug-kernel.sh index 47d4bdc25e..235841944d 100755 --- a/Meta/debug-kernel.sh +++ b/Meta/debug-kernel.sh @@ -1,8 +1,18 @@ #!/bin/sh +SCRIPT_DIR="$(dirname "${0}")" + # Set this environment variable to override the default debugger. # -[ -z "$SERENITY_KERNEL_DEBUGGER" ] && SERENITY_KERNEL_DEBUGGER="gdb" +if [ -z "$SERENITY_KERNEL_DEBUGGER" ]; then + if [ "$SERENITY_ARCH" = "aarch64" ]; then + # Prepend the toolchain aarch64 bin directory so we pick up GDB from there + PATH="$SCRIPT_DIR/../Toolchain/Local/aarch64/bin:$PATH" + SERENITY_KERNEL_DEBUGGER="aarch64-pc-serenity-gdb" + else + SERENITY_KERNEL_DEBUGGER="gdb" + fi +fi # The QEMU -s option (enabled by default in ./run) sets up a debugger # remote on localhost:1234. So point our debugger there, and inform @@ -12,10 +22,14 @@ if [ "$SERENITY_ARCH" = "x86_64" ]; then gdb_arch=i386:x86-64 prekernel_image=Prekernel64 kernel_base=0x2000200000 -else +elif [ "$SERENITY_ARCH" = "i686" ]; then gdb_arch=i386:intel - prekernel_image=Prekernel + prekernel_image=Prekernel32 kernel_base=0xc0200000 +elif [ "$SERENITY_ARCH" = "aarch64" ]; then + gdb_arch=aarch64:armv8-r + prekernel_image=Prekernel + kernel_base=0xc0000000 # FIXME fi # FIXME: This doesn't work when running QEMU inside the WSL2 VM @@ -25,16 +39,17 @@ else gdb_host=localhost fi + exec $SERENITY_KERNEL_DEBUGGER \ - -ex "file $(dirname "$0")/../Build/${SERENITY_ARCH:-i686}/Kernel/Prekernel/$prekernel_image" \ + -ex "file $SCRIPT_DIR/../Build/${SERENITY_ARCH:-i686}/Kernel/Prekernel/$prekernel_image" \ -ex "set confirm off" \ - -ex "directory $(dirname "$0")/../Build/${SERENITY_ARCH:-i686}/" \ - -ex "add-symbol-file $(dirname "$0")/../Build/${SERENITY_ARCH:-i686}/Kernel/Kernel -o $kernel_base" \ + -ex "directory $SCRIPT_DIR/../Build/${SERENITY_ARCH:-i686}/" \ + -ex "add-symbol-file $SCRIPT_DIR/../Build/${SERENITY_ARCH:-i686}/Kernel/Kernel -o $kernel_base" \ -ex "set confirm on" \ -ex "set arch $gdb_arch" \ -ex "set print frame-arguments none" \ -ex "target remote ${gdb_host}:1234" \ - -ex "source $(dirname "$0")/serenity_gdb.py" \ + -ex "source $SCRIPT_DIR/serenity_gdb.py" \ -ex "layout asm" \ -ex "fs next" \ "$@" |