% cd linux
CFLAGS := -Wall -Wstrict-prototypes -Wno-trigraphs -O1 -g -fno-strict-aliasing -fno-common
AFLAGS := -D__ASSEMBLY__ -Wa,-gdwarf2
% make vmlinux
mysim config kdebug_enable 1
Kdebug uses two important variables. Normally they are set automatically when the kernel is loaded. "kdebug_virtual" is the address to which the kernel .text is linked. "kdebug_real" should be the real address in Systemsim to which you load the kernel. For example, on a 32-bit target you might load the OS at address 0x0, but it is linked at addres 0xC0000000. You would then set:
mysim config kdebug_virtual 0xC0000000
mysim config kdebug_real 0x00000000
You can see the current values of the kdebug_* variables by using the config command without providing a value.
% ../run_cmdline -f .systemsim.tcl
systemsim % sim spruce mysim
systemsim % mysim load vmlinux ./vmlinux 0x0
systemsim % mysim debugger wait 0
WARNING : Waiting for GDB to attach on port 2345
% cd linux (go to the linux source directory)
% powerpc64-linux-gdb
(gdb) file ./vmlinux
(gdb) set architecture powerpc:a35
(gdb) target remote :2345
Now set breakpoints and begin simulation with "c"
(gdb) c
At this point, you can use normal GDB commands to trace the execution of Linux
step: source-level stepping stepi: step one machine instruction ctrl-c: pause simulation and get gdb prompt. info registers: print the registers info float: print floating point registers p/x $pc: print the PC p/x $r1: print register r1 detach: return to Systemsim prompt.
To reattach, In Systemsim type "mysim debug wait 0" and in gdb type "target remote :2345".