如何在C++中由许多文件组成的程序中设置gdb观察点?

发布于 2024-08-20 22:23:20 字数 313 浏览 3 评论 0原文

我正在尝试设置一个观察点来监视由许多 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一袭水袖舞倾城 2024-08-27 22:23:20

我总是在函数中设置一个断点,然后在遇到它时设置观察点,以便我处于上下文中,然后根据需要删除断点。

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.

心凉怎暖 2024-08-27 22:23:20

您想设置条件断点吗?如果那么你可以使用下面的命令。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文