[英]GDB execute next instruction after watchpoint is hit
I have a function of the following form: 我具有以下形式的功能:
void foo(){
int *a = //...
*a = 1;
//some actions
*a = 2;
//some actions
*a = 3;
//some actions
//etc...
}
I want to set a watchpoint on a
, execute next instruction with si
, print registers and then continue until the watchpoint of a
is hit again and repeat that. 我想设置一个观察点上
a
,用下一个指令si
,打印寄存器,然后一直持续到观察点a
被再次命中和重复。
I wrote the following script: 我写了以下脚本:
b foo
watch *a
commands
si
info reg
cont
end
cont
The problem is it stops after the first watchpoint is hit and neither prints registers and nor continues execution. 问题在于它在第一个观察点被击中后停止,既不打印寄存器也不继续执行。 As I read in docs
正如我在文档中阅读的
Any other commands in the command list, after a command that resumes execution, are ignored.
在恢复执行的命令之后,命令列表中的任何其他命令将被忽略。 This is because any time you resume execution (even with a simple next or step), you may encounter another breakpoint—which could have its own command list, leading to ambiguities about which list to execute.
这是因为任何时候恢复执行(即使是简单的下一步或步骤),都可能会遇到另一个断点,该断点可能具有自己的命令列表,这导致要执行的列表含糊不清。
everything after si
is simply ignored. si
之后的所有内容都将被忽略。
Is there a way to write such a script ( gdb
or python
)? 有没有办法编写这样的脚本(
gdb
或python
)?
Before watch *a
you may run the program via run
. 在
watch *a
之前,您可以通过run
运行程序。
If not you'll get something like this: No symbol "a" in current context.
如果没有,您将得到如下信息:
No symbol "a" in current context.
So try this: 所以试试这个:
b foo
run
watch *a
commands
si
info reg
cont
end
cont
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.