Separate building a debug image and running it, and provide a script for GDB.

This commit is contained in:
apio 2022-10-08 15:32:48 +02:00
parent 309058888c
commit aa5c1be945
5 changed files with 20 additions and 4 deletions

4
.gdbconf Normal file
View File

@ -0,0 +1,4 @@
file initrd/boot/moon.elf
break _start
target remote :1234
continue

View File

@ -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.

6
tools/build-debug.sh Normal file
View File

@ -0,0 +1,6 @@
#!/bin/sh
set -e
source $(dirname $0)/env.sh
MOON_BUILD_DEBUG=1 tools/rebuild-iso.sh

View File

@ -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 $@
qemu-system-x86_64 -cdrom Luna.iso -smp 1 -m 256M -serial stdio -d int,cpu_reset -s $@

6
tools/gdb.sh Normal file
View File

@ -0,0 +1,6 @@
#!/bin/sh
set -e
source $(dirname $0)/env.sh
gdb -x .gdbconf