Link Search Menu Expand Document

Debugging Pintos tests

Running the debugger for a individual Pintos test is very similar to just running the test. The steps for doing so are nearly identical to those given in Running Pintos tests, with the only difference being that you’ll need to add the PINTOS_DEBUG environment variable. For example, to debug the stack-align-0 test, you would do the following:

make
PINTOS_DEBUG=1 pintos-test stack-align-0

This will open GDB in your current terminal. Simply enter debugpintos to connect to the Pintos process, then proceed with setting breakpoints, continuing, etc. When you are done debugging, type quit in GDB, and you then will see whatever output the test created while it was running.

When you want to debug a test, running pintos-test with PINTOS DEBUG=1 is what you want to do 99% of the time.

Rarely however, you will want to see what the test is outputting while you are stepping through it in the debugger. To do this, the instructions are slightly different. Most of the above will remain the same, except that you will set PINTOS_DEBUG=2 (note 2 instead of 1). When you run pintos-test with PINTOS_DEBUG=2, GDB will not open in your current terminal; instead, the output of the test will be shown live in your current terminal. You’ll need to open a second terminal (either through tmux or by just ssh’ing into your VM again in a separate terminal window), navigate to the build/ subdirectory of the directory you ran pintos-test in, then run pintos-gdb kernel.o. For example, to debug the open-twice test while being able to observe its live output, you would do the following:

cd ~/code/personal/proj-pregame/src/userprog
make
PINTOS_DEBUG=2 pintos-test open-twice

Then open a second terminal, and do the following:

cd ~/code/personal/proj-pregame/src/userprog/build
pintos-gdb kernel.o

In your second terminal, GDB should now be open. Enter debugpintos to connect to the Pintos process, and proceed with debugging as usual. The only difference is that now the live output of the process you’re debugging will appear in your first terminal.