summaryrefslogtreecommitdiff
path: root/compiler/exception_test.cc
diff options
context:
space:
mode:
author Aart Bik <ajcbik@google.com> 2018-02-08 11:23:07 -0800
committer Aart Bik <ajcbik@google.com> 2018-02-08 11:23:07 -0800
commite78471d19081a53ed13d9078b000b78b6c975e1f (patch)
tree99753e6a78f4d37bdac7f62da13f6b6ea91defb7 /compiler/exception_test.cc
parent6568c1c52ca504200c1852b92c1029728938298d (diff)
Make exception test more robust against dex changes.
Rationale: With the shift from dx to d8, dex bytecode may be layed out slightly different. The exception test was not particularly robust against this, as it was looking for instruction at dex_pc == 3 in method g(). Incidentialy, the way it was setup, it would even use that dex_pc for querying f(), which seemed unintentional (and makes it hard to make the test more robust by e.g. looking up the new instance instruction). Therefore, test was made more robust by simply assuming dex_pc == 0, which consistently maps to first statement in source. Bug: 73050355 Test: exception_test Change-Id: Ic5b2784a48ae10d139c0b77a3bbfcc53b58a5b42
Diffstat (limited to 'compiler/exception_test.cc')
-rw-r--r--compiler/exception_test.cc20
1 files changed, 10 insertions, 10 deletions
diff --git a/compiler/exception_test.cc b/compiler/exception_test.cc
index 7bacacf91d..f00fe637cf 100644
--- a/compiler/exception_test.cc
+++ b/compiler/exception_test.cc
@@ -42,6 +42,11 @@ namespace art {
class ExceptionTest : public CommonRuntimeTest {
protected:
+ // Since various dexers may differ in bytecode layout, we play
+ // it safe and simply set the dex pc to the start of the method,
+ // which always points to the first source statement.
+ static constexpr const uint32_t kDexPc = 0;
+
virtual void SetUp() {
CommonRuntimeTest::SetUp();
@@ -66,7 +71,7 @@ class ExceptionTest : public CommonRuntimeTest {
ArenaStack arena_stack(&pool);
ScopedArenaAllocator allocator(&arena_stack);
StackMapStream stack_maps(&allocator, kRuntimeISA);
- stack_maps.BeginStackMapEntry(/* dex_pc */ 3u,
+ stack_maps.BeginStackMapEntry(kDexPc,
/* native_pc_offset */ 3u,
/* register_mask */ 0u,
/* sp_mask */ nullptr,
@@ -181,11 +186,6 @@ TEST_F(ExceptionTest, StackTraceElement) {
ASSERT_EQ(kStackAlignment, 16U);
// ASSERT_EQ(sizeof(uintptr_t), sizeof(uint32_t));
-
- // Create three fake stack frames with mapping data created in SetUp. We map offset 3 in the
- // code to dex pc 3.
- const uint32_t dex_pc = 3;
-
// Create the stack frame for the callee save method, expected by the runtime.
fake_stack.push_back(reinterpret_cast<uintptr_t>(save_method));
for (size_t i = 0; i < frame_info.FrameSizeInBytes() - 2 * sizeof(uintptr_t);
@@ -194,14 +194,14 @@ TEST_F(ExceptionTest, StackTraceElement) {
}
fake_stack.push_back(method_g_->GetOatQuickMethodHeader(0)->ToNativeQuickPc(
- method_g_, dex_pc, /* is_catch_handler */ false)); // return pc
+ method_g_, kDexPc, /* is_catch_handler */ false)); // return pc
// Create/push fake 16byte stack frame for method g
fake_stack.push_back(reinterpret_cast<uintptr_t>(method_g_));
fake_stack.push_back(0);
fake_stack.push_back(0);
fake_stack.push_back(method_g_->GetOatQuickMethodHeader(0)->ToNativeQuickPc(
- method_g_, dex_pc, /* is_catch_handler */ false)); // return pc
+ method_g_, kDexPc, /* is_catch_handler */ false)); // return pc
// Create/push fake 16byte stack frame for method f
fake_stack.push_back(reinterpret_cast<uintptr_t>(method_f_));
@@ -217,7 +217,7 @@ TEST_F(ExceptionTest, StackTraceElement) {
fake_stack.push_back(0);
fake_stack.push_back(0);
- // Set up thread to appear as if we called out of method_g_ at pc dex 3
+ // Set up thread to appear as if we called out of method_g_ at given pc dex.
thread->SetTopOfStack(reinterpret_cast<ArtMethod**>(&fake_stack[0]));
jobject internal = thread->CreateInternalStackTrace<false>(soa);
@@ -233,7 +233,7 @@ TEST_F(ExceptionTest, StackTraceElement) {
EXPECT_STREQ("ExceptionHandle.java",
trace_array->Get(0)->GetFileName()->ToModifiedUtf8().c_str());
EXPECT_STREQ("g", trace_array->Get(0)->GetMethodName()->ToModifiedUtf8().c_str());
- EXPECT_EQ(37, trace_array->Get(0)->GetLineNumber());
+ EXPECT_EQ(36, trace_array->Get(0)->GetLineNumber());
ASSERT_TRUE(trace_array->Get(1) != nullptr);
EXPECT_STREQ("ExceptionHandle",