diff options
author | 2019-09-24 14:36:50 -0700 | |
---|---|---|
committer | 2019-10-03 20:44:33 +0000 | |
commit | c84fc3a742b160ce51cbf01c2e5f971ccc0a2c6c (patch) | |
tree | 1380b353e0d3b5015c9d1ef29fd4c2534828f97b /runtime/debugger.cc | |
parent | 8679fd5e938d7bed67d3ab67c55b7f4fb2cdd92a (diff) |
Walk internal ArtField/ArtMethod pointers
During structural class redefinition we sometimes need to update some
of the ArtMethod/ArtField pointers held by runtime frames. This adds
support for doing this through a StackReflectiveHandleScope similar to
the StackHandleScope used for holding object references. This also
updates various places where reflective-handles to ArtMethods and
ArtFields are needed, for example the JniIdManager, field Read/Write
operations and events, field resolution, and the old debugger.
Test: ./test.py --host
Bug: 134162467
Change-Id: I4ea73e85956a07735c6d7b125c5828a4233670bc
Diffstat (limited to 'runtime/debugger.cc')
-rw-r--r-- | runtime/debugger.cc | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/runtime/debugger.cc b/runtime/debugger.cc index 4cc3583496..b28868fb7b 100644 --- a/runtime/debugger.cc +++ b/runtime/debugger.cc @@ -71,6 +71,8 @@ #include "oat_file.h" #include "obj_ptr-inl.h" #include "reflection.h" +#include "reflective_handle.h" +#include "reflective_handle_scope-inl.h" #include "runtime-inl.h" #include "scoped_thread_state_change-inl.h" #include "stack.h" @@ -4056,18 +4058,19 @@ void Dbg::ExecuteMethodWithoutPendingException(ScopedObjectAccess& soa, DebugInv soa.Self()->AssertNoPendingException(); // Translate the method through the vtable, unless the debugger wants to suppress it. - ArtMethod* m = pReq->method; + StackArtMethodHandleScope<2> rhs(soa.Self()); + MutableReflectiveHandle<ArtMethod> m(rhs.NewHandle(pReq->method)); PointerSize image_pointer_size = Runtime::Current()->GetClassLinker()->GetImagePointerSize(); if ((pReq->options & JDWP::INVOKE_NONVIRTUAL) == 0 && pReq->receiver.Read() != nullptr) { - ArtMethod* actual_method = - pReq->klass.Read()->FindVirtualMethodForVirtualOrInterface(m, image_pointer_size); - if (actual_method != m) { - VLOG(jdwp) << "ExecuteMethod translated " << ArtMethod::PrettyMethod(m) - << " to " << ArtMethod::PrettyMethod(actual_method); + MutableReflectiveHandle<ArtMethod> actual_method(rhs.NewHandle( + pReq->klass.Read()->FindVirtualMethodForVirtualOrInterface(m.Get(), image_pointer_size))); + if (actual_method.Get() != m.Get()) { + VLOG(jdwp) << "ExecuteMethod translated " << m->PrettyMethod() + << " to " << actual_method->PrettyMethod(); m = actual_method; } } - VLOG(jdwp) << "ExecuteMethod " << ArtMethod::PrettyMethod(m) + VLOG(jdwp) << "ExecuteMethod " << m->PrettyMethod() << " receiver=" << pReq->receiver.Read() << " arg_count=" << pReq->arg_count; CHECK(m != nullptr); |