Execute to Line in GDB
Asked Answered
P

2

14

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?

Paderewski answered 2/5, 2013 at 9:25 Comment(0)
R
31

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

Rata answered 2/5, 2013 at 10:16 Comment(2)
Thanks a lot! I found that u is a nice shortcut for this.Paderewski
You have massively increased my productivity.Confederate
B
4

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.
Becalm answered 2/5, 2013 at 9:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.