Which tool is commonly used to debug C++ programs?
Analysis & Theory
`GDB` (GNU Debugger) is a widely used tool for debugging C and C++ programs.
What does a segmentation fault indicate in C++?
Analysis & Theory
A segmentation fault usually occurs when a program tries to access memory it shouldn't.
Which GDB command sets a breakpoint?
Analysis & Theory
`break` sets a breakpoint at a specific line or function in the program.
What does the `step` command do in GDB?
A
Skips to the next function
C
Executes the next line, entering functions
Analysis & Theory
`step` executes the next line of code and steps into any called functions.
Which of the following can help detect memory leaks in C++?
Analysis & Theory
`Valgrind` is a tool used to detect memory leaks and memory errors in C++.
Which keyword is useful for conditional debug output in C++?
Analysis & Theory
Using `#define DEBUG` and `#ifdef DEBUG` allows enabling/disabling debug output easily.
Which GDB command continues execution after a breakpoint?
Analysis & Theory
`continue` resumes program execution after stopping at a breakpoint.
What does the `next` command do in GDB?
C
Steps over function calls
Analysis & Theory
`next` executes the next line of code but skips over function calls.
Which type of error is easiest to catch with a debugger?
Analysis & Theory
Runtime errors like segmentation faults are best caught and analyzed using a debugger.
Which command in GDB shows the value of a variable?
Analysis & Theory
`print variable_name` displays the current value of a variable in GDB.