Ade YU
Ade YU

Reputation: 2362

Is there an "until" command in gdb?

Say that I'm in line 20, and I want the program to continue and stop at line 40, 60 and 80.

Is there some command functions like until 40, until 60 and until 80?

There are loops in the code, so n 20 doesn't fit here.

Upvotes: 16

Views: 20934

Answers (2)

Michael F
Michael F

Reputation: 40859

Emphasis mine:

gdb$ help break
Set breakpoint at specified **line** or function.
break [PROBE_MODIFIER] [LOCATION] [thread THREADNUM] [if CONDITION]
PROBE_MODIFIER shall be present if the command is to be placed in a
probe point.  Accepted values are `-probe' (for a generic, automatically
guessed probe type) or `-probe-stap' (for a SystemTap probe).
**LOCATION may be a line number, function name, or "*" and an address.**
If a line number is specified, break at start of code for that line.
If a function is specified, break at start of code for that function.
If an address is specified, break at that exact address.
With no LOCATION, uses current execution address of the selected
stack frame.  This is useful for breaking on return to a stack frame.

THREADNUM is the number from "info threads".
CONDITION is a boolean expression.

Multiple breakpoints at one place are permitted, and useful if their
conditions are different.

Do "help breakpoints" for info on other commands dealing with breakpoints.

Additionally, until location can also be used but it also stops your program when it returns from the current stack frame.

Upvotes: 3

dbrank0
dbrank0

Reputation: 9476

In addition to Michael's explanation of breakpoints, that are probably the best way to solve your problem, there are actually also are "until" and "advance" commands, that do just what you require/suggest.

Basically you can do "until 60" or "until main.c:60" or "advance 60" or similar, depending if you want to limit temporary breakpoint to current frame or not.

See appropriate section of GDB manual.

Upvotes: 19

Related Questions