Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to filter call stack in Eclipse debug view for Java

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
like image 596
espinchi Avatar asked Oct 21 '10 14:10

espinchi


People also ask

How can I see stacks in Eclipse?

you just click on the stack frame in the Debug view. Show activity on this post. In the visual debugger, you will see the entire stack trace. Just CLICK on the level you want to inspect to do that.

How do I filter in Eclipse?

To enable the step filtering feature, mark the 'Use Step Filters' checkbox and the add the required resources to the 'Defined step filters' list. Note: The Step Filters functionality can be toggled on/off during debugging by clicking the Use Step Filters button on the Debug view toolbar.

How do I view debug logs in Eclipse?

In your Eclipse development interface, select Window > Preferences. This mode displays verbose debug logs so you can view them in the Eclipse console window while you are previewing the app.

How do I run Java in debug mode in Eclipse?

To debug your application, select a Java file with a main method. Right-click on it and select Debug As Java Application. If you started an application once via the context menu, you can use the created launch configuration again via the Debug button in the Eclipse toolbar.


1 Answers

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.

like image 105
kriegaex Avatar answered Oct 02 '22 21:10

kriegaex