How to use GDB Part 2

Still not sure how to use GDB. I looked at the video and I can detect a cmd panic but I think I have a panic in my test? How would I GDB the test161? Or should I run the test in os161 in debug mode?

All tests ran by test161 can be individually run on the kernel cmdline. Run the tests individual with gdb attached. You can do the same with tests you wrote by adding them to the kernel menu.
Start by setting a breakpoint at the beginning of your test, you were running p testbin/consoletest. Maybe break common_prog or break consoletest.c:##line_to_break. From there step through your code using s, check what’s going on with i locals and bt full, you can also print variables individually p var…

EDIT: Also when stepping through it can be nice to have a visual for where you are in the code, you can use gdb tui mode. Press <ctrl-x a> to toggle tui mode. Do this when you hit a breakpoint. You can then see the code you are debugging.

1 Like

Hello benjamin, thank you for this response, I am sorry I am not following how to step into the userland code, like consoletest.c or forktest.c. What I run from bash is : os161-gdb kernel and connect to the sys161 kernel running in another shell. I tried setting a breakpoint in a userland test file, but gdb does not see the file to set a breakpoint in it.

Your help is very appreciated.

Thank you.