Breakpoints
- Setting Breakpoints:
- Deleting Breakpoints:
- Disabling Breakpoints:
- Temporary Breakpoints:
- Editing Breakpoint Properties:
- Breakpoint Conditions:
- Breakpoint Ignore Counts:
- Breakpoint Commands:
- Moving and Copying Breakpoints:
- Looking up Breakpoints:
- Editing all Breakpoints:
- Hardware-Assisted Breakpoints:
Node:Setting Breakpoints, Next:Deleting Breakpoints, Up:Breakpoints
Setting Breakpoints
You can set breakpoints by location or by name.
Setting Breakpoints by Location
Breakpoints are set at a specific location in the program.
If the source line is visible, click with mouse button 1 on the left of the source line and then on the Break
button.
As a faster alternative, you can simply press mouse button 3 on the left of the source line and select the Set Breakpoint
item from the line popup menu.
As an even faster alternative, you can simply double-click on the left of the source line to set a breakpoint.
As yet another alternative, you can select Source => Breakpoints
. Click on the Break
button and enter the location.
(If you find this number of alternatives confusing, be aware that DDD users fall into three categories, which must all be supported. Novice users explore DDD and may prefer to use one single mouse button. Advanced users know how to use shortcuts and prefer popup menus. Experienced users prefer the command line interface.)
Breakpoints are indicated by a plain stop sign, or as #
Illegal HTML tag removed : n, where Illegal HTML tag removed : n is the breakpoint number. A greyed out stop sign (or _
Illegal HTML tag removed : n_
) indicates a disabled breakpoint. A stop sign with a question mark (or ?
Illegal HTML tag removed : n?
) indicates a conditional breakpoint or a breakpoint with an ignore count set.
If you set a breakpoint by mistake, use Edit => Undo
to delete it again.
Setting Breakpoints by Name
If the function name is visible, click with mouse button 1 on the function name. The function name is then copied to the argument field. Click on the Break
button to set a breakpoint there.
As a shorter alternative, you can simply press mouse button 3 on the function name and select the Break at
item from the popup menu.
As yet another alternative, you can click on Break...
from the Breakpoint editor (invoked through Source => Breakpoints
) and enter the function name.
Setting Regexp Breakpoints
Using GDB, you can also set a breakpoint on all functions that match a given string. Break => Set Breakpoints at Regexp ()
sets a breakpoint on all functions whose name matches the regular expression given in ()
. Here are some examples:
- To set a breakpoint on every function that starts with
Xm
, set()
to^Xm
. - To set a breakpoint on every member of class
Date
, set()
to^Date::
. - To set a breakpoint on every function whose name contains
_fun
, set()
to_fun
. - To set a breakpoint on every function that ends in
_test
, set()
to_test$
.
Node:Deleting Breakpoints, Next:Disabling Breakpoints, Previous:Setting Breakpoints, Up:Breakpoints
Deleting Breakpoints
To delete a visible breakpoint, click with mouse button 1 on the breakpoint. The breakpoint location is copied to the argument field. Click on the Clear
button to delete all breakpoints there.
If the function name is visible, click with mouse button 1 on the function name. The function name is copied to the argument field. Click on the Clear
button to clear all breakpoints there.
As a faster alternative, you can simply press mouse button 3 on the breakpoint and select the Delete Breakpoint
item from the popup menu.
As yet another alternative, you can select the breakpoint and click on Delete
in the Breakpoint editor (invoked through Source => Breakpoints
).
As an even faster alternative, you can simply double-click on the breakpoint while holding <Ctrl>.
Node:Disabling Breakpoints, Next:Temporary Breakpoints, Previous:Deleting Breakpoints, Up:Breakpoints
Disabling Breakpoints
Rather than deleting a breakpoint or watchpoint, you might prefer to Illegal HTML tag removed : disable it. This makes the breakpoint inoperative as if it had been deleted, but remembers the information on the breakpoint so that you can Illegal HTML tag removed : enable it again later.12
To disable a breakpoint, press mouse button 3 on the breakpoint symbol and select the Disable Breakpoint
item from the breakpoint popup menu. To enable it again, select Enable Breakpoint
.
As an alternative, you can select the breakpoint and click on Disable
or Enable
in the Breakpoint editor (invoked through Source => Breakpoints
.
Disabled breakpoints are indicated by a grey stop sign, or _
Illegal HTML tag removed : n_
, where Illegal HTML tag removed : n is the breakpoint number.
The Disable Breakpoint
item is also accessible via the Clear
button. Just press and hold mouse button 1 on the button to get a popup menu.
Node:Temporary Breakpoints, Next:Editing Breakpoint Properties, Previous:Disabling Breakpoints, Up:Breakpoints
Temporary Breakpoints
A Illegal HTML tag removed : temporary breakpoint is immediately deleted as soon as it is reached.13
To set a temporary breakpoint, press mouse button 3 on the left of the source line and select the Set Temporary Breakpoint
item from the popup menu.
As a faster alternative, you can simply double-click on the left of the source line while holding <Ctrl>.
Temporary breakpoints are convenient to make the program continue up to a specific location: just set the temporary breakpoint at this location and continue execution.
The Continue Until Here
item from the popup menu sets a temporary breakpoint on the left of the source line and immediately continues execution. Execution stops when the temporary breakpoint is reached.
The Set Temporary Breakpoint
and Continue Until Here
items are also accessible via the Break
button. Just press and hold mouse button 1 on the button to get a popup menu.
Node:Editing Breakpoint Properties, Next:Breakpoint Conditions, Previous:Temporary Breakpoints, Up:Breakpoints
Editing Breakpoint Properties
You can change all properties of a breakpoint by pressing mouse button 3 on the breakpoint symbol and select Properties
from the breakpoint popup menu. This will pop up a dialog showing the current properties of the selected breakpoint.
As an even faster alternative, you can simply double-click on the breakpoint.
- Click on
Lookup
to move the cursor to the breakpoint's location. - Click on
Enable
to enable the breakpoint. - Click on
Disable
to disable the breakpoint. - Click on
Temp
to make the breakpoint temporary.14 - Click on
Delete
to delete the breakpoint.
Node:Breakpoint Conditions, Next:Breakpoint Ignore Counts, Previous:Editing Breakpoint Properties, Up:Breakpoints
Breakpoint Conditions
The simplest sort of breakpoint breaks every time your program reaches a specified place. You can also specify a Illegal HTML tag removed : condition for a breakpoint. A condition is just a Boolean expression in your programming language. A breakpoint with a condition evaluates the expression each time your program reaches it, and your program stops only if the condition is true.
This is the converse of using assertions for program validation; in that situation, you want to stop when the assertion is violated-that is, when the condition is false. In C, if you want to test an assertion expressed by the condition Illegal HTML tag removed : assertion, you should set the condition !
Illegal HTML tag removed : assertion on the appropriate breakpoint.
Break conditions can have side effects, and may even call functions in your program. This can be useful, for example, to activate functions that log program progress, or to use your own print functions to format special data structures. The effects are completely predictable unless there is another enabled breakpoint at the same address. (In that case, DDD might see the other breakpoint first and stop your program without checking the condition of this one.)
Note that breakpoint commands are usually more convenient and flexible for the purpose of performing side effects when a breakpoint is reached. See Breakpoint Commands, for details.
Node:Breakpoint Ignore Counts, Next:Breakpoint Commands, Previous:Breakpoint Conditions, Up:Breakpoints
Breakpoint Ignore Counts
A special case of a breakpoint condition is to stop only when the breakpoint has been reached a certain number of times. This is so useful that there is a special way to do it, using the Illegal HTML tag removed : ignore count of the breakpoint. Every breakpoint has an ignore count, which is an integer. Most of the time, the ignore count is zero, and therefore has no effect. But if your program reaches a breakpoint whose ignore count is positive, then instead of stopping, it just decrements the ignore count by one and continues. As a result, if the ignore count value is Illegal HTML tag removed : n, the breakpoint does not stop the next Illegal HTML tag removed : n times your program reaches it.
In the field Ignore Count
of the Breakpoint Properties
panel, you can specify the breakpoint ignore count.15
If a breakpoint has a positive ignore count and a condition, the condition is not checked. Once the ignore count reaches zero, DDD resumes checking the condition.
Node:Breakpoint Commands, Next:Moving and Copying Breakpoints, Previous:Breakpoint Ignore Counts, Up:Breakpoints
Breakpoint Commands
You can give any breakpoint (or watchpoint) a series of DDD commands to execute when your program stops due to that breakpoint. For example, you might want to print the values of certain expressions, or enable other breakpoints.16
Using the Commands
buttons of the Breakpoint Properties
panel, you can edit commands to be executed when the breakpoint is hit.
To edit breakpoint commands, click on Edit >>
and enter the commands in the commands editor. When done with editing, click on Edit <<
to close the commands editor.
Using GDB, you can also Illegal HTML tag removed : record a command sequence to be executed. To record a command sequence, follow these steps:
- Click on
Record
to begin the recording of the breakpoint commands. - Now interact with DDD. While recording, DDD does not execute commands, but simply records them to be executed when the breakpoint is hit. The recorded debugger commands are shown in the debugger console.
To stop the recording, click on
End
or enterend
at the GDB prompt. ToIllegal HTML tag removed : cancel
the recording, click on
Interrupt
or press <ESC>.- You can edit the breakpoint commands just recorded using
Edit >>
.
Node:Moving and Copying Breakpoints, Next:Looking up Breakpoints, Previous:Breakpoint Commands, Up:Breakpoints
Moving and Copying Breakpoints
To move a breakpoint to a different location, press mouse button 1 on the stop sign and drag it to the desired location.17 This is equivalent to deleting the breakpoint at the old location and setting a breakpoint at the new location. The new breakpoint inherits all properties of the old breakpoint, except the breakpoint number.
To copy a breakpoint to a new location, press <Shift> while dragging.
Node:Looking up Breakpoints, Next:Editing all Breakpoints, Previous:Moving and Copying Breakpoints, Up:Breakpoints
Looking up Breakpoints
If you wish to lookup a specific breakpoint, select Source => Breakpoints => Lookup
. After selecting a breakpoint from the list and clicking the Lookup
button, the breakpoint location is displayed.
As an alternative, you can enter #
Illegal HTML tag removed : n in the argument field, where Illegal HTML tag removed : n is the breakpoint number, and click on the Lookup
button to find its definition.
Node:Editing all Breakpoints, Next:Hardware-Assisted Breakpoints, Previous:Looking up Breakpoints, Up:Breakpoints
Editing all Breakpoints
To view and edit all breakpoints at once, select Source => Breakpoints
. This will popup the Illegal HTML tag removed : Breakpoint Editor which displays the state of all breakpoints.
In the breakpoint editor, you can select individual breakpoints by clicking on them. Pressing <Ctrl> while clicking toggles the selection. To edit the properties of all selected breakpoints, click on Props
.
Node:Hardware-Assisted Breakpoints, Previous:Editing all Breakpoints, Up:Breakpoints
Hardware-Assisted Breakpoints
Using GDB, a few more commands related to breakpoints can be invoked through the debugger console:
hbreak
Illegal HTML tag removed : position
Sets a hardware-assisted breakpoint at
Illegal HTML tag removed : position
. This command requires hardware support and some target hardware may not have this support. The main purpose of this is EPROM/ROM code debugging, so you can set a breakpoint at an instruction without changing the instruction.
thbreak
Illegal HTML tag removed : pos
Set a temporary hardware-assisted breakpoint at
Illegal HTML tag removed : pos
.
See Setting breakpoints, for details.
Node:Watchpoints, Next:Interrupting, Previous:Breakpoints, Up:Stopping