Debugging user-code on xv6 with gdb
file cat
, break main
, continue
semi reference running and debugging xv6
From the xv6 top-level dir:
Run the emulator in debug mode (assuming no X11):
make qemu-nox-gdb
In other terminal just run the debugger loading the kernel symbols with:
gdb kernel
This is important, otherwise the debugger will be confused between kernel and and user program symbols, for examplemain()
From the gdb interface run:
(gdb) target remote localhost:26000
where 26000 is the TCP port that the step #1 report at the end (this might change).Load the user exec with
(gdb)file user_program
Place a breakpoint
(gdb) break main
and continue with(gdb) continue
etc...