summaryrefslogtreecommitdiffstats
path: root/tools/debug-kernel.py
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-07-31 02:18:30 +0200
committersalmonik <salmonik@tuta.io>2026-07-31 02:18:30 +0200
commit76103215711d268b4b02f62e900f2be3032cf295 (patch)
treedcd86b5b02ae99c99ca833668055f4f53211be6b /tools/debug-kernel.py
downloadrs-dos-76103215711d268b4b02f62e900f2be3032cf295.tar.gz
rs-dos-76103215711d268b4b02f62e900f2be3032cf295.zip
Initial commit: raisernics toy kernel
- Bare-metal x86_64 UEFI kernel (PE32+, no libc) - GOP framebuffer + 8x16 bitmap font - PS/2 keyboard (polling, scancode set 1) - UART 16550 serial driver (COM1, 115200 8N1) - Bump allocator as #[global_allocator] (alloc::String, Vec, format!) - UEFI memory map capture (static buffer, ADR 0001) - Shell with 7 commands (help, echo, clear, hello, info, mem, halt) - Dual output: GOP framebuffer + serial console - Makefile: run, run-gui, debug, release, image targets - tools/: qemu.sh, boot-image.sh, debug-kernel.py
Diffstat (limited to 'tools/debug-kernel.py')
-rwxr-xr-xtools/debug-kernel.py64
1 files changed, 64 insertions, 0 deletions
diff --git a/tools/debug-kernel.py b/tools/debug-kernel.py
new file mode 100755
index 0000000..c794ad6
--- /dev/null
+++ b/tools/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")