Temporarily clear exception during ExceptionCaughtEvent.

If there are listeners for the exception caught event, the exception
needs to be cleared since Check JNI checks to make sure there aren't
any pending exceptions. This change clears the thread's exception,
then resets it after the event is sent.

Change-Id: Ib7b5b52dafd73ff41bbdf30b866a8e9e6cd085cc
diff --git a/src/instrumentation.cc b/src/instrumentation.cc
index 982af29..a8c2c73 100644
--- a/src/instrumentation.cc
+++ b/src/instrumentation.cc
@@ -438,11 +438,14 @@
                                            uint32_t catch_dex_pc,
                                            mirror::Throwable* exception_object) {
   if (have_exception_caught_listeners_) {
+    DCHECK_EQ(thread->GetException(NULL), exception_object);
+    thread->ClearException();
     typedef std::list<InstrumentationListener*>::const_iterator It; // TODO: C++0x auto
     for (It it = exception_caught_listeners_.begin(), end = exception_caught_listeners_.end();
         it != end; ++it) {
       (*it)->ExceptionCaught(thread, throw_location, catch_method, catch_dex_pc, exception_object);
     }
+    thread->SetException(throw_location, exception_object);
   }
 }