Handlerize throw location in DumpJavaStack
Handlerize this object and method during DumpJavaStack.
Bug: 17669899
(cherry picked from commit 79ffe35fa0784f26c2d25242ea1b3ce300a009cb)
Change-Id: Id090daaa2eef8cd445e52cbbe71b2e2ed7fef2fe
diff --git a/runtime/thread.cc b/runtime/thread.cc
index d573a3f..fd37703 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -950,12 +950,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;
}
@@ -966,6 +972,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());
}
}