Eclipse Tips: (Debugging) Ignoring certain classes from being stepped into

Some of us may have encountered a not so nice experience where you basically got an strange result from a method and decide to step into that method as deep as possible. The problem is somehow you are lost in track and you can’t debug furthermore except if you’re exiting the debug mode or resuming the debug. Both are not the best solution because you have to inspect the application one more time.

The symptom of the problem is usually you a “Source not found” on your editor. If you are trying to ‘Step Return’ you are basically lost in track because you can not return to a class with source code.

For testing, you may try to write a log, for example:

logger.info("whatever");

If you’re trying to step into this method, you may get (since this obviously depends on your Eclipse configuration, you may also not get this screenshot):

2009-08-24_1210

Now try to ‘Step Return’ several times… do you still get the ‘Source not found’ message?

Why?

It’s actually easy to understand if you look at the debug view.
2009-08-24_1215

You are basically step into a long method calls, which most of them doesn’t have line information. Eclipse will automatically ignore these methods when you are stepping into. But then suddenly, it touched a method equals from class ‘Class’ which does have line information, but no source attached for it.

So, if you are patient enough, you can just do ‘Step Return’ several times (in this case about 16 times) and you’ll return to your class (with nice source code 🙂 ). This is obviously too much work.

One other alternative is to ignore certain classes to be stepped into. In Eclipse, the name of the functionality is called ‘Step Filters’. To use this functionality to ignore JDK classes, you have to configure Eclipse.

Go to the Preferences dialog, and open Java → Debug → Step Filtering.

2009-08-24_1227

Just ‘Select All’ and click ‘OK’. Now… If you are still trapped in the equals method, you can simply ‘Step Return’ and you’ll be back to your source code.

Once you’ve set the configuration in the Preferences, you can enable and disable this Step Filters anytime from your Debug perspective by clicking this button on Debug view.

2009-08-24_1230

Now… there is no reason to redo your entire debug session if you’re trapped in such situation.

Happy debugging!

Leave a Reply

Your email address will not be published. Required fields are marked *