gdb中是否有“until”命令?

13

假设我在第20行,希望程序在第40、60和80行停止。

是否有像until 40until 60until 80这样的命令函数?

代码中有循环,因此n 20不适用于此处。

2个回答

15

除了 Michael 对断点的解释,那可能是解决您问题的最佳方法之外,实际上还有“until”和“advance”命令,可以正好实现您所需/建议的功能。

基本上,您可以执行“until 60”或“until main.c:60”或“advance 60”或类似操作,具体取决于您是否想将临时断点限制为当前帧。

请参见GDB手册中的相应部分


当断点不是最好的选择时,“until”很方便,可以帮助你跳过一个循环。 - x-yuri

3

我强调:

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.

此外,until location也可以使用,但它会在返回当前堆栈帧时停止您的程序。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接