Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Debugging page faults

Below are some examples for debugging page faults using the Bochs emulator. We recommend using Bochs, rather than QEMU, to debug kernel crashes because QEMU exits when the kernel crashes, precluding after-the-fact debugging. In order to use the Bochs emulator for a specific test-run/debugging-session, use the FORCE_SIMULATOR environment variable. For example, to debug the do-nothing test using the Bochs emulator, you would run:

FORCE_SIMULATOR=--bochs PINTOS_DEBUG=1 pintos-test do-nothing

In the event that you encounter a bug that only shows up in QEMU, you can try setting a breakpoint in the page fault handler to allow for debugging before QEMU exits.

If you encounter a page fault during a test, you should use the method in Debugging Pintos tests to debug Pintos with GDB.

For example:

pintos-debug: a page fault occurred in kernel mode
#0 test_alarm_negative () at ../../tests/threads/alarm-negative.c:14
#1 0xc000ef4c in ?? ()
#2 0xc0020165 in start () at ../../threads/start.S:180

If you want to inspect the original environment where the page fault occurred, simply use the continue command:

(gdb) continue

After the kernel encounters the page fault, run these commands:

(gdb) set $eip = ((void**) $esp)[1]
(gdb) up
(gdb) down

You should now be able to inspect the local variables and the stack trace when the page fault occurred.