On Feb 9, 7:09 pm, Bob Kerns <[email protected]> wrote:
> You may not be seeing what you want because you stop too soon, before
> it's really created the exception.

The debugger stops at the point of the throw.  There is no exception
variable to examine because there's no exception variable in the
source code for the debugger to refer to.

The exception object is passed to the debugger when the "exception
happened" event is sent up, so it's free to display it however it
chooses to.  I expect different debuggers deal with this in different
ways, but so long as they're using JDWP to talk to the VM they all get
the same set of information.

(FWIW, you can connect any debugger you like through DDMS.  It's
probably easiest to make sure there's only one person talking to the
VM at a time if you close Eclipse and use the stand-alone "ddms"
command.  I've used "jdb", IntelliJ IDEA, and a couple others.)

> I didn't paste it into this message, but I did look at what was in the
> exception, I just clicked on the little triangle to expand. It showed
> the message ("Divide by zero"), and also showed that the stacktrace
> field hadn't been filled in yet (which I expected).

The stack trace elements are populated on demand.  Since most
exceptions are never displayed, it's inefficient to go through the
trouble of formatting a nice stack trace.  There's an array of int[]
hiding in there that has the actual info.

> But, I do spot one anomaly here: I have it set to break on
> RuntimeException. ArithmeticException is a RuntimeException, but it
> didn't break. It didn't break until it tried to rethrow it, further up
> the stack.

Make sure you're trapping both caught and uncaught exceptions.  An
exception is considered "caught" if there's a "finally" block anywhere
below it, and there are dx-generated "finally" blocks in all
synchronized methods.  You end up breaking on a lot of stuff you don't
care about, but sometimes it's the only way to really catch the
exception.

Some notes about the debugger can be found in the source tree in
dalvik/docs/debugger.html
  
http://android.git.kernel.org/?p=platform/dalvik.git;a=blob_plain;f=docs/debugger.html;hb=HEAD

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to