Handlerize throw location in DumpJavaStack

Handlerize this object and method during DumpJavaStack.
Bug: 17669899

Change-Id: I2e082137fe7f4c82257fc3b2fb36485a6981f369
diff --git a/runtime/thread.cc b/runtime/thread.cc
index 482ba26..45d799d 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -981,12 +981,18 @@
   // Dumping the Java stack involves the verifier for locks. The verifier operates under the
   // assumption that there is no exception pending on entry. Thus, stash any pending exception.
   // TODO: Find a way to avoid const_cast.
-  StackHandleScope<1> scope(const_cast<Thread*>(this));
+  StackHandleScope<3> scope(const_cast<Thread*>(this));
   Handle<mirror::Throwable> exc;
-  ThrowLocation exc_location;
+  Handle<mirror::Object> throw_location_this_object;
+  Handle<mirror::ArtMethod> throw_location_method;
+  uint32_t throw_location_dex_pc;
   bool have_exception = false;
   if (IsExceptionPending()) {
+    ThrowLocation exc_location;
     exc = scope.NewHandle(GetException(&exc_location));
+    throw_location_this_object = scope.NewHandle(exc_location.GetThis());
+    throw_location_method = scope.NewHandle(exc_location.GetMethod());
+    throw_location_dex_pc = exc_location.GetDexPc();
     const_cast<Thread*>(this)->ClearException();
     have_exception = true;
   }
@@ -997,6 +1003,9 @@
   dumper.WalkStack();
 
   if (have_exception) {
+    ThrowLocation exc_location(throw_location_this_object.Get(),
+                               throw_location_method.Get(),
+                               throw_location_dex_pc);
     const_cast<Thread*>(this)->SetException(exc_location, exc.Get());
   }
 }