是否有"直到"在gdb中命令?

时间:2014-10-14 07:58:06

标签: gdb

说我在第20行,我希望程序继续并停在第40,60和80行。

是否有一些命令功能,如until 40until 60until 80

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

2 个答案:

答案 0 :(得分:3)

除了迈克尔对断点的解释,这可能是解决问题的最佳方法,实际上还有“直到”和“前进”命令,这些命令就是你需要/建议的。

基本上你可以做“直到60”或“直到main.c:60”或“提前60”或类似的,这取决于你是否要将临时断点限制在当前帧。

请参阅appropriate section of GDB manual

答案 1 :(得分:1)

强调我的:

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,但它也会在从当前堆栈帧返回时停止程序。