Hide menu

More on debugging

Debugging using bactrace

The backtrace tool is very convenient to find out where the pintos kernel panics. When a kernel panic happens pintos will print out the addresses call stack of the functions that were running whne the panic happend. However, from a humans perspecitve the adresses will not be of much help. The backtrace command can help translate addresses to human understandable form. For example if we run the following command (whitout having a disk file):

        pintos --qemu -- ls 
Pintos will panic and output similar to the following will show up:
Writing command line to /tmp/HQKKT9krUO.dsk...
qemu -hda /tmp/HQKKT9krUO.dsk -m 4 -net none -serial stdio
Kernel command line: ls
Pintos booting with 4,088 kB RAM...
371 pages available in kernel pool.
371 pages available in user pool.
Calibrating timer...  209,510,400 loops/s.
Boot complete.
Kernel PANIC at ../../threads/init.c:308 in run_actions(): unknown action `ls' (use -h for help)
Call stack: 0xc0106e2b.
The `backtrace' program can make call stacks useful.
Read "Backtraces" in the "Debugging Tools" chapter
of the Pintos documentation for more information.
If we run backtrace with the call stack address:
        backtrace 0xc0106e2b 
A hint where the crash might have happen will show.
        0xc0106e2b: debug_panic (.../../lib/kernel/debug.c:34)
Be aware that the line number might be a bit inaccurate.

Debugging wih GDB

Here is an example of how to debug pintos using gdb.
  1. Change to the pintos/threads/build directory.
  2. Start pintos pintos -v --qemu --gdb -- run alarm-single
    Something similar will show up:
    Writing command line to /tmp/efpJEn9yH8.dsk...
    qemu -hda /tmp/efpJEn9yH8.dsk -m 4 -net none -nographic -s -S

    pintos will now halt
  3. Open another terminal and run pintos-gdb kernel.o
  4. In the gdb command line runt target remote localhost:1234
  5. Type: c
  6. Go back to the first terminal and see that pintos now will continue executing!

More information

Additional information on debugging and DDD can be found in the following slides.