Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an "until" command in gdb?

Tags:

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.

like image 418
Ade YU Avatar asked Oct 14 '14 07:10

Ade YU


2 Answers

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.

like image 68
dbrank0 Avatar answered Oct 04 '22 00:10

dbrank0


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.

like image 34
Michael Foukarakis Avatar answered Oct 04 '22 00:10

Michael Foukarakis