gdb问题设置硬件观察点/如何设置软件观察点 [英] gdb problem setting hardware watchpoint/how to set software watchpoint

查看:830
本文介绍了gdb问题设置硬件观察点/如何设置软件观察点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

前面的问题解释说,在x86上,被监视对象的大小受调试寄存器的限制。 此处如预期,我可以看一个双变量。但我不能观看双数据成员,例如

 观看pObject-> dPrice 

产生

 硬件观察点1:pObject - > dPrice 

但是当您尝试继续执行时,表示

 无法插入硬件断点:$ b​​ $ b您可能请求了太多的硬件断点/观察点。 

即使这只是断点/观察点。

我很好奇为什么会这样,但更重要的是有办法吗?根据gdb docs它可以使用软件观察点,如果它不能使用硬件。

解决方案

在这种情况下,它不会尝试使用软件观察点 - 可以:


设置can-use-hw-watchpoints 0


5.1.2设置观察点


您可以使用set can-use-hw-watchpoints 0命令强制gdb仅使用软件观察点。将此变量设置为零,gdb将永远不会尝试使用硬件观察点,即使底层系统支持它们。 (请注意,在将can-use-hw-watchpoint设置为零之前设置的硬件辅助观察点仍将使用观察表达式值的硬件机制。)


set can-use-hw-watchpoints



    设置是否使用硬件观察点。



show can-use-hw-watchpoints



    显示当前使用硬件观察点的模式。


An earlier question explained that on x86 the size of objects being watched is limited by debug registers. here. As expected, I can "watch" a double variable. But I can't watch a double datamember, eg

watch pObject->dPrice

produces

Hardware watchpoint 1: pObject->dPrice

But when you try to continue execution, it says

Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.

even though this is the only breakpoint/watchpoint.

I'm curious why this is so, but more importantly is there a way around it? According to gdb docs it may use software watchpoints if it can't use hardware. In this case it makes no attempt to use a software watchpoint -- is there a way to force it to do so?

解决方案

Yes you can:

set can-use-hw-watchpoints 0

From 5.1.2 Setting Watchpoints:

You can force gdb to use only software watchpoints with the set can-use-hw-watchpoints 0 command. With this variable set to zero, gdb will never try to use hardware watchpoints, even if the underlying system supports them. (Note that hardware-assisted watchpoints that were set before setting can-use-hw-watchpoints to zero will still use the hardware mechanism of watching expression values.)

set can-use-hw-watchpoints

    Set whether or not to use hardware watchpoints.

show can-use-hw-watchpoints

    Show the current mode of using hardware watchpoints.

这篇关于gdb问题设置硬件观察点/如何设置软件观察点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆