From b668000e44029d2c0088e415a24dad385aeadbe8 Mon Sep 17 00:00:00 2001 From: Daniel Bertalan Date: Sat, 11 Mar 2023 20:09:10 +0100 Subject: [PATCH] Meta+Documentation: Allow cross-debugging x86_64 Serenity on M1 Macs While there is no native GDB on Apple Silicon, a cross-debugger that supports x86-64 does exist. --- Documentation/BuildInstructionsMacOS.md | 6 ++++++ Meta/debug-kernel.sh | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Documentation/BuildInstructionsMacOS.md b/Documentation/BuildInstructionsMacOS.md index d69daca42e..e29df79970 100644 --- a/Documentation/BuildInstructionsMacOS.md +++ b/Documentation/BuildInstructionsMacOS.md @@ -22,6 +22,9 @@ Toolchain/BuildFuseExt2.sh # (option 2) genext2fs brew install genext2fs + +# for kernel debugging, on Apple Silicon +brew install x86_64-elf-gdb ``` If you have Xcode version 13 or older, also install a newer host compiler from homebrew. Xcode 14 is known to work. @@ -51,3 +54,6 @@ It's important to make sure that Xcode is not only installed but also accordingl Homebrew is known to ship bleeding edge CMake versions, but building CMake from source with homebrew gcc or llvm may not work. If homebrew does not offer cmake 3.25.x+ on your platform, it may be necessary to manually run Toolchain/BuildCMake.sh with Apple clang from Xcode as the first compiler in your $PATH. + +If you want to debug the x86-64 kernel on an Apple Silicon machine, you can install the `x86_64-elf-gdb` +package to get a native build of GDB that can cross-debug x86-64 code. diff --git a/Meta/debug-kernel.sh b/Meta/debug-kernel.sh index 603eeb6dc6..3393673b29 100755 --- a/Meta/debug-kernel.sh +++ b/Meta/debug-kernel.sh @@ -14,7 +14,11 @@ if [ -z "$SERENITY_KERNEL_DEBUGGER" ]; then PATH="$SCRIPT_DIR/../Toolchain/Local/aarch64/bin:$PATH" SERENITY_KERNEL_DEBUGGER="aarch64-pc-serenity-gdb" else - SERENITY_KERNEL_DEBUGGER="gdb" + if command -v x86_64-elf-gdb >/dev/null 2>&1; then + SERENITY_KERNEL_DEBUGGER="x86_64-elf-gdb" + else + SERENITY_KERNEL_DEBUGGER=gdb + fi fi fi