diff --git a/.gdbconf b/.gdbconf new file mode 100644 index 00000000..76713d3c --- /dev/null +++ b/.gdbconf @@ -0,0 +1,4 @@ +file initrd/boot/moon.elf +break _start +target remote :1234 +continue \ No newline at end of file diff --git a/README.md b/README.md index 8f5fc327..85747e62 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,8 @@ There are a variety of scripts for building Luna. `tools/build-iso.sh` will build, install, and make an ISO disk image named Luna.iso. +`tools/build-debug.sh` will rebuild the kernel with debug symbols and optimizations disabled, install, and make an ISO image. This script should only be used when you are going to be running the system with a debugger (such as GDB). + `tools/build-stable-iso.sh` does the same thing as build-iso.sh, but configures the kernel so that the version does not show the commit hash (used for stable versions). `tools/rebuild-iso.sh` will do a clean rebuild, install, and make an ISO disk image. @@ -54,7 +56,7 @@ You can choose between 3 run scripts: `tools/rebuild-and-run.sh` will rebuild, install, make an ISO, and run Luna in QEMU. -`tools/debug.sh` will rebuild the kernel with debug symbols and optimizations disabled, install, make an ISO image, and run Luna in QEMU with a port open for GDB to connect to. (run `gdb initrd/boot/moon.elf`, `break _start`, `target remote :1234`, and then `debug.sh` for an optimal debugging experience) +`tools/debug.sh` will run Luna in QEMU with a port open for GDB to connect to. (run `tools/build-debug.sh`, `tools/gdb.sh`, and then `tools/debug.sh` in a separate terminal for an optimal debugging experience) Beware that running without hardware virtualization/with optimizations disabled may cause the kernel to behave differently, which is why I don't use it that often. diff --git a/tools/build-debug.sh b/tools/build-debug.sh new file mode 100644 index 00000000..6494307c --- /dev/null +++ b/tools/build-debug.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +set -e +source $(dirname $0)/env.sh + +MOON_BUILD_DEBUG=1 tools/rebuild-iso.sh \ No newline at end of file diff --git a/tools/debug.sh b/tools/debug.sh index 71090fe6..edce3513 100755 --- a/tools/debug.sh +++ b/tools/debug.sh @@ -3,6 +3,4 @@ set -e source $(dirname $0)/env.sh -MOON_BUILD_DEBUG=1 tools/rebuild-iso.sh - -qemu-system-x86_64 -cdrom Luna.iso -smp 1 -m 256M -serial stdio -d int,cpu_reset -s -no-reboot $@ \ No newline at end of file +qemu-system-x86_64 -cdrom Luna.iso -smp 1 -m 256M -serial stdio -d int,cpu_reset -s $@ \ No newline at end of file diff --git a/tools/gdb.sh b/tools/gdb.sh new file mode 100644 index 00000000..680c6b27 --- /dev/null +++ b/tools/gdb.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +set -e +source $(dirname $0)/env.sh + +gdb -x .gdbconf \ No newline at end of file