summaryrefslogtreecommitdiffstats
path: root/scripts/debug-kernel.py
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-07-31 03:22:20 +0200
committersalmonik <salmonik@tuta.io>2026-07-31 03:22:20 +0200
commit0ace22d6f88692883584119c64ff010f4cee6738 (patch)
tree6f575f9088dec8bab90943d6c23e174bca183f0a /scripts/debug-kernel.py
parentrestructure: rsnix kernel + shell crate + rsdos entry point (diff)
downloadrs-dos-0ace22d6f88692883584119c64ff010f4cee6738.tar.gz
rs-dos-0ace22d6f88692883584119c64ff010f4cee6738.zip
fix(rsdos): organizational changes
Diffstat (limited to 'scripts/debug-kernel.py')
-rwxr-xr-xscripts/debug-kernel.py64
1 files changed, 64 insertions, 0 deletions
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 @@
1"""
2GDB Python script for debugging raisernics under QEMU.
3
4Usage:
5 1. Terminal 1: ./tools/qemu.sh --debug
6 2. Terminal 2: gdb -x tools/debug-kernel.py target/x86_64-unknown-uefi/debug/raisernics.efi
7"""
8
9import gdb
10import os
11
12# Find the kernel binary
13script_dir = os.path.dirname(os.path.abspath(__file__))
14project_root = os.path.dirname(script_dir)
15binary = os.path.join(
16 project_root,
17 "target/x86_64-unknown-uefi/debug/raisernics.efi"
18)
19
20# Connect to QEMU's GDB stub
21gdb.execute("target remote :1234")
22
23# Load the binary (add symbol table)
24if os.path.exists(binary):
25 gdb.execute(f"symbol-file {binary}")
26 print(f"Loaded symbols from {binary}")
27else:
28 print(f"WARNING: {binary} not found. Build with debug symbols first.")
29
30gdb.execute("set breakpoint pending on")
31
32
33# Helper commands
34class DumpBootServices(gdb.Command):
35 """Dump EFI boot services signature and key pointers"""
36
37 def __init__(self):
38 super().__init__("dump-bs", gdb.COMMAND_USER)
39
40 def invoke(self, argument, from_tty):
41 del argument, from_tty
42 gdb.execute("printf \"SystemTable, BootServices, and key function pointers\\n\"")
43 gdb.execute("info functions efi_main")
44
45
46class DumpGop(gdb.Command):
47 """Dump GOP framebuffer info"""
48
49 def __init__(self):
50 super().__init__("dump-gop", gdb.COMMAND_USER)
51
52 def invoke(self, argument, from_tty):
53 del argument, from_tty
54 gdb.execute("printf \"Check the gop::Framebuffer static\\n\"")
55
56
57DumpBootServices()
58DumpGop()
59
60print("")
61print("raisernics GDB session ready.")
62print(" target remote :1234 (connected)")
63print(" Commands: continue, stepi, bt, info registers, etc.")
64print(" Custom: dump-bs, dump-gop")