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

时间:2022-12-03 22:09:25

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.

有没有办法完成这样的事情?如果没有,如何规避这种限制?想到的唯一方法是定义一个临时单例以保持状态,并让我的低级别断点依赖于该单例的标志。

3 个解决方案

#1


1  

If you right click on breakpoint properties you will see plenty of options

如果右键单击断点属性,您将看到许多选项

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

#2


0  

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

Eclipse有一个非常有用的机制来打破异常。它是一种不同类型的断点,它在抛出异常时触发,无论它是如何(以及如果)被捕获的。如果您正在使用断言,我强烈建议在调试代码时在断言失败时设置断点。

#3


0  

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/

#1


1  

If you right click on breakpoint properties you will see plenty of options

如果右键单击断点属性,您将看到许多选项

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

#2


0  

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

Eclipse有一个非常有用的机制来打破异常。它是一种不同类型的断点,它在抛出异常时触发,无论它是如何(以及如果)被捕获的。如果您正在使用断言,我强烈建议在调试代码时在断言失败时设置断点。

#3


0  

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/