-
Notifications
You must be signed in to change notification settings - Fork 107
Kernel Debugging
This page is a collection of various techniques and tips for debugging the Harvey kernel.
When running Harvey in QEMU using the usual launch scripts, you can connect gdb by running:
gdb sys/src/9/amd64/harvey
gdb> set architecture i386:x86-64
The target architecture is assumed to be i386:x86-64
gdb> target remote localhost:1234
Insert die("labelfoo")
where you want the kernel to stop. Once the kernel prints out labelfoo
, connect gdb as shown here. Inside die()
the CPU is spinning on the variable staydead
. From gdb, set staydead=0
to enable Harvey to continue.
To print info for every syscall enter and exit, go to syscall.c
, set the variable printallsyscalls
to 1 and recompile the kernel.
The Harvey kernel can be forced to run on only a single core by setting nosmp=1
in the sys/src/9/amd64/main.c
.
Another option is to modify the GO9PCPU
or GO9PTERM
script to change the -smp 4
flag to -smp 1
.