February 10, 2014

gdb tips

I usually debug lLnux programs using gdb, I like the neatness of the tui mode, thanks for that feature! Here are some simple commands to get you started using gdb. There are several major doc out there, this is simply meant as a quick start and remembering reference for me, I'll make no attempt to replace any of these.
  • Starting your program with arguments: gdb -tui --args love_calc john jane
  • Setting a breakpoint in a specific file (in your huge project): b filename.cpp:linenum, i.e. b posix_thread.cpp:25
  • Stepping is s or (step) stepping into is stepi and continue is c.
  • Examining variables is done with p variable_name, i.e. p argv[1]
The above image shows the result of the commands.

There's a small guide from gnu on tui single key mode & a quick guide if you need more than I have shown here.





No comments: