1/11
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Why is debugging important?
Helps trace code execution and understand lower abstraction levels.
Validates assumptions, verifies data, and memory.
Essential for finding and fixing bugs.
What is a debugger?
An external tool to inspect program execution and runtime properties, like:
Memory, variables, objects, threads, registers, and call stacks.
Requires language support (e.g., debug symbols like DWARF).
More efficient than using print statements.
When should you use a debugger vs. printing/logging?
Use a debugger during development to inspect code execution.
Use printing/logging when a debugger is unavailable (e.g., in production or on player devices).
What is the #1 feature of a debugger?
The ability to pause program execution at specific points using breakpoints.
Can be achieved in various ways, but typically by setting breakpoints
What are breakpoints?
Points in the source code where the debugger halts execution for introspection.
Useful for examining threads, variables, and call stacks.
What is a halted context?
The state of the program when execution is paused, allowing you to inspect:
Threads, call stacks, local variables, objects, and registers.
What is a call stack?
Shows how the program reached the current line of code.
Includes the sequence of function calls and the current thread.
What are watchpoints?
Advanced breakpoints that pause execution when:
Specific variables or memory accesses meet conditions (e.g., variable <= 5).
Supported in tools like VSCode and Chrome debugger.
How do breakpoints work under the hood?
Software Breakpoints: Replace an instruction with a trap that interrupts the program.
Hardware Breakpoints: Use dedicated CPU registers to halt execution.
What is DWARF in debugging?
(DWARF):
Converts program memory and addresses into source code and variables.
Requires compiler flags like -g
for languages like C/C++, Rust, or Swift.
difference between breakpoint and watchpoint?
A breakpoint hits every game hits, watchpoint only hits when a condition happens
What are the steps a debugger can perform during a halted context?
Step to the next line of code.
Step into a function call.
Return to the calling function.