简体   繁体   English

是否有可能在Eclipse中定义一组断点并且只在给定事件发生后触发它们?

[英]Is it possible in Eclipse to define a set of breakpoints and only have them fire after a given event happens?

I'd like to set a set of breakpoints in a couple of tight loops.. but I just want them to fire after a given event occurs. 我想在几个紧密循环中设置一组断点..但我只是希望它们在给定事件发生后触发。

The problem lies in the fact that all those breakpoints are defined in a very low level module, so they can't know when that high level event is raised. 问题在于所有这些断点都是在非常低级别的模块中定义的,因此他们无法知道何时引发高级别事件。

It'd be perfect if I could set a special conditional breakpoint in the high level code, such that after that breakpoint condition was met it would, from that moment on, start firing any other breakpoints found in the program (I don't particularly care for that high level breakpoint, though). 如果我可以在高级代码中设置一个特殊的条件断点,那将是完美的,这样在满足断点条件后,从那一刻起,它将开始触发程序中找到的任何其他断点(我不特别但是,关心那个高级断点。

Is there any way to accomplish something like this? 有没有办法完成这样的事情? If not, how to circumvent this limitation? 如果没有,如何规避这个限制? The only way that comes to mind would be to define a temporary singleton to keep state and have my low level breakpoints depend on that singleton's flag. 想到的唯一方法是定义一个临时单例以保持状态,并让我的低级断点依赖于该单例的标志。

If you right click on breakpoint properties you will see plenty of options 如果右键单击breakpoint properties您将看到许多选项

断点属性

You can make creative use of assertions, but they are disabled in Eclipse by default. 您可以创造性地使用断言,但默认情况下它们在Eclipse中被禁用。

Here's a good link explaining how to enable assertions: http://www.cis.upenn.edu/~matuszek/cit594-2004/Pages/eclipse-faq.html#assert 这是一个解释如何启用断言的好链接: http//www.cis.upenn.edu/~matuszek/cit594-2004/Pages/eclipse-faq.html#assert

And here's more info on how to use them for your purposes: http://eclipse.dzone.com/articles/using-java-assertions-use 以下是有关如何将它们用于您的目的的更多信息: http//eclipse.dzone.com/articles/using-java-assertions-use

From the article: 来自文章:

Eclipse has a very useful mechanism for breaking on Exceptions. Eclipse有一个非常有用的机制来打破异常。 It's a different kind of breakpoint, which is triggered when the exception is thrown, regardless of how (and if) it is caught. 它是一种不同类型的断点,它在抛出异常时触发,无论它是如何(以及如果)被捕获的。 If you are using assertions, I highly recommend setting a breakpoint on assertion failures when debugging your code. 如果您正在使用断言,我强烈建议在调试代码时在断言失败时设置断点。

You're asking several different questions here. 你在这里问几个不同的问题。

In answer to "Q: can I set a breakpoint that triggers when some event occurs", you might want to look at "watch points": 回答“问:我可以设置一个事件发生时触发的断点”,你可能想看一下“观察点”:

http://www.vogella.de/articles/EclipseDebugging/article.html http://www.vogella.de/articles/EclipseDebugging/article.html

The same article discusses a possible answer to another of your questions: "Q: ... after that breakpoint condition was met it would, from that moment on, start firing other breakpoints..." 同一篇文章讨论了另一个问题的可能答案:“问:......在满足断点条件后,从那一刻开始,就会开始解雇其他断点......”

Look for "breakpoint properties", in the same article. 在同一篇文章中查找“断点属性”。

'Hope that helps! '希望有所帮助!

PS: Here's one other short - but very good - article: PS:这是另一篇简短但非常好的文章:

http://www.ibm.com/developerworks/library/os-ecbug/ http://www.ibm.com/developerworks/library/os-ecbug/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Eclipse +断点=没有任何反应 - Eclipse + breakpoints = nothing happens AMQP异步侦听器仅在事件发生后才开始侦听消息 - AMQP async listener starts listening to message only after an event happens 是否可以在Eclipse中链接条件断点和剪贴簿? - Is it possible to link conditional breakpoints and scrapbook in Eclipse? 如何在 Eclipse 中设置实例断点? - How do you set Instance Breakpoints in Eclipse? 使用Eclipse进行远程调试 - 如何设置断点? - Remote debugging using Eclipse - How to set breakpoints? 是否可以在特定的字节码指令上设置断点? - Is it possible to set breakpoints at a specific bytecode instruction? java eclipse windowbuilder keyPressed事件不会触发 - java eclipse windowbuilder keyPressed event does not fire 仅当鼠标悬停在元素上至少一段特定时间时,如何触发MouseMove事件? - How to have a MouseMove event fire only if the mouse is hovered over an element for at least a specific amount of time? Eclipse - 调试器不会在 xTend 代码断点处停止,但可以在 java 代码断点处停止 - Eclipse - debugger doesn't stop at xTend code breakpoints, but possible to java code breakpoints 如何仅在按Enter或更改JcomboBox中的选定项目后才触发事件 - How to fire event only after press enter or changing selected item in JcomboBox
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM