From 79ffe35fa0784f26c2d25242ea1b3ce300a009cb Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Fri, 10 Oct 2014 15:57:19 -0700 Subject: [PATCH] Handlerize throw location in DumpJavaStack Handlerize this object and method during DumpJavaStack. Bug: 17669899 Change-Id: I2e082137fe7f4c82257fc3b2fb36485a6981f369 --- runtime/thread.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/runtime/thread.cc b/runtime/thread.cc index 482ba2680..45d799d02 100644 --- a/runtime/thread.cc +++ b/runtime/thread.cc @@ -981,12 +981,18 @@ void Thread::DumpJavaStack(std::ostream& os) const { // 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(this)); + StackHandleScope<3> scope(const_cast(this)); Handle exc; - ThrowLocation exc_location; + Handle throw_location_this_object; + Handle 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(this)->ClearException(); have_exception = true; } @@ -997,6 +1003,9 @@ void Thread::DumpJavaStack(std::ostream& os) const { dumper.WalkStack(); if (have_exception) { + ThrowLocation exc_location(throw_location_this_object.Get(), + throw_location_method.Get(), + throw_location_dex_pc); const_cast(this)->SetException(exc_location, exc.Get()); } } -- 2.11.0