eclipse java/eclipse中的数据断点

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4086039/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 15:17:04  来源:igfitidea点击:

data breakpoints in java/eclipse

javaeclipsebreakpoints

提问by clamp

when developing C++ with VS you have this amazing feature of data breakpoints, which trigger when the data at a certain address in memory changes.

在用 VS 开发 C++ 时,你有一个惊人的数据断点特性,它在内存中某个地址的数据发生变化时触发。

is there a similar feature when developing java in eclipse?

在eclipse中开发java时有没有类似的功能?

thanks!

谢谢!

edit: about the "suspend when value changes" feature: i have the impression that the execution must still reach the line where the breakpoint is. the thing is i want it to trigger anywhere as soon as the value changes.

编辑:关于“值更改时暂停”功能:我的印象是执行仍必须到达断点所在的行。问题是我希望它在值改变时立即触发。

回答by user85421

You can set a watchpoint on a field: put the cursor at the line where the field is being declared and select the menu Run -> Toggle Watchpoint
or just set a breakpoint by double-clicking at the left margin on that line.

您可以在字段上设置观察点:将光标放在声明该字段的行上并选择菜单,Run -> Toggle Watchpoint
或者通过双击该行的左边距来设置断点。

You can change the properties of the watchpoint like suspend on field accessor suspend on field modificationafter adding it. Just right-click on the watchpoint at the left margin and select Breakpoint Properties...

您可以像添加它一样suspend on field accesssuspend on field modification在添加它之后更改观察点的属性。只需右键单击左边距的观察点并选择Breakpoint Properties...

Search the help for watchpoint to get more information:

搜索 watchpoint 的帮助以获取更多信息:

A watchpoint is a special breakpoint that stops the execution of an application whenever the value of a given expression changes, without specifying where it might occur. ...

观察点是一个特殊的断点,它在给定表达式的值发生变化时停止应用程序的执行,而不指定它可能发生的位置。...

回答by Francois Misiak

Using the Variable view:

使用变量视图:

  • right click the field and select "Toggle Watchpoint", and then
  • right click the same instance again and select "Instance breakpoints..." which allows you to restrict a specific breakpoint to a given instance.
  • 右键单击该字段并选择“切换观察点”,然后
  • 再次右键单击同一实例并选择“实例断点...”,这允许您将特定断点限制为给定实例。

Note that the performance is probably not as good as with a memory hardware breakpoint (like in VC++ for example).

请注意,性能可能不如内存硬件断点(例如在 VC++ 中)。

回答by Neil

Under breakpoint properties, you have the option of making it conditional and checking the radio button "Suspend when value changes".

在断点属性下,您可以选择将其设置为条件并选中“值更改时暂停”单选按钮。

回答by Sean Patrick Floyd

Right click on the Breakpoint and select Breakpoint properties.

右键单击断点并选择Breakpoint properties

In the opening screen, choose: Conditional -> Suspend when value changes

在打开的屏幕中,选择: Conditional -> Suspend when value changes

回答by Romain Linsolas

As far as I know, there is no such generic feature in Eclipse. However, you can give some conditions to an existing breakpoint:

据我所知,Eclipse 中没有这样的通用功能。但是,您可以为现有断点提供一些条件:

Add a breakpoint somewhere in your code. Then, in the "Breakpoint" view, right click on it, then choose "Breakpoint properties". In the panel, you can add a condition that must be verified to make the application stops on this breakpoint (for example if (foo > 0)).

在代码中的某处添加断点。然后,在“断点”视图中,右键单击它,然后选择“断点属性”。在面板中,您可以添加一个必须验证的条件才能使应用程序在此断点处停止(例如if (foo > 0))。

This is not exactly what you want, but I do not think Eclipse provides such feature.

这不完全是您想要的,但我不认为 Eclipse 提供这样的功能。

回答by stacker

The closest thing would be editing the breakpoint properties. You could add conditions to check for distinct values. Another way could be adding a breakpoint to the setter method.

最接近的是编辑断点属性。您可以添加条件来检查不同的值。另一种方法是向 setter 方法添加断点。

You can set the breakpoint properties by right-clicking on an already set breakpoint in the breakpoint view.

您可以通过右键单击断点视图中已设置的断点来设置断点属性。