Fix exception_test for (USE_LLVM_COMPILER) build.
Finally tdy's patch marks the passing of all gtests on host.
(cherry picked from commit daadfea12645ffafefa1c7debe1178ffc0db1148)
Change-Id: I73ad33cba74d728716cee3656cd76b4be6febe1e
diff --git a/src/exception_test.cc b/src/exception_test.cc
index 120f16a..877f1c3 100644
--- a/src/exception_test.cc
+++ b/src/exception_test.cc
@@ -118,6 +118,7 @@
ASSERT_EQ(kStackAlignment, 16);
ASSERT_EQ(sizeof(uintptr_t), sizeof(uint32_t));
+#if !defined(ART_USE_LLVM_COMPILER)
// Create two fake stack frames with mapping data created in SetUp. We map offset 3 in the code
// to dex pc 3, however, we set the return pc to 5 as the stack walker always subtracts two
// from a return pc.
@@ -141,6 +142,25 @@
// Set up thread to appear as if we called out of method_g_ at pc 3
Thread* thread = Thread::Current();
thread->SetTopOfStack(&fake_stack[0], reinterpret_cast<uintptr_t>(method_g_->GetCode()) + pc_offset); // return pc
+#else
+ // Create/push fake 20-byte shadow frame for method g
+ fake_stack.push_back(0);
+ fake_stack.push_back(0);
+ fake_stack.push_back(reinterpret_cast<uintptr_t>(method_g_));
+ fake_stack.push_back(37);
+ fake_stack.push_back(0);
+
+ // Create/push fake 20-byte shadow frame for method f
+ fake_stack.push_back(0);
+ fake_stack.push_back(0);
+ fake_stack.push_back(reinterpret_cast<uintptr_t>(method_f_));
+ fake_stack.push_back(22);
+ fake_stack.push_back(0);
+
+ Thread* thread = Thread::Current();
+ thread->PushShadowFrame(reinterpret_cast<ShadowFrame*>(&fake_stack[5]));
+ thread->PushShadowFrame(reinterpret_cast<ShadowFrame*>(&fake_stack[0]));
+#endif
JNIEnv* env = thread->GetJniEnv();
jobject internal = thread->CreateInternalStackTrace(env);
diff --git a/src/shadow_frame.h b/src/shadow_frame.h
index c5b6492..9a02a58 100644
--- a/src/shadow_frame.h
+++ b/src/shadow_frame.h
@@ -31,6 +31,11 @@
return number_of_references_;
}
+ // Caller line number
+ uint32_t GetLineNumber() const {
+ return line_num_;
+ }
+
// Link to previous shadow frame or NULL
ShadowFrame* GetLink() const {
return link_;
diff --git a/src/thread.cc b/src/thread.cc
index ae460e4..1f1952d 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -1384,7 +1384,7 @@
Frame frame;
frame.SetSP(reinterpret_cast<Method**>(reinterpret_cast<byte*>(cur) +
ShadowFrame::MethodOffset()));
- bool should_continue = visitor->VisitFrame(frame, 0);
+ bool should_continue = visitor->VisitFrame(frame, cur->GetLineNumber());
if (!should_continue) {
return;
}
@@ -1490,7 +1490,11 @@
Method* method = down_cast<Method*>(method_trace->Get(i));
mh.ChangeMethod(method);
uint32_t native_pc = pc_trace->Get(i);
+#if !defined(ART_USE_LLVM_COMPILER)
int32_t line_number = mh.GetLineNumFromNativePC(native_pc);
+#else
+ int32_t line_number = native_pc; // LLVM stored line_number in the ShadowFrame
+#endif
// Allocate element, potentially triggering GC
// TODO: reuse class_name_object via Class::name_?
const char* descriptor = mh.GetDeclaringClassDescriptor();