Debuggers
Jump to navigation
Jump to search
A debugger is a tool that lets you walk through the execution of a program to identify and resolve bugs.
Why
- Lets me go through a program step by step
- I don't have to write print statements in a long program where I am unsure about what I want to achieve
- Depending on the debugger, I can go back in time (the debugger in this case keeps track of all changes a program makes so they can be reverted) to replay a step in a program.
Examples
- gdb (for C and C-based programs)
- Pdb (for Python)
- Pdb is a hybrid of a debugger and a programming environment. You can run valid Python code in Pdb.
Features
- Step back to a previous line of code
- Step forward to the next line of code
- Change the value of a variable (Pdb)
- See the Assembly calls behind a line of code (gdb)
Usage Notes
- A blank line (created when you click Enter) runs the same command as the one you last executed
- Set a breakpoint where the program will stop
- In the case of Pdb, import the library on the line where I want the interactive prompt to come up
See Also
- Program Introspection talk on Missing Semester
- Profilers