views:

795

answers:

2

An everyday debugging situation for Java developers is that in which an Exception is thrown and then you need to dig into the debugger to find out what threw it. Usually you would try to set up some breakpoints before the exception is thrown and hope that you are able to determine the situation that leads up to that exception.

In Eclipse, a breakpoint may have an expression defined where it is only triggered when, for example, variable x equals value y. My question is, is it possible to define some kind of global expression where, once an exception is thrown, it is caught by the debugger, allowing the programmer to inspect all variables immediately? Ideally you would not have hit the catch block yet, Eclipse would catch the exception being raised and stop execution without changing the stack contents.

Is this possible or is it limited by the JVM?

+3  A: 

http://agile.csc.ncsu.edu/SEMaterials/tutorials/eclipse-debugger/

Specifically the "5.0 Special Breakpoints and Watching Expressions" portion.

TofuBeer
+11  A: 
VonC
Because I couldn't find the "J!" button until I asked my officemate: it's in the Breakpoints view. Obvious in hindsight, I know, but someone else might have the same problem.
Samir Talwar
@Samir: good point. I have added the explicit reference to that "Breakpoint view" (and a link to the official eclipse help about this view)
VonC