[contents]
[usage]
[execution]
[stack]
[breakpoints]
[watchpoints]
[advanced]
4. How do I use breakpoints?Breakpoints are a way of telling gdb that you want it to stop your program at certain lines of code. You can also have it stop when your program makes specific function calls. Once the program is stopped, you can poke around in memory and see what the values of all your variables are, examine the stack, and step through your program's execution. How do I ...?
4.1 How do I set a breakpoint on a line? [top]  [toc]The command to set a breakpoint is break. If you only have one source file, you can set a breakpoint like so:
If you have more than one file, you must give the break command a filename as well:
4.2 How do I set a breakpoint on a C function? [top]  [toc]To set a breakpoint on a C function, pass it's name to break.
4.3 How do I set a breakpoint on a C++ function? [top]  [toc]Setting a breakpoint on a C++ function is similar to setting a breakpoint on a C function. However C++ is polymorphic, so you must tell break which version of the function you want to break on (even if there is only one). To do this, you tell it the list of argument types.
4.4 How do I set a temporary breakpoint? [top]  [toc]Use the tbreak command instead of break. A temporary breakpoint only stops the program once, and is then removed. 4.5 How do I get a list of breakpoints? [top]  [toc]Use the info breakpoints command.
4.6 How do I disable breakpoints? [top]  [toc]Use the disable command. Pass the number of the breakpoint you wish to disable as an argument to this command. You can find the breakpoint number in the list of breakpoints, as shown above. In the example below we can see that breakpoint number 2 has been disabled (there is an 'n' under the Enb column).
4.7 How do I skip breakpoints? [top]  [toc]To skip a breakpoint a certain number of times, we use the ignore command. The ignore command takes two arguments: the breakpoint number to skip, and the number of times to skip it.
[contents] [usage] [execution] [stack] [breakpoints] [watchpoints] [advanced] Questions? Comments? Flames? email rms@unknownroad.com |