OSDN Git Service

Fix JDWP ObjectReference.InvokeMethod for virtual method call.
authorSebastien Hertz <shertz@google.com>
Thu, 20 Mar 2014 08:57:40 +0000 (09:57 +0100)
committerSebastien Hertz <shertz@google.com>
Thu, 20 Mar 2014 08:57:40 +0000 (09:57 +0100)
Fixes virtual method call by invoking the concrete method in sirt reference
after devirtualization, not the original method.

Bug: 13526099
Change-Id: I2e3548eca2f5434e8cece64c22aaf80d1cd8badf

runtime/debugger.cc

index 2c671aa..036b0c5 100644 (file)
@@ -3071,7 +3071,7 @@ void Dbg::ExecuteMethod(DebugInvokeReq* pReq) {
   // Translate the method through the vtable, unless the debugger wants to suppress it.
   SirtRef<mirror::ArtMethod> m(soa.Self(), pReq->method);
   if ((pReq->options & JDWP::INVOKE_NONVIRTUAL) == 0 && pReq->receiver != NULL) {
-    mirror::ArtMethod* actual_method = pReq->klass->FindVirtualMethodForVirtualOrInterface(pReq->method);
+    mirror::ArtMethod* actual_method = pReq->klass->FindVirtualMethodForVirtualOrInterface(m.get());
     if (actual_method != m.get()) {
       VLOG(jdwp) << "ExecuteMethod translated " << PrettyMethod(m.get()) << " to " << PrettyMethod(actual_method);
       m.reset(actual_method);
@@ -3084,7 +3084,7 @@ void Dbg::ExecuteMethod(DebugInvokeReq* pReq) {
 
   CHECK_EQ(sizeof(jvalue), sizeof(uint64_t));
 
-  pReq->result_value = InvokeWithJValues(soa, pReq->receiver, soa.EncodeMethod(pReq->method),
+  pReq->result_value = InvokeWithJValues(soa, pReq->receiver, soa.EncodeMethod(m.get()),
                                          reinterpret_cast<jvalue*>(pReq->arg_values));
 
   mirror::Throwable* exception = soa.Self()->GetException(NULL);