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

Debugging Pintos tests

Virtual Machine Debugging

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.

Instructional Machine Debugging

There have been issues with the previous debugger which affects connecting to localhost:1234. This primarily applies to instructional machine users. To remedy this, we have upgraded pintos-test to automatically select a random port. Like the old debugger, you will still run the same commands outside of GDB. For example, to debug the stack-align-0 test, you would still do the following:

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

However, once this opens up GDB, it will automatically connect to the Pintos process. You will no longer need to run debugpintos. You can then proceed with setting breakpoints, continuing, etc. Just like before, when you are done debugging, type quit in GDB, and you then will see whatever output the test created while it was running.

All instructional machines will have the updated pintos-test scripts. There are no further steps required.

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.