next up previous

Points d'arręt conditionnels

The simplest sort of breakpoint breaks every time the program reaches a
specified place.  You can also specify a "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 the
program reaches it, and the program stops only if the condition is true.

Break conditions may have side effects, and may even call functions in your
program.  These may sound like strange things to do, but their effects are
completely predictable unless there is another enabled breakpoint at the
same address.  (In that case, GDB might see the other breakpoint first and
stop the 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
(*Note Break Commands::).

Break conditions can be specified when a breakpoint is set, by using
`if' in the arguments to the `break' command.  *Note Set Breaks::.
They can also be changed at any time with the `condition' command:

`condition BNUM EXPRESSION'     
     Specify EXPRESSION as the break condition for breakpoint number
     BNUM.  From now on, this breakpoint will stop the program only if
     the value of EXPRESSION is true (nonzero, in C).  EXPRESSION
     is not evaluated at the time the `condition' command is given.
`condition BNUM'     
     Remove the condition from breakpoint number BNUM.  It becomes
     an ordinary unconditional breakpoint.

A special feature is provided for one kind of condition: to prevent the
breakpoint from doing anything until it has been reached a certain number
of times.  This is done with the "ignore count" of the breakpoint.
When the program reaches a breakpoint whose ignore count is positive, then
instead of stopping, it just decrements the ignore count by one and

`ignore BNUM COUNT'     
     Set the ignore count of breakpoint number BNUM to COUNT.
     The next COUNT times the breakpoint is reached, it will not stop.
     To make the breakpoint stop the next time it is reached, specify
     a count of zero.
`cont COUNT'     
     Continue execution of the program, setting the ignore count of the
     breakpoint that the program stopped at to COUNT minus one.
     Continuing through the breakpoint does not itself count as one of
     COUNT.  Thus, the program will not stop at this breakpoint until the
     COUNT'th time it is hit.
     This command is allowed only when the program stopped due to a
     breakpoint.  At other times, the argument to `cont' is ignored.

If a breakpoint has a positive ignore count and a condition, the condition
is not checked.  Once the ignore count reaches zero, the condition will
start to be checked.

Note that you could achieve the effect of the ignore count with a condition
such as `$foo-- <= 0' using a debugger convenience variable that is
decremented each time.  That is why the ignore count is considered a
special case of a condition.  *Note Convenience Vars::.