1 / 20

Debuggers

Debuggers. Using a debugger. A primitive way of debugging is to insert print statements. Using a debugger. A primitive way of debugging is to insert print statements. That’s OK but a debugger is much more powerful. It’s a program that watches and controls another program as it runs!.

lala
Download Presentation

Debuggers

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Debuggers

  2. Using a debugger • A primitive way of debugging is to insert print statements.

  3. Using a debugger • A primitive way of debugging is to insert print statements. • That’s OK but a debugger is much more powerful. • It’s a program that watches and controls another program as it runs!

  4. Using a debugger • A primitive way of debugging is to insert print statements. • That’s OK but a debugger is much more powerful. • It’s a program that watches and controls another program as it runs! • It allows us to execute our code one line at a time. • It allows us to set breakpoints (stop points) in our code. • We can even examine and change the contents of variables as our program runs!

  5. jgrasp

  6. Setting a breakpoint (jGRASP)

  7. Breakpoint is now set (jGRASP)

  8. Start the debugger (jGRASP) • Build -> Debug • The program then runs and stops at our first breakpoint.

  9. step over step in step out jGRASP variables (r-click to change value) next line to be executed end debugging

  10. VC++

  11. Setting a breakpoint (VC++)

  12. Starting the debugger (VC++)

  13. Watch variables (VC++)

  14. VC++ debugging options

  15. gdb

  16. Debugging with gdb (Unix/Linux) • Direct compiler to include debugging information with –g (ex. g++ -g test.cpp) • Run the debugger and indicate program to debug (ex. gdb ./a.out)

  17. Setting a breakpoint (gdb) in main and start running

  18. Print and set (change) var

  19. List source code

  20. Useful gdb commands • b main set breakpoint in func main • b 10 set breakpoint at line #10 • cont continue • del break delete all breakpoints • l (ell) list source code lines • l <func> (ell) list source code lines for <func> • n next (like step over) • p <var> print contents of variable • quit end execution • run start running program • s step (like step into) • set <var>=value change var

More Related