简体   繁体   English

在GDB中执行行

[英]Execute to Line in GDB

I can execute up to a specific line in GDB by placing a breakpoint there and then pressing c to continue execution. 通过在GDB中放置一个断点,然后按c继续执行,可以执行GDB中的特定行。

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? 是否有命令可以运行到特定的行号,从而避免了必须运行上述命令序列?

“ until”命令更加容易,它会自动生成一个临时断点,并一直持续到其位置为止。

You can use temporary breakpoint instead of regular breakpoint. 您可以使用临时断点代替常规断点。 This will eliminate step 3 in your command sequence: 这将消除命令序列中的步骤3:

(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.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM