Fix JDWP tests after ArtMethod change
Fixes Throwable::GetStackDepth for exception event detection after
internal stack trace representation change.
Adds missing ArtMethod::GetInterfaceMethodIfProxy call in case of
proxy method.
Bug: 19264997
Change-Id: I363e293796848c3ec491c963813f62d868da44d2
diff --git a/runtime/debugger.cc b/runtime/debugger.cc
index 7999559..24615e2 100644
--- a/runtime/debugger.cc
+++ b/runtime/debugger.cc
@@ -1467,7 +1467,7 @@
if (m == nullptr) {
return "null";
}
- return m->GetName();
+ return m->GetInterfaceMethodIfProxy(sizeof(void*))->GetName();
}
std::string Dbg::GetFieldName(JDWP::FieldId field_id) {
@@ -1590,8 +1590,9 @@
ArtMethod* m = i < direct_method_count ?
c->GetDirectMethod(i, ptr_size) : c->GetVirtualMethod(i - direct_method_count, ptr_size);
expandBufAddMethodId(pReply, ToMethodId(m));
- expandBufAddUtf8String(pReply, m->GetName());
- expandBufAddUtf8String(pReply, m->GetSignature().ToString());
+ expandBufAddUtf8String(pReply, m->GetInterfaceMethodIfProxy(sizeof(void*))->GetName());
+ expandBufAddUtf8String(pReply,
+ m->GetInterfaceMethodIfProxy(sizeof(void*))->GetSignature().ToString());
if (with_generic) {
const char* generic_signature = "";
expandBufAddUtf8String(pReply, generic_signature);
diff --git a/runtime/mirror/throwable.cc b/runtime/mirror/throwable.cc
index 224d266..1c21edb 100644
--- a/runtime/mirror/throwable.cc
+++ b/runtime/mirror/throwable.cc
@@ -71,9 +71,18 @@
int32_t Throwable::GetStackDepth() {
Object* stack_state = GetStackState();
- if (stack_state == nullptr || !stack_state->IsObjectArray()) return -1;
- ObjectArray<Object>* method_trace = down_cast<ObjectArray<Object>*>(stack_state);
- return method_trace->GetLength() - 1;
+ if (stack_state == nullptr) {
+ return -1;
+ }
+ if (!stack_state->IsIntArray() && !stack_state->IsLongArray()) {
+ return -1;
+ }
+ mirror::PointerArray* method_trace = down_cast<mirror::PointerArray*>(stack_state->AsArray());
+ int32_t array_len = method_trace->GetLength();
+ // The format is [method pointers][pcs] so the depth is half the length (see method
+ // BuildInternalStackTraceVisitor::Init).
+ CHECK_EQ(array_len % 2, 0);
+ return array_len / 2;
}
std::string Throwable::Dump() {
diff --git a/runtime/thread.cc b/runtime/thread.cc
index 89e3467..65999f7 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -1583,7 +1583,7 @@
bool Init(int depth)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- // Allocate method trace with an extra slot that will hold the PC trace
+ // Allocate method trace with format [method pointers][pcs].
auto* cl = Runtime::Current()->GetClassLinker();
trace_ = cl->AllocPointerArray(self_, depth * 2);
if (trace_ == nullptr) {