如何在 Eclipse 调试视图中过滤 Java 的调用堆栈
调试时,Eclipse 中的“调试”视图显示调用堆栈。这太棒了。但我希望能够过滤掉所有我绝对不关心的调用,例如 Spring 和 JUnit 运行程序。
这是我现在的调用堆栈的示例。我想将条目保留为粗体,同时隐藏所有其余条目。有可能以任何方式做吗? (插件、下一个 Eclipse 版本、配置……)
com.myproject.mymodule.MyFinderObject.fetchDestinationSettings
com.myproject.mymodule.MyFinderObject.compareCurrentSettings
com.myproject.mymodule.MyFinderObject.compareSettings
sun.reflect.NativeMethodAccessorImpl.invoke0
sun.reflect.NativeMethodAccessorImpl.invoke
sun.reflect.DelegatingMethodAccessorImpl.invoke
java.lang.reflect.Method.invoke
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
com.myproject.caching.CachingInterceptor.invoke
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
org.springframework.aop.framework.JdkDynamicAopProxy.invoke
$Proxy43.doSthWith
com.myproject.mymodule.MyFinderObjectTest.testSettingComparisonForCurrentSettings
sun.reflect.NativeMethodAccessorImpl.invoke0
sun.reflect.NativeMethodAccessorImpl.invoke
sun.reflect.DelegatingMethodAccessorImpl.invoke
java.lang.reflect.Method.invoke
com.myproject.mymodule.MyFinderObjectTest
com.myproject.mymodule.MyFinderObjectTest
com.myproject.mymodule.MyFinderObjectTest
junit.framework.TestResult$1.protect
junit.framework.TestResult.runProtected
junit.framework.TestResult.run
com.myproject.mymodule.MyFinderObjectTest
junit.framework.TestSuite.runTest
junit.framework.TestSuite.run
org.junit.internal.runners.JUnit38ClassRunner.run
org.eclipse.jdt.internal.junit4.runner.JUnit4TestMethodReference
org.eclipse.jdt.internal.junit.runner.TestExecution.run
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main
While debugging, the Debug view in Eclipse shows the call stack. Which is great. But I'd love to be able to filter out all the call that I definitely don't care about, such as Spring and the JUnit runner.
Here's an example of my call stack right now. I'd like to keep the entries in bold, while hiding all the rest. Is it possible to do in any way? (plugin, next Eclipse release, configuration, ...)
com.myproject.mymodule.MyFinderObject.fetchDestinationSettings
com.myproject.mymodule.MyFinderObject.compareCurrentSettings
com.myproject.mymodule.MyFinderObject.compareSettings
sun.reflect.NativeMethodAccessorImpl.invoke0
sun.reflect.NativeMethodAccessorImpl.invoke
sun.reflect.DelegatingMethodAccessorImpl.invoke
java.lang.reflect.Method.invoke
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
com.myproject.caching.CachingInterceptor.invoke
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
org.springframework.aop.framework.JdkDynamicAopProxy.invoke
$Proxy43.doSthWith
com.myproject.mymodule.MyFinderObjectTest.testSettingComparisonForCurrentSettings
sun.reflect.NativeMethodAccessorImpl.invoke0
sun.reflect.NativeMethodAccessorImpl.invoke
sun.reflect.DelegatingMethodAccessorImpl.invoke
java.lang.reflect.Method.invoke
com.myproject.mymodule.MyFinderObjectTest
com.myproject.mymodule.MyFinderObjectTest
com.myproject.mymodule.MyFinderObjectTest
junit.framework.TestResult$1.protect
junit.framework.TestResult.runProtected
junit.framework.TestResult.run
com.myproject.mymodule.MyFinderObjectTest
junit.framework.TestSuite.runTest
junit.framework.TestSuite.run
org.junit.internal.runners.JUnit38ClassRunner.run
org.eclipse.jdt.internal.junit4.runner.JUnit4TestMethodReference
org.eclipse.jdt.internal.junit.runner.TestExecution.run
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
准备工作:您可以使用步骤过滤器,如此处< /a>.然后,每当您对代码进行单步调试时,它都不会跳转到排除的包或类,例如来自 JDK 或 Hibernate 或 Spring 等框架的包或类。但这只是一个先决条件。
解决方案:堆栈跟踪仍然包含来自这些包的帧。为了过滤掉这些,您需要修补 Eclipse JDT 调试 UI 插件。 其他人已经为较旧的 Eclipse 版本(直至 Indigo)做到了这一点。因为我很好奇是否也可以在当前版本的 Luna 4.4.1 中运行它,所以我重新创建了其他人的更改并推送了 调试视图 + 堆栈过滤器插件到 GitHub,包括已修补插件的下载链接。因此,如果您也在使用 4.4.1,那么您很幸运,不需要自己修补和编译任何内容。就用我的版本吧。否则,请克隆我的存储库并查看更改,然后将它们应用到您选择的插件版本。
Preparation: You can use step filters as described here. Then whenever you step-debug through your code, it will not jump into excluded packages or classes, e.g. from the JDK or some frameworks like Hibernate or Spring. But this is just a prerequisite.
Solution: The stacktrace still contains frames from those those packages. In order to filter out those as well, you need to patch the Eclipse JDT Debug UI plugin. Someone else has done that already for older Eclipse releases up to Indigo. Because I was curious if I could get it running in the current release Luna 4.4.1 as well, I recreated the other guy's changes and pushed the Debug View + Stack Filter Plug-In to GitHub including a download link to the patched plugin. So if you are also on 4.4.1, you are lucky and do not need to patch and compile anything by yourself. Just use my version. Otherwise please clone my repo and look at the changes, then apply them to the plugin version of your choice.
据我所知,过滤堆栈跟踪视图的唯一方法是通过 Mylyn。如果您有一个活动的 Mylyn 任务,并且单击“调试视图”中的“关注活动任务(实验)”按钮,则堆栈跟踪将被过滤,仅显示当前任务上下文中的那些方法。
在这种情况下,您不会从堆栈跟踪中过滤某些项目;相反,默认情况下所有内容都会显示出来,并且只会显示某些项目(任务上下文中的项目)。
你可以看看这个 回答有关 Mylyn 的更多信息。
The only way I know of to filter the stack trace view is via Mylyn. If you have an active Mylyn task, and you click the "Focus on Active Task (experimental)" button in the Debug View, then the stack trace will be filtered to only show those methods that are in the current task's context.
In this case, you wouldn't be filtering certain items from the stack trace; rather, everything would be out by default, and only certain items would be displayed (those in the task context).
You can look at this answer for more about Mylyn.