计算断点命中 [英] Counting breakpoint hits

查看:68
本文介绍了计算断点命中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于这个问题已经3年多了,我想我会带再来一次尤其是因为提供的解决方案对我来说不是一个真正的选择。

As this question is over 3 years old, I figured I'd bring it up again. Especially since the solution offered there isn't a real option for me.

我正在寻找一种方法来计算Eclipse调试器中特定断点的通过次数,而实际上没有暂停代码。我需要这样做是因为我正在处理的问题仅在每秒发送数千条消息时才会显现出来。

I'm looking for a way to count passes over a particular breakpoint in the eclipse debugger without actually suspending the code. I need to do this because the issue I'm working on manifests itself only when thousands of messages are sent per second.

上面提供的解决方案对我而言并不切实可行,因为要调试的代码位于远程位置,所以我无法真正创建静态类来跟踪匹配。

The solution offered above is not really feasible for me, as the code being debugged is in a remote location and I cannot really create the static class to track hits. Is there either a default feature or a plugin that will simply count breakpoint hits, or is it not possible in eclipse?

推荐答案

实际上是不是有一个默认功能或一个插件可以简单地计算断点命中率?在上述问题中,使用另一个类的唯一原因是拥有一个专用的静态变量,您可以从断点代码段访问该变量。您可以使用对代码段可见的任何其他静态变量/方法。

Actually in said question the only reason to use another class is to have a dedicated static variable that you can access from the breakpoint snippet. You can use any other static variable/method that is visble to the snippet.

例如:

int a = System.getProperty("my-prop");
System.setProperty("my-prop", ++a);

这可能很慢,因此您可以尝试使用 ThreadLocal s或找到一个自己的静态变量(最好是一个跟踪许多地方的地图),您可以为此目的进行劫持。

That might be slow, so you could try with ThreadLocals or find youself a static var (or preferably a map to track many places) that you can hijack for this purpose.

这篇关于计算断点命中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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