xref: /aosp_15_r20/art/compiler/exception_test.cc (revision 795d594fd825385562da6b089ea9b2033f3abf5a)
1*795d594fSAndroid Build Coastguard Worker /*
2*795d594fSAndroid Build Coastguard Worker  * Copyright (C) 2011 The Android Open Source Project
3*795d594fSAndroid Build Coastguard Worker  *
4*795d594fSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*795d594fSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*795d594fSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*795d594fSAndroid Build Coastguard Worker  *
8*795d594fSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*795d594fSAndroid Build Coastguard Worker  *
10*795d594fSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*795d594fSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*795d594fSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*795d594fSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*795d594fSAndroid Build Coastguard Worker  * limitations under the License.
15*795d594fSAndroid Build Coastguard Worker  */
16*795d594fSAndroid Build Coastguard Worker 
17*795d594fSAndroid Build Coastguard Worker #include <android-base/test_utils.h>
18*795d594fSAndroid Build Coastguard Worker 
19*795d594fSAndroid Build Coastguard Worker #include <memory>
20*795d594fSAndroid Build Coastguard Worker #include <type_traits>
21*795d594fSAndroid Build Coastguard Worker 
22*795d594fSAndroid Build Coastguard Worker #include "art_method-inl.h"
23*795d594fSAndroid Build Coastguard Worker #include "base/arena_allocator.h"
24*795d594fSAndroid Build Coastguard Worker #include "base/callee_save_type.h"
25*795d594fSAndroid Build Coastguard Worker #include "base/leb128.h"
26*795d594fSAndroid Build Coastguard Worker #include "base/macros.h"
27*795d594fSAndroid Build Coastguard Worker #include "base/malloc_arena_pool.h"
28*795d594fSAndroid Build Coastguard Worker #include "base/pointer_size.h"
29*795d594fSAndroid Build Coastguard Worker #include "class_linker.h"
30*795d594fSAndroid Build Coastguard Worker #include "common_runtime_test.h"
31*795d594fSAndroid Build Coastguard Worker #include "dex/code_item_accessors-inl.h"
32*795d594fSAndroid Build Coastguard Worker #include "dex/dex_file-inl.h"
33*795d594fSAndroid Build Coastguard Worker #include "dex/dex_file.h"
34*795d594fSAndroid Build Coastguard Worker #include "dex/dex_file_exception_helpers.h"
35*795d594fSAndroid Build Coastguard Worker #include "gtest/gtest.h"
36*795d594fSAndroid Build Coastguard Worker #include "handle_scope-inl.h"
37*795d594fSAndroid Build Coastguard Worker #include "mirror/class-inl.h"
38*795d594fSAndroid Build Coastguard Worker #include "mirror/object-inl.h"
39*795d594fSAndroid Build Coastguard Worker #include "mirror/object_array-inl.h"
40*795d594fSAndroid Build Coastguard Worker #include "mirror/stack_trace_element-inl.h"
41*795d594fSAndroid Build Coastguard Worker #include "oat/oat_quick_method_header.h"
42*795d594fSAndroid Build Coastguard Worker #include "obj_ptr-inl.h"
43*795d594fSAndroid Build Coastguard Worker #include "optimizing/stack_map_stream.h"
44*795d594fSAndroid Build Coastguard Worker #include "runtime-inl.h"
45*795d594fSAndroid Build Coastguard Worker #include "scoped_thread_state_change-inl.h"
46*795d594fSAndroid Build Coastguard Worker #include "thread.h"
47*795d594fSAndroid Build Coastguard Worker 
48*795d594fSAndroid Build Coastguard Worker namespace art HIDDEN {
49*795d594fSAndroid Build Coastguard Worker 
50*795d594fSAndroid Build Coastguard Worker class ExceptionTest : public CommonRuntimeTest {
51*795d594fSAndroid Build Coastguard Worker  protected:
52*795d594fSAndroid Build Coastguard Worker   // Since various dexers may differ in bytecode layout, we play
53*795d594fSAndroid Build Coastguard Worker   // it safe and simply set the dex pc to the start of the method,
54*795d594fSAndroid Build Coastguard Worker   // which always points to the first source statement.
55*795d594fSAndroid Build Coastguard Worker   static constexpr const uint32_t kDexPc = 0;
56*795d594fSAndroid Build Coastguard Worker 
SetUp()57*795d594fSAndroid Build Coastguard Worker   void SetUp() override {
58*795d594fSAndroid Build Coastguard Worker     CommonRuntimeTest::SetUp();
59*795d594fSAndroid Build Coastguard Worker 
60*795d594fSAndroid Build Coastguard Worker     ScopedObjectAccess soa(Thread::Current());
61*795d594fSAndroid Build Coastguard Worker     StackHandleScope<2> hs(soa.Self());
62*795d594fSAndroid Build Coastguard Worker     Handle<mirror::ClassLoader> class_loader(
63*795d594fSAndroid Build Coastguard Worker         hs.NewHandle(soa.Decode<mirror::ClassLoader>(LoadDex("ExceptionHandle"))));
64*795d594fSAndroid Build Coastguard Worker     my_klass_ = FindClass("LExceptionHandle;", class_loader);
65*795d594fSAndroid Build Coastguard Worker     ASSERT_TRUE(my_klass_ != nullptr);
66*795d594fSAndroid Build Coastguard Worker     Handle<mirror::Class> klass(hs.NewHandle(my_klass_));
67*795d594fSAndroid Build Coastguard Worker     class_linker_->EnsureInitialized(soa.Self(), klass, true, true);
68*795d594fSAndroid Build Coastguard Worker     my_klass_ = klass.Get();
69*795d594fSAndroid Build Coastguard Worker 
70*795d594fSAndroid Build Coastguard Worker     dex_ = my_klass_->GetDexCache()->GetDexFile();
71*795d594fSAndroid Build Coastguard Worker 
72*795d594fSAndroid Build Coastguard Worker     std::vector<uint8_t> fake_code;
73*795d594fSAndroid Build Coastguard Worker     uint32_t code_size = 12;
74*795d594fSAndroid Build Coastguard Worker     for (size_t i = 0 ; i < code_size; i++) {
75*795d594fSAndroid Build Coastguard Worker       fake_code.push_back(0x70 | i);
76*795d594fSAndroid Build Coastguard Worker     }
77*795d594fSAndroid Build Coastguard Worker 
78*795d594fSAndroid Build Coastguard Worker     const uint32_t native_pc_offset = 4u;
79*795d594fSAndroid Build Coastguard Worker     CHECK_ALIGNED_PARAM(native_pc_offset, GetInstructionSetInstructionAlignment(kRuntimeISA));
80*795d594fSAndroid Build Coastguard Worker 
81*795d594fSAndroid Build Coastguard Worker     MallocArenaPool pool;
82*795d594fSAndroid Build Coastguard Worker     ArenaStack arena_stack(&pool);
83*795d594fSAndroid Build Coastguard Worker     ScopedArenaAllocator allocator(&arena_stack);
84*795d594fSAndroid Build Coastguard Worker     StackMapStream stack_maps(&allocator, kRuntimeISA);
85*795d594fSAndroid Build Coastguard Worker     stack_maps.BeginMethod(/* frame_size_in_bytes= */ 4 * sizeof(void*),
86*795d594fSAndroid Build Coastguard Worker                            /* core_spill_mask= */ 0u,
87*795d594fSAndroid Build Coastguard Worker                            /* fp_spill_mask= */ 0u,
88*795d594fSAndroid Build Coastguard Worker                            /* num_dex_registers= */ 0u,
89*795d594fSAndroid Build Coastguard Worker                            /* baseline= */ false,
90*795d594fSAndroid Build Coastguard Worker                            /* debuggable= */ false);
91*795d594fSAndroid Build Coastguard Worker     stack_maps.BeginStackMapEntry(kDexPc, native_pc_offset);
92*795d594fSAndroid Build Coastguard Worker     stack_maps.EndStackMapEntry();
93*795d594fSAndroid Build Coastguard Worker     stack_maps.EndMethod(code_size);
94*795d594fSAndroid Build Coastguard Worker     ScopedArenaVector<uint8_t> stack_map = stack_maps.Encode();
95*795d594fSAndroid Build Coastguard Worker 
96*795d594fSAndroid Build Coastguard Worker     const size_t stack_maps_size = stack_map.size();
97*795d594fSAndroid Build Coastguard Worker     const size_t header_size = sizeof(OatQuickMethodHeader);
98*795d594fSAndroid Build Coastguard Worker     const size_t code_alignment = GetInstructionSetCodeAlignment(kRuntimeISA);
99*795d594fSAndroid Build Coastguard Worker 
100*795d594fSAndroid Build Coastguard Worker     fake_header_code_and_maps_size_ = stack_maps_size + header_size + code_size + code_alignment;
101*795d594fSAndroid Build Coastguard Worker     // Use mmap to make sure we get untagged memory here. Real code gets allocated using
102*795d594fSAndroid Build Coastguard Worker     // mspace_memalign which is never tagged.
103*795d594fSAndroid Build Coastguard Worker     fake_header_code_and_maps_ = static_cast<uint8_t*>(mmap(nullptr,
104*795d594fSAndroid Build Coastguard Worker                                                             fake_header_code_and_maps_size_,
105*795d594fSAndroid Build Coastguard Worker                                                             PROT_READ | PROT_WRITE,
106*795d594fSAndroid Build Coastguard Worker                                                             MAP_PRIVATE | MAP_ANONYMOUS,
107*795d594fSAndroid Build Coastguard Worker                                                             -1,
108*795d594fSAndroid Build Coastguard Worker                                                             0));
109*795d594fSAndroid Build Coastguard Worker     uint8_t* code_ptr =
110*795d594fSAndroid Build Coastguard Worker       AlignUp(&fake_header_code_and_maps_[stack_maps_size + header_size], code_alignment);
111*795d594fSAndroid Build Coastguard Worker 
112*795d594fSAndroid Build Coastguard Worker     memcpy(&fake_header_code_and_maps_[0], stack_map.data(), stack_maps_size);
113*795d594fSAndroid Build Coastguard Worker     OatQuickMethodHeader method_header(code_ptr - fake_header_code_and_maps_);
114*795d594fSAndroid Build Coastguard Worker     static_assert(std::is_trivially_copyable<OatQuickMethodHeader>::value, "Cannot use memcpy");
115*795d594fSAndroid Build Coastguard Worker     memcpy(code_ptr - header_size, &method_header, header_size);
116*795d594fSAndroid Build Coastguard Worker     memcpy(code_ptr, fake_code.data(), fake_code.size());
117*795d594fSAndroid Build Coastguard Worker 
118*795d594fSAndroid Build Coastguard Worker     if (kRuntimeISA == InstructionSet::kArm) {
119*795d594fSAndroid Build Coastguard Worker       // Check that the Thumb2 adjustment will be a NOP, see EntryPointToCodePointer().
120*795d594fSAndroid Build Coastguard Worker       CHECK_ALIGNED(code_ptr, 2);
121*795d594fSAndroid Build Coastguard Worker     }
122*795d594fSAndroid Build Coastguard Worker 
123*795d594fSAndroid Build Coastguard Worker     method_f_ = my_klass_->FindClassMethod("f", "()I", kRuntimePointerSize);
124*795d594fSAndroid Build Coastguard Worker     ASSERT_TRUE(method_f_ != nullptr);
125*795d594fSAndroid Build Coastguard Worker     ASSERT_FALSE(method_f_->IsDirect());
126*795d594fSAndroid Build Coastguard Worker     method_f_->SetEntryPointFromQuickCompiledCode(code_ptr);
127*795d594fSAndroid Build Coastguard Worker 
128*795d594fSAndroid Build Coastguard Worker     method_g_ = my_klass_->FindClassMethod("g", "(I)V", kRuntimePointerSize);
129*795d594fSAndroid Build Coastguard Worker     ASSERT_TRUE(method_g_ != nullptr);
130*795d594fSAndroid Build Coastguard Worker     ASSERT_FALSE(method_g_->IsDirect());
131*795d594fSAndroid Build Coastguard Worker     method_g_->SetEntryPointFromQuickCompiledCode(code_ptr);
132*795d594fSAndroid Build Coastguard Worker   }
133*795d594fSAndroid Build Coastguard Worker 
TearDown()134*795d594fSAndroid Build Coastguard Worker   void TearDown() override { munmap(fake_header_code_and_maps_, fake_header_code_and_maps_size_); }
135*795d594fSAndroid Build Coastguard Worker 
136*795d594fSAndroid Build Coastguard Worker   const DexFile* dex_;
137*795d594fSAndroid Build Coastguard Worker 
138*795d594fSAndroid Build Coastguard Worker   size_t fake_header_code_and_maps_size_;
139*795d594fSAndroid Build Coastguard Worker   uint8_t* fake_header_code_and_maps_;
140*795d594fSAndroid Build Coastguard Worker 
141*795d594fSAndroid Build Coastguard Worker   ArtMethod* method_f_;
142*795d594fSAndroid Build Coastguard Worker   ArtMethod* method_g_;
143*795d594fSAndroid Build Coastguard Worker 
144*795d594fSAndroid Build Coastguard Worker  private:
145*795d594fSAndroid Build Coastguard Worker   ObjPtr<mirror::Class> my_klass_;
146*795d594fSAndroid Build Coastguard Worker };
147*795d594fSAndroid Build Coastguard Worker 
TEST_F(ExceptionTest,FindCatchHandler)148*795d594fSAndroid Build Coastguard Worker TEST_F(ExceptionTest, FindCatchHandler) {
149*795d594fSAndroid Build Coastguard Worker   ScopedObjectAccess soa(Thread::Current());
150*795d594fSAndroid Build Coastguard Worker   CodeItemDataAccessor accessor(*dex_, method_f_->GetCodeItem());
151*795d594fSAndroid Build Coastguard Worker 
152*795d594fSAndroid Build Coastguard Worker   ASSERT_TRUE(accessor.HasCodeItem());
153*795d594fSAndroid Build Coastguard Worker 
154*795d594fSAndroid Build Coastguard Worker   ASSERT_EQ(2u, accessor.TriesSize());
155*795d594fSAndroid Build Coastguard Worker   ASSERT_NE(0u, accessor.InsnsSizeInCodeUnits());
156*795d594fSAndroid Build Coastguard Worker 
157*795d594fSAndroid Build Coastguard Worker   const dex::TryItem& t0 = accessor.TryItems().begin()[0];
158*795d594fSAndroid Build Coastguard Worker   const dex::TryItem& t1 = accessor.TryItems().begin()[1];
159*795d594fSAndroid Build Coastguard Worker   EXPECT_LE(t0.start_addr_, t1.start_addr_);
160*795d594fSAndroid Build Coastguard Worker   {
161*795d594fSAndroid Build Coastguard Worker     CatchHandlerIterator iter(accessor, 4 /* Dex PC in the first try block */);
162*795d594fSAndroid Build Coastguard Worker     EXPECT_STREQ("Ljava/io/IOException;", dex_->GetTypeDescriptor(iter.GetHandlerTypeIndex()));
163*795d594fSAndroid Build Coastguard Worker     ASSERT_TRUE(iter.HasNext());
164*795d594fSAndroid Build Coastguard Worker     iter.Next();
165*795d594fSAndroid Build Coastguard Worker     EXPECT_STREQ("Ljava/lang/Exception;", dex_->GetTypeDescriptor(iter.GetHandlerTypeIndex()));
166*795d594fSAndroid Build Coastguard Worker     ASSERT_TRUE(iter.HasNext());
167*795d594fSAndroid Build Coastguard Worker     iter.Next();
168*795d594fSAndroid Build Coastguard Worker     EXPECT_FALSE(iter.HasNext());
169*795d594fSAndroid Build Coastguard Worker   }
170*795d594fSAndroid Build Coastguard Worker   {
171*795d594fSAndroid Build Coastguard Worker     CatchHandlerIterator iter(accessor, 8 /* Dex PC in the second try block */);
172*795d594fSAndroid Build Coastguard Worker     EXPECT_STREQ("Ljava/io/IOException;", dex_->GetTypeDescriptor(iter.GetHandlerTypeIndex()));
173*795d594fSAndroid Build Coastguard Worker     ASSERT_TRUE(iter.HasNext());
174*795d594fSAndroid Build Coastguard Worker     iter.Next();
175*795d594fSAndroid Build Coastguard Worker     EXPECT_FALSE(iter.HasNext());
176*795d594fSAndroid Build Coastguard Worker   }
177*795d594fSAndroid Build Coastguard Worker   {
178*795d594fSAndroid Build Coastguard Worker     CatchHandlerIterator iter(accessor, 11 /* Dex PC not in any try block */);
179*795d594fSAndroid Build Coastguard Worker     EXPECT_FALSE(iter.HasNext());
180*795d594fSAndroid Build Coastguard Worker   }
181*795d594fSAndroid Build Coastguard Worker }
182*795d594fSAndroid Build Coastguard Worker 
TEST_F(ExceptionTest,StackTraceElement)183*795d594fSAndroid Build Coastguard Worker TEST_F(ExceptionTest, StackTraceElement) {
184*795d594fSAndroid Build Coastguard Worker   Thread* thread = Thread::Current();
185*795d594fSAndroid Build Coastguard Worker   thread->TransitionFromSuspendedToRunnable();
186*795d594fSAndroid Build Coastguard Worker   bool started = runtime_->Start();
187*795d594fSAndroid Build Coastguard Worker   CHECK(started);
188*795d594fSAndroid Build Coastguard Worker   JNIEnv* env = thread->GetJniEnv();
189*795d594fSAndroid Build Coastguard Worker   ScopedObjectAccess soa(env);
190*795d594fSAndroid Build Coastguard Worker 
191*795d594fSAndroid Build Coastguard Worker   std::vector<uintptr_t> fake_stack;
192*795d594fSAndroid Build Coastguard Worker   Runtime* r = Runtime::Current();
193*795d594fSAndroid Build Coastguard Worker   r->SetInstructionSet(kRuntimeISA);
194*795d594fSAndroid Build Coastguard Worker   ArtMethod* save_method = r->CreateCalleeSaveMethod();
195*795d594fSAndroid Build Coastguard Worker   r->SetCalleeSaveMethod(save_method, CalleeSaveType::kSaveAllCalleeSaves);
196*795d594fSAndroid Build Coastguard Worker   QuickMethodFrameInfo frame_info = r->GetRuntimeMethodFrameInfo(save_method);
197*795d594fSAndroid Build Coastguard Worker 
198*795d594fSAndroid Build Coastguard Worker   ASSERT_EQ(kStackAlignment, 16U);
199*795d594fSAndroid Build Coastguard Worker   // ASSERT_EQ(sizeof(uintptr_t), sizeof(uint32_t));
200*795d594fSAndroid Build Coastguard Worker 
201*795d594fSAndroid Build Coastguard Worker   // Create the stack frame for the callee save method, expected by the runtime.
202*795d594fSAndroid Build Coastguard Worker   fake_stack.push_back(reinterpret_cast<uintptr_t>(save_method));
203*795d594fSAndroid Build Coastguard Worker   for (size_t i = 0; i < frame_info.FrameSizeInBytes() - 2 * sizeof(uintptr_t);
204*795d594fSAndroid Build Coastguard Worker        i += sizeof(uintptr_t)) {
205*795d594fSAndroid Build Coastguard Worker     fake_stack.push_back(0);
206*795d594fSAndroid Build Coastguard Worker   }
207*795d594fSAndroid Build Coastguard Worker 
208*795d594fSAndroid Build Coastguard Worker   OatQuickMethodHeader* header = OatQuickMethodHeader::FromEntryPoint(
209*795d594fSAndroid Build Coastguard Worker       method_g_->GetEntryPointFromQuickCompiledCode());
210*795d594fSAndroid Build Coastguard Worker   // Untag native pc when running with hwasan since the pcs on the stack aren't tagged and we use
211*795d594fSAndroid Build Coastguard Worker   // this to create a fake stack. See OatQuickMethodHeader::Contains where we untag code pointers
212*795d594fSAndroid Build Coastguard Worker   // before comparing it with the PC from the stack.
213*795d594fSAndroid Build Coastguard Worker   uintptr_t native_pc = header->ToNativeQuickPc(method_g_, kDexPc);
214*795d594fSAndroid Build Coastguard Worker   if (running_with_hwasan()) {
215*795d594fSAndroid Build Coastguard Worker     // TODO(228989263): Use HWASanUntag once we have a hwasan target for tests too. HWASanUntag
216*795d594fSAndroid Build Coastguard Worker     // uses static checks which won't work if we don't have a dedicated target.
217*795d594fSAndroid Build Coastguard Worker     native_pc = (native_pc & ((1ULL << 56) - 1));
218*795d594fSAndroid Build Coastguard Worker   }
219*795d594fSAndroid Build Coastguard Worker   fake_stack.push_back(native_pc);  // return pc
220*795d594fSAndroid Build Coastguard Worker 
221*795d594fSAndroid Build Coastguard Worker   // Create/push fake 16byte stack frame for method g
222*795d594fSAndroid Build Coastguard Worker   fake_stack.push_back(reinterpret_cast<uintptr_t>(method_g_));
223*795d594fSAndroid Build Coastguard Worker   fake_stack.push_back(0);
224*795d594fSAndroid Build Coastguard Worker   fake_stack.push_back(0);
225*795d594fSAndroid Build Coastguard Worker   fake_stack.push_back(native_pc);  // return pc.
226*795d594fSAndroid Build Coastguard Worker 
227*795d594fSAndroid Build Coastguard Worker   // Create/push fake 16byte stack frame for method f
228*795d594fSAndroid Build Coastguard Worker   fake_stack.push_back(reinterpret_cast<uintptr_t>(method_f_));
229*795d594fSAndroid Build Coastguard Worker   fake_stack.push_back(0);
230*795d594fSAndroid Build Coastguard Worker   fake_stack.push_back(0);
231*795d594fSAndroid Build Coastguard Worker   fake_stack.push_back(0xEBAD6070);  // return pc
232*795d594fSAndroid Build Coastguard Worker 
233*795d594fSAndroid Build Coastguard Worker   // Push Method* of null to terminate the trace
234*795d594fSAndroid Build Coastguard Worker   fake_stack.push_back(0);
235*795d594fSAndroid Build Coastguard Worker 
236*795d594fSAndroid Build Coastguard Worker   // Push null values which will become null incoming arguments.
237*795d594fSAndroid Build Coastguard Worker   fake_stack.push_back(0);
238*795d594fSAndroid Build Coastguard Worker   fake_stack.push_back(0);
239*795d594fSAndroid Build Coastguard Worker   fake_stack.push_back(0);
240*795d594fSAndroid Build Coastguard Worker 
241*795d594fSAndroid Build Coastguard Worker   // Set up thread to appear as if we called out of method_g_ at given pc dex.
242*795d594fSAndroid Build Coastguard Worker   thread->SetTopOfStack(reinterpret_cast<ArtMethod**>(&fake_stack[0]));
243*795d594fSAndroid Build Coastguard Worker 
244*795d594fSAndroid Build Coastguard Worker   jobject internal = soa.AddLocalReference<jobject>(thread->CreateInternalStackTrace(soa));
245*795d594fSAndroid Build Coastguard Worker   ASSERT_TRUE(internal != nullptr);
246*795d594fSAndroid Build Coastguard Worker   jobjectArray ste_array = Thread::InternalStackTraceToStackTraceElementArray(soa, internal);
247*795d594fSAndroid Build Coastguard Worker   ASSERT_TRUE(ste_array != nullptr);
248*795d594fSAndroid Build Coastguard Worker   auto trace_array = soa.Decode<mirror::ObjectArray<mirror::StackTraceElement>>(ste_array);
249*795d594fSAndroid Build Coastguard Worker 
250*795d594fSAndroid Build Coastguard Worker   ASSERT_TRUE(trace_array != nullptr);
251*795d594fSAndroid Build Coastguard Worker   ASSERT_TRUE(trace_array->Get(0) != nullptr);
252*795d594fSAndroid Build Coastguard Worker   EXPECT_STREQ("ExceptionHandle",
253*795d594fSAndroid Build Coastguard Worker                trace_array->Get(0)->GetDeclaringClass()->ToModifiedUtf8().c_str());
254*795d594fSAndroid Build Coastguard Worker   EXPECT_STREQ("ExceptionHandle.java",
255*795d594fSAndroid Build Coastguard Worker                trace_array->Get(0)->GetFileName()->ToModifiedUtf8().c_str());
256*795d594fSAndroid Build Coastguard Worker   EXPECT_STREQ("g", trace_array->Get(0)->GetMethodName()->ToModifiedUtf8().c_str());
257*795d594fSAndroid Build Coastguard Worker   EXPECT_EQ(36, trace_array->Get(0)->GetLineNumber());
258*795d594fSAndroid Build Coastguard Worker 
259*795d594fSAndroid Build Coastguard Worker   ASSERT_TRUE(trace_array->Get(1) != nullptr);
260*795d594fSAndroid Build Coastguard Worker   EXPECT_STREQ("ExceptionHandle",
261*795d594fSAndroid Build Coastguard Worker                trace_array->Get(1)->GetDeclaringClass()->ToModifiedUtf8().c_str());
262*795d594fSAndroid Build Coastguard Worker   EXPECT_STREQ("ExceptionHandle.java",
263*795d594fSAndroid Build Coastguard Worker                trace_array->Get(1)->GetFileName()->ToModifiedUtf8().c_str());
264*795d594fSAndroid Build Coastguard Worker   EXPECT_STREQ("f", trace_array->Get(1)->GetMethodName()->ToModifiedUtf8().c_str());
265*795d594fSAndroid Build Coastguard Worker   EXPECT_EQ(22, trace_array->Get(1)->GetLineNumber());
266*795d594fSAndroid Build Coastguard Worker 
267*795d594fSAndroid Build Coastguard Worker   thread->SetTopOfStack(nullptr);  // Disarm the assertion that no code is running when we detach.
268*795d594fSAndroid Build Coastguard Worker }
269*795d594fSAndroid Build Coastguard Worker 
270*795d594fSAndroid Build Coastguard Worker }  // namespace art
271