How to filter call stack in Eclipse debug view for

2020-01-29 04:46发布

问题:

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

回答1:

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.



回答2:

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.