From 0ace22d6f88692883584119c64ff010f4cee6738 Mon Sep 17 00:00:00 2001 From: salmonik Date: Fri, 31 Jul 2026 03:22:20 +0200 Subject: fix(rsdos): organizational changes --- scripts/debug-kernel.py | 64 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100755 scripts/debug-kernel.py (limited to 'scripts/debug-kernel.py') diff --git a/scripts/debug-kernel.py b/scripts/debug-kernel.py new file mode 100755 index 0000000..c794ad6 --- /dev/null +++ b/scripts/debug-kernel.py @@ -0,0 +1,64 @@ +""" +GDB Python script for debugging raisernics under QEMU. + +Usage: + 1. Terminal 1: ./tools/qemu.sh --debug + 2. Terminal 2: gdb -x tools/debug-kernel.py target/x86_64-unknown-uefi/debug/raisernics.efi +""" + +import gdb +import os + +# Find the kernel binary +script_dir = os.path.dirname(os.path.abspath(__file__)) +project_root = os.path.dirname(script_dir) +binary = os.path.join( + project_root, + "target/x86_64-unknown-uefi/debug/raisernics.efi" +) + +# Connect to QEMU's GDB stub +gdb.execute("target remote :1234") + +# Load the binary (add symbol table) +if os.path.exists(binary): + gdb.execute(f"symbol-file {binary}") + print(f"Loaded symbols from {binary}") +else: + print(f"WARNING: {binary} not found. Build with debug symbols first.") + +gdb.execute("set breakpoint pending on") + + +# Helper commands +class DumpBootServices(gdb.Command): + """Dump EFI boot services signature and key pointers""" + + def __init__(self): + super().__init__("dump-bs", gdb.COMMAND_USER) + + def invoke(self, argument, from_tty): + del argument, from_tty + gdb.execute("printf \"SystemTable, BootServices, and key function pointers\\n\"") + gdb.execute("info functions efi_main") + + +class DumpGop(gdb.Command): + """Dump GOP framebuffer info""" + + def __init__(self): + super().__init__("dump-gop", gdb.COMMAND_USER) + + def invoke(self, argument, from_tty): + del argument, from_tty + gdb.execute("printf \"Check the gop::Framebuffer static\\n\"") + + +DumpBootServices() +DumpGop() + +print("") +print("raisernics GDB session ready.") +print(" target remote :1234 (connected)") +print(" Commands: continue, stepi, bt, info registers, etc.") +print(" Custom: dump-bs, dump-gop") -- cgit v1.2.3