如何在C++中由许多文件组成的程序中设置gdb观察点?
我正在尝试设置一个观察点来监视由许多 C++ 文件组成的包中的变量。
有很多文件
abc.cpp qwe.cpp .. xyz.cpp 等
我想监视文件 abc.cpp 中某些函数 qwerty() 中的变量“temp” 如何设置观察点?
我尝试
观看 abc.cpp::temp 观看 abc.cpp:temp 观看 temp
但我看到错误没有符号 'abc.cpp::temp','abc.cpp:temp','temp' 不在当前上下文中 信息观察点还告诉我没有设置观察点。请注意,我可以为同一变量成功设置断点
I am trying to set up a watchpoint to monitor a variable in a package consisting of many C++ files.
There are many files
abc.cpp
qwe.cpp
..
xyz.cpp and so on
I want to monitor a variable 'temp' in some function qwerty() in the file abc.cpp
How do I set the watchpoint ?
I tried
watch abc.cpp::temp
watch abc.cpp:temp
watch temp
but I see the errors No symbols 'abc.cpp::temp','abc.cpp:temp','temp' not in current context
Also a info watchpoints tells me that no watchpoints are set. Note that I can set the breakpoints successfully for the same variable
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我总是在函数中设置一个断点,然后在遇到它时设置观察点,以便我处于上下文中,然后根据需要删除断点。
I always set a breakpoint in the function, then set the watchpoint when I hit it, so that I'm in the context, then delete the breakpoint as appropriate.
您想设置条件断点吗?如果那么你可以使用下面的命令。
(gdb) 中断 abc::qwerty()
(gdb) 条件 1 temp=1 // 如果要在 temp 的值 = 1 时中断。
Do you want to make conditional breakpoints? If then you can use the commands below.
(gdb) break abc::qwerty()
(gdb) condition 1 temp=1 // If you want to break when the value of temp = 1.