12

I can execute up to a specific line in GDB by placing a breakpoint there and then pressing c to continue execution.

b <line_number> ; insert breakpoint
c ; run up to the breakpoint
del <breakpoint_number> ; remove breakpoint

Is there a command to run up to a specific line number that will avoid having to run the above sequence of commands?

2 Answers2

27

Still easier is the "until" command, which automatically generates a temporary breakpoint and continues until its location.

Martin
  • 1,261
  • 7
  • 11
3

You can use temporary breakpoint instead of regular breakpoint. This will eliminate step 3 in your command sequence:

(gdb) tbreak <line_number>
(gdb) continue

Temporary breakpoint is like regular one except it will be deleted when hit:

(gdb) help tbreak 
Set a temporary breakpoint.
Like "break" except the breakpoint is only temporary,
so it will be deleted when hit.  Equivalent to "break" followed
by using "enable delete" on the breakpoint number.
ks1322
  • 33,961
  • 14
  • 109
  • 164