blob: a187dc3796f038650b093a62adc6fe9e13d10c03 [file] [log] [blame]
Christopher Ferrisc3d79f72017-11-28 19:14:54 -08001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <inttypes.h>
18#include <stdint.h>
19#include <stdio.h>
20#include <stdlib.h>
21#include <unistd.h>
22
23#include <gtest/gtest.h>
24
25#include <string>
Christopher Ferrise37e2d02018-02-09 15:57:39 -080026#include <unordered_map>
Christopher Ferrisc3d79f72017-11-28 19:14:54 -080027#include <vector>
28
Christopher Ferrise37e2d02018-02-09 15:57:39 -080029#include <android-base/file.h>
30
Christopher Ferris150db122017-12-20 18:49:01 -080031#include <unwindstack/JitDebug.h>
Christopher Ferris53914162018-02-08 19:27:47 -080032#include <unwindstack/MachineArm.h>
33#include <unwindstack/MachineArm64.h>
34#include <unwindstack/MachineX86.h>
Christopher Ferrise37e2d02018-02-09 15:57:39 -080035#include <unwindstack/MachineX86_64.h>
Christopher Ferrisc3d79f72017-11-28 19:14:54 -080036#include <unwindstack/Maps.h>
37#include <unwindstack/Memory.h>
Christopher Ferrisd06001d2017-11-30 18:56:01 -080038#include <unwindstack/RegsArm.h>
39#include <unwindstack/RegsArm64.h>
Christopher Ferris150db122017-12-20 18:49:01 -080040#include <unwindstack/RegsX86.h>
Christopher Ferrise37e2d02018-02-09 15:57:39 -080041#include <unwindstack/RegsX86_64.h>
Christopher Ferrisc3d79f72017-11-28 19:14:54 -080042#include <unwindstack/Unwinder.h>
43
Christopher Ferrisc3d79f72017-11-28 19:14:54 -080044#include "ElfTestUtils.h"
45
46namespace unwindstack {
47
Christopher Ferrisd299a7a2018-05-17 18:37:38 -070048static void AddMemory(std::string file_name, MemoryOfflineParts* parts) {
49 MemoryOffline* memory = new MemoryOffline;
50 ASSERT_TRUE(memory->Init(file_name.c_str(), 0));
51 parts->Add(memory);
52}
53
Christopher Ferrise37e2d02018-02-09 15:57:39 -080054class UnwindOfflineTest : public ::testing::Test {
55 protected:
56 void TearDown() override {
57 if (cwd_ != nullptr) {
58 ASSERT_EQ(0, chdir(cwd_));
59 }
60 free(cwd_);
61 }
62
63 void Init(const char* file_dir, ArchEnum arch) {
64 dir_ = TestGetFileDirectory() + "offline/" + file_dir;
65
66 std::string data;
67 ASSERT_TRUE(android::base::ReadFileToString((dir_ + "maps.txt"), &data));
68
69 maps_.reset(new BufferMaps(data.c_str()));
70 ASSERT_TRUE(maps_->Parse());
71
Christopher Ferrisd299a7a2018-05-17 18:37:38 -070072 std::string stack_name(dir_ + "stack.data");
73 struct stat st;
74 if (stat(stack_name.c_str(), &st) == 0 && S_ISREG(st.st_mode)) {
75 std::unique_ptr<MemoryOffline> stack_memory(new MemoryOffline);
76 ASSERT_TRUE(stack_memory->Init((dir_ + "stack.data").c_str(), 0));
77 process_memory_.reset(stack_memory.release());
78 } else {
79 std::unique_ptr<MemoryOfflineParts> stack_memory(new MemoryOfflineParts);
80 for (size_t i = 0;; i++) {
81 stack_name = dir_ + "stack" + std::to_string(i) + ".data";
82 if (stat(stack_name.c_str(), &st) == -1 || !S_ISREG(st.st_mode)) {
83 ASSERT_TRUE(i != 0) << "No stack data files found.";
84 break;
85 }
86 AddMemory(stack_name, stack_memory.get());
87 }
88 process_memory_.reset(stack_memory.release());
89 }
Christopher Ferrise37e2d02018-02-09 15:57:39 -080090
91 switch (arch) {
92 case ARCH_ARM: {
93 RegsArm* regs = new RegsArm;
94 regs_.reset(regs);
95 ReadRegs<uint32_t>(regs, arm_regs_);
96 break;
97 }
98 case ARCH_ARM64: {
99 RegsArm64* regs = new RegsArm64;
100 regs_.reset(regs);
101 ReadRegs<uint64_t>(regs, arm64_regs_);
102 break;
103 }
104 case ARCH_X86: {
105 RegsX86* regs = new RegsX86;
106 regs_.reset(regs);
107 ReadRegs<uint32_t>(regs, x86_regs_);
108 break;
109 }
110 case ARCH_X86_64: {
111 RegsX86_64* regs = new RegsX86_64;
112 regs_.reset(regs);
113 ReadRegs<uint64_t>(regs, x86_64_regs_);
114 break;
115 }
116 default:
117 ASSERT_TRUE(false) << "Unknown arch " << std::to_string(arch);
118 }
119 cwd_ = getcwd(nullptr, 0);
120 // Make dir_ an absolute directory.
121 if (dir_.empty() || dir_[0] != '/') {
122 dir_ = std::string(cwd_) + '/' + dir_;
123 }
124 ASSERT_EQ(0, chdir(dir_.c_str()));
125 }
126
127 template <typename AddressType>
128 void ReadRegs(RegsImpl<AddressType>* regs,
129 const std::unordered_map<std::string, uint32_t>& name_to_reg) {
130 FILE* fp = fopen((dir_ + "regs.txt").c_str(), "r");
131 ASSERT_TRUE(fp != nullptr);
132 while (!feof(fp)) {
133 uint64_t value;
134 char reg_name[100];
135 ASSERT_EQ(2, fscanf(fp, "%s %" SCNx64 "\n", reg_name, &value));
136 std::string name(reg_name);
137 if (!name.empty()) {
138 // Remove the : from the end.
139 name.resize(name.size() - 1);
140 }
141 auto entry = name_to_reg.find(name);
142 ASSERT_TRUE(entry != name_to_reg.end()) << "Unknown register named " << name;
143 (*regs)[entry->second] = value;
144 }
145 fclose(fp);
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800146 }
147
148 static std::unordered_map<std::string, uint32_t> arm_regs_;
149 static std::unordered_map<std::string, uint32_t> arm64_regs_;
150 static std::unordered_map<std::string, uint32_t> x86_regs_;
151 static std::unordered_map<std::string, uint32_t> x86_64_regs_;
152
153 char* cwd_ = nullptr;
154 std::string dir_;
155 std::unique_ptr<Regs> regs_;
156 std::unique_ptr<Maps> maps_;
157 std::shared_ptr<Memory> process_memory_;
158};
159
160std::unordered_map<std::string, uint32_t> UnwindOfflineTest::arm_regs_ = {
161 {"r0", ARM_REG_R0}, {"r1", ARM_REG_R1}, {"r2", ARM_REG_R2}, {"r3", ARM_REG_R3},
162 {"r4", ARM_REG_R4}, {"r5", ARM_REG_R5}, {"r6", ARM_REG_R6}, {"r7", ARM_REG_R7},
163 {"r8", ARM_REG_R8}, {"r9", ARM_REG_R9}, {"r10", ARM_REG_R10}, {"r11", ARM_REG_R11},
164 {"ip", ARM_REG_R12}, {"sp", ARM_REG_SP}, {"lr", ARM_REG_LR}, {"pc", ARM_REG_PC},
165};
166
167std::unordered_map<std::string, uint32_t> UnwindOfflineTest::arm64_regs_ = {
168 {"x0", ARM64_REG_R0}, {"x1", ARM64_REG_R1}, {"x2", ARM64_REG_R2}, {"x3", ARM64_REG_R3},
169 {"x4", ARM64_REG_R4}, {"x5", ARM64_REG_R5}, {"x6", ARM64_REG_R6}, {"x7", ARM64_REG_R7},
170 {"x8", ARM64_REG_R8}, {"x9", ARM64_REG_R9}, {"x10", ARM64_REG_R10}, {"x11", ARM64_REG_R11},
171 {"x12", ARM64_REG_R12}, {"x13", ARM64_REG_R13}, {"x14", ARM64_REG_R14}, {"x15", ARM64_REG_R15},
172 {"x16", ARM64_REG_R16}, {"x17", ARM64_REG_R17}, {"x18", ARM64_REG_R18}, {"x19", ARM64_REG_R19},
173 {"x20", ARM64_REG_R20}, {"x21", ARM64_REG_R21}, {"x22", ARM64_REG_R22}, {"x23", ARM64_REG_R23},
174 {"x24", ARM64_REG_R24}, {"x25", ARM64_REG_R25}, {"x26", ARM64_REG_R26}, {"x27", ARM64_REG_R27},
175 {"x28", ARM64_REG_R28}, {"x29", ARM64_REG_R29}, {"sp", ARM64_REG_SP}, {"lr", ARM64_REG_LR},
176 {"pc", ARM64_REG_PC},
177};
178
179std::unordered_map<std::string, uint32_t> UnwindOfflineTest::x86_regs_ = {
180 {"eax", X86_REG_EAX}, {"ebx", X86_REG_EBX}, {"ecx", X86_REG_ECX},
181 {"edx", X86_REG_EDX}, {"ebp", X86_REG_EBP}, {"edi", X86_REG_EDI},
182 {"esi", X86_REG_ESI}, {"esp", X86_REG_ESP}, {"eip", X86_REG_EIP},
183};
184
185std::unordered_map<std::string, uint32_t> UnwindOfflineTest::x86_64_regs_ = {
186 {"rax", X86_64_REG_RAX}, {"rbx", X86_64_REG_RBX}, {"rcx", X86_64_REG_RCX},
187 {"rdx", X86_64_REG_RDX}, {"r8", X86_64_REG_R8}, {"r9", X86_64_REG_R9},
188 {"r10", X86_64_REG_R10}, {"r11", X86_64_REG_R11}, {"r12", X86_64_REG_R12},
189 {"r13", X86_64_REG_R13}, {"r14", X86_64_REG_R14}, {"r15", X86_64_REG_R15},
190 {"rdi", X86_64_REG_RDI}, {"rsi", X86_64_REG_RSI}, {"rbp", X86_64_REG_RBP},
191 {"rsp", X86_64_REG_RSP}, {"rip", X86_64_REG_RIP},
192};
193
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800194static std::string DumpFrames(Unwinder& unwinder) {
195 std::string str;
196 for (size_t i = 0; i < unwinder.NumFrames(); i++) {
197 str += unwinder.FormatFrame(i) + "\n";
198 }
199 return str;
200}
201
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800202TEST_F(UnwindOfflineTest, pc_straddle_arm) {
Christopher Ferrisd299a7a2018-05-17 18:37:38 -0700203 ASSERT_NO_FATAL_FAILURE(Init("straddle_arm/", ARCH_ARM));
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800204
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800205 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800206 unwinder.Unwind();
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800207
208 std::string frame_info(DumpFrames(unwinder));
209 ASSERT_EQ(4U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
210 EXPECT_EQ(
Christopher Ferrisb70b4a52018-03-15 14:35:01 -0700211 " #00 pc 0001a9f8 libc.so (abort+64)\n"
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800212 " #01 pc 00006a1b libbase.so (_ZN7android4base14DefaultAborterEPKc+6)\n"
213 " #02 pc 00007441 libbase.so (_ZN7android4base10LogMessageD2Ev+748)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800214 " #03 pc 00015147 /does/not/exist/libhidlbase.so\n",
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800215 frame_info);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800216 EXPECT_EQ(0xf31ea9f8U, unwinder.frames()[0].pc);
217 EXPECT_EQ(0xe9c866f8U, unwinder.frames()[0].sp);
218 EXPECT_EQ(0xf2da0a1bU, unwinder.frames()[1].pc);
219 EXPECT_EQ(0xe9c86728U, unwinder.frames()[1].sp);
220 EXPECT_EQ(0xf2da1441U, unwinder.frames()[2].pc);
221 EXPECT_EQ(0xe9c86730U, unwinder.frames()[2].sp);
222 EXPECT_EQ(0xf3367147U, unwinder.frames()[3].pc);
223 EXPECT_EQ(0xe9c86778U, unwinder.frames()[3].sp);
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800224}
225
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800226TEST_F(UnwindOfflineTest, pc_in_gnu_debugdata_arm) {
Christopher Ferrisd299a7a2018-05-17 18:37:38 -0700227 ASSERT_NO_FATAL_FAILURE(Init("gnu_debugdata_arm/", ARCH_ARM));
Christopher Ferrise7b66242017-12-15 11:17:45 -0800228
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800229 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
Christopher Ferrise7b66242017-12-15 11:17:45 -0800230 unwinder.Unwind();
Christopher Ferrise7b66242017-12-15 11:17:45 -0800231
232 std::string frame_info(DumpFrames(unwinder));
233 ASSERT_EQ(2U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
234 EXPECT_EQ(
235 " #00 pc 0006dc49 libandroid_runtime.so "
236 "(_ZN7android14AndroidRuntime15javaThreadShellEPv+80)\n"
237 " #01 pc 0006dce5 libandroid_runtime.so "
238 "(_ZN7android14AndroidRuntime19javaCreateThreadEtcEPFiPvES1_PKcijPS1_)\n",
239 frame_info);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800240 EXPECT_EQ(0xf1f6dc49U, unwinder.frames()[0].pc);
241 EXPECT_EQ(0xd8fe6930U, unwinder.frames()[0].sp);
242 EXPECT_EQ(0xf1f6dce5U, unwinder.frames()[1].pc);
243 EXPECT_EQ(0xd8fe6958U, unwinder.frames()[1].sp);
Christopher Ferrise7b66242017-12-15 11:17:45 -0800244}
245
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800246TEST_F(UnwindOfflineTest, pc_straddle_arm64) {
Christopher Ferrisd299a7a2018-05-17 18:37:38 -0700247 ASSERT_NO_FATAL_FAILURE(Init("straddle_arm64/", ARCH_ARM64));
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800248
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800249 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800250 unwinder.Unwind();
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800251
252 std::string frame_info(DumpFrames(unwinder));
253 ASSERT_EQ(6U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
254 EXPECT_EQ(
255 " #00 pc 0000000000429fd8 libunwindstack_test (SignalInnerFunction+24)\n"
256 " #01 pc 000000000042a078 libunwindstack_test (SignalMiddleFunction+8)\n"
257 " #02 pc 000000000042a08c libunwindstack_test (SignalOuterFunction+8)\n"
258 " #03 pc 000000000042d8fc libunwindstack_test "
259 "(_ZN11unwindstackL19RemoteThroughSignalEij+20)\n"
260 " #04 pc 000000000042d8d8 libunwindstack_test "
261 "(_ZN11unwindstack37UnwindTest_remote_through_signal_Test8TestBodyEv+32)\n"
262 " #05 pc 0000000000455d70 libunwindstack_test (_ZN7testing4Test3RunEv+392)\n",
263 frame_info);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800264 EXPECT_EQ(0x64d09d4fd8U, unwinder.frames()[0].pc);
265 EXPECT_EQ(0x7fe0d84040U, unwinder.frames()[0].sp);
266 EXPECT_EQ(0x64d09d5078U, unwinder.frames()[1].pc);
267 EXPECT_EQ(0x7fe0d84070U, unwinder.frames()[1].sp);
268 EXPECT_EQ(0x64d09d508cU, unwinder.frames()[2].pc);
269 EXPECT_EQ(0x7fe0d84080U, unwinder.frames()[2].sp);
270 EXPECT_EQ(0x64d09d88fcU, unwinder.frames()[3].pc);
271 EXPECT_EQ(0x7fe0d84090U, unwinder.frames()[3].sp);
272 EXPECT_EQ(0x64d09d88d8U, unwinder.frames()[4].pc);
273 EXPECT_EQ(0x7fe0d840f0U, unwinder.frames()[4].sp);
274 EXPECT_EQ(0x64d0a00d70U, unwinder.frames()[5].pc);
275 EXPECT_EQ(0x7fe0d84110U, unwinder.frames()[5].sp);
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800276}
277
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800278TEST_F(UnwindOfflineTest, jit_debug_x86) {
Christopher Ferrisd299a7a2018-05-17 18:37:38 -0700279 ASSERT_NO_FATAL_FAILURE(Init("jit_debug_x86/", ARCH_X86));
Christopher Ferris150db122017-12-20 18:49:01 -0800280
281 MemoryOfflineParts* memory = new MemoryOfflineParts;
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800282 AddMemory(dir_ + "descriptor.data", memory);
283 AddMemory(dir_ + "stack.data", memory);
Christopher Ferris150db122017-12-20 18:49:01 -0800284 for (size_t i = 0; i < 7; i++) {
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800285 AddMemory(dir_ + "entry" + std::to_string(i) + ".data", memory);
286 AddMemory(dir_ + "jit" + std::to_string(i) + ".data", memory);
Christopher Ferris150db122017-12-20 18:49:01 -0800287 }
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800288 process_memory_.reset(memory);
Christopher Ferris150db122017-12-20 18:49:01 -0800289
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800290 JitDebug jit_debug(process_memory_);
291 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
292 unwinder.SetJitDebug(&jit_debug, regs_->Arch());
Christopher Ferris150db122017-12-20 18:49:01 -0800293 unwinder.Unwind();
Christopher Ferris150db122017-12-20 18:49:01 -0800294
295 std::string frame_info(DumpFrames(unwinder));
296 ASSERT_EQ(69U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
297 EXPECT_EQ(
298 " #00 pc 00068fb8 libarttestd.so (_ZN3artL13CauseSegfaultEv+72)\n"
299 " #01 pc 00067f00 libarttestd.so (Java_Main_unwindInProcess+10032)\n"
300 " #02 pc 000021a8 (offset 0x2000) 137-cfi.odex (boolean Main.unwindInProcess(boolean, int, "
301 "boolean)+136)\n"
Christopher Ferrisfd6b7282018-03-28 15:12:49 -0700302 " #03 pc 0000fe80 anonymous:ee74c000 (boolean Main.bar(boolean)+64)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800303 " #04 pc 006ad4d2 libartd.so (art_quick_invoke_stub+338)\n"
304 " #05 pc 00146ab5 libartd.so "
305 "(_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+885)\n"
306 " #06 pc 0039cf0d libartd.so "
307 "(_ZN3art11interpreter34ArtInterpreterToCompiledCodeBridgeEPNS_6ThreadEPNS_9ArtMethodEPNS_"
308 "11ShadowFrameEtPNS_6JValueE+653)\n"
309 " #07 pc 00392552 libartd.so "
310 "(_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_"
311 "6JValueEb+354)\n"
312 " #08 pc 0039399a libartd.so "
313 "(_ZN3art11interpreter30EnterInterpreterFromEntryPointEPNS_6ThreadERKNS_"
314 "20CodeItemDataAccessorEPNS_11ShadowFrameE+234)\n"
315 " #09 pc 00684362 libartd.so (artQuickToInterpreterBridge+1058)\n"
316 " #10 pc 006b35bd libartd.so (art_quick_to_interpreter_bridge+77)\n"
Christopher Ferrisfd6b7282018-03-28 15:12:49 -0700317 " #11 pc 0000fe03 anonymous:ee74c000 (int Main.compare(Main, Main)+51)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800318 " #12 pc 006ad4d2 libartd.so (art_quick_invoke_stub+338)\n"
319 " #13 pc 00146ab5 libartd.so "
320 "(_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+885)\n"
321 " #14 pc 0039cf0d libartd.so "
322 "(_ZN3art11interpreter34ArtInterpreterToCompiledCodeBridgeEPNS_6ThreadEPNS_9ArtMethodEPNS_"
323 "11ShadowFrameEtPNS_6JValueE+653)\n"
324 " #15 pc 00392552 libartd.so "
325 "(_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_"
326 "6JValueEb+354)\n"
327 " #16 pc 0039399a libartd.so "
328 "(_ZN3art11interpreter30EnterInterpreterFromEntryPointEPNS_6ThreadERKNS_"
329 "20CodeItemDataAccessorEPNS_11ShadowFrameE+234)\n"
330 " #17 pc 00684362 libartd.so (artQuickToInterpreterBridge+1058)\n"
331 " #18 pc 006b35bd libartd.so (art_quick_to_interpreter_bridge+77)\n"
Christopher Ferrisfd6b7282018-03-28 15:12:49 -0700332 " #19 pc 0000fd3b anonymous:ee74c000 (int Main.compare(java.lang.Object, "
333 "java.lang.Object)+107)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800334 " #20 pc 006ad4d2 libartd.so (art_quick_invoke_stub+338)\n"
335 " #21 pc 00146ab5 libartd.so "
336 "(_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+885)\n"
337 " #22 pc 0039cf0d libartd.so "
338 "(_ZN3art11interpreter34ArtInterpreterToCompiledCodeBridgeEPNS_6ThreadEPNS_9ArtMethodEPNS_"
339 "11ShadowFrameEtPNS_6JValueE+653)\n"
340 " #23 pc 00392552 libartd.so "
341 "(_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_"
342 "6JValueEb+354)\n"
343 " #24 pc 0039399a libartd.so "
344 "(_ZN3art11interpreter30EnterInterpreterFromEntryPointEPNS_6ThreadERKNS_"
345 "20CodeItemDataAccessorEPNS_11ShadowFrameE+234)\n"
346 " #25 pc 00684362 libartd.so (artQuickToInterpreterBridge+1058)\n"
347 " #26 pc 006b35bd libartd.so (art_quick_to_interpreter_bridge+77)\n"
Christopher Ferrisfd6b7282018-03-28 15:12:49 -0700348 " #27 pc 0000fbdb anonymous:ee74c000 (int "
Christopher Ferris150db122017-12-20 18:49:01 -0800349 "java.util.Arrays.binarySearch0(java.lang.Object[], int, int, java.lang.Object, "
Christopher Ferrisfd6b7282018-03-28 15:12:49 -0700350 "java.util.Comparator)+331)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800351 " #28 pc 006ad6a2 libartd.so (art_quick_invoke_static_stub+418)\n"
352 " #29 pc 00146acb libartd.so "
353 "(_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+907)\n"
354 " #30 pc 0039cf0d libartd.so "
355 "(_ZN3art11interpreter34ArtInterpreterToCompiledCodeBridgeEPNS_6ThreadEPNS_9ArtMethodEPNS_"
356 "11ShadowFrameEtPNS_6JValueE+653)\n"
357 " #31 pc 00392552 libartd.so "
358 "(_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_"
359 "6JValueEb+354)\n"
360 " #32 pc 0039399a libartd.so "
361 "(_ZN3art11interpreter30EnterInterpreterFromEntryPointEPNS_6ThreadERKNS_"
362 "20CodeItemDataAccessorEPNS_11ShadowFrameE+234)\n"
363 " #33 pc 00684362 libartd.so (artQuickToInterpreterBridge+1058)\n"
364 " #34 pc 006b35bd libartd.so (art_quick_to_interpreter_bridge+77)\n"
Christopher Ferrisfd6b7282018-03-28 15:12:49 -0700365 " #35 pc 0000f624 anonymous:ee74c000 (boolean Main.foo()+164)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800366 " #36 pc 006ad4d2 libartd.so (art_quick_invoke_stub+338)\n"
367 " #37 pc 00146ab5 libartd.so "
368 "(_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+885)\n"
369 " #38 pc 0039cf0d libartd.so "
370 "(_ZN3art11interpreter34ArtInterpreterToCompiledCodeBridgeEPNS_6ThreadEPNS_9ArtMethodEPNS_"
371 "11ShadowFrameEtPNS_6JValueE+653)\n"
372 " #39 pc 00392552 libartd.so "
373 "(_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_"
374 "6JValueEb+354)\n"
375 " #40 pc 0039399a libartd.so "
376 "(_ZN3art11interpreter30EnterInterpreterFromEntryPointEPNS_6ThreadERKNS_"
377 "20CodeItemDataAccessorEPNS_11ShadowFrameE+234)\n"
378 " #41 pc 00684362 libartd.so (artQuickToInterpreterBridge+1058)\n"
379 " #42 pc 006b35bd libartd.so (art_quick_to_interpreter_bridge+77)\n"
Christopher Ferrisfd6b7282018-03-28 15:12:49 -0700380 " #43 pc 0000eedb anonymous:ee74c000 (void Main.runPrimary()+59)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800381 " #44 pc 006ad4d2 libartd.so (art_quick_invoke_stub+338)\n"
382 " #45 pc 00146ab5 libartd.so "
383 "(_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+885)\n"
384 " #46 pc 0039cf0d libartd.so "
385 "(_ZN3art11interpreter34ArtInterpreterToCompiledCodeBridgeEPNS_6ThreadEPNS_9ArtMethodEPNS_"
386 "11ShadowFrameEtPNS_6JValueE+653)\n"
387 " #47 pc 00392552 libartd.so "
388 "(_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_"
389 "6JValueEb+354)\n"
390 " #48 pc 0039399a libartd.so "
391 "(_ZN3art11interpreter30EnterInterpreterFromEntryPointEPNS_6ThreadERKNS_"
392 "20CodeItemDataAccessorEPNS_11ShadowFrameE+234)\n"
393 " #49 pc 00684362 libartd.so (artQuickToInterpreterBridge+1058)\n"
394 " #50 pc 006b35bd libartd.so (art_quick_to_interpreter_bridge+77)\n"
Christopher Ferrisfd6b7282018-03-28 15:12:49 -0700395 " #51 pc 0000ac21 anonymous:ee74c000 (void Main.main(java.lang.String[])+97)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800396 " #52 pc 006ad6a2 libartd.so (art_quick_invoke_static_stub+418)\n"
397 " #53 pc 00146acb libartd.so "
398 "(_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+907)\n"
399 " #54 pc 0039cf0d libartd.so "
400 "(_ZN3art11interpreter34ArtInterpreterToCompiledCodeBridgeEPNS_6ThreadEPNS_9ArtMethodEPNS_"
401 "11ShadowFrameEtPNS_6JValueE+653)\n"
402 " #55 pc 00392552 libartd.so "
403 "(_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_"
404 "6JValueEb+354)\n"
405 " #56 pc 0039399a libartd.so "
406 "(_ZN3art11interpreter30EnterInterpreterFromEntryPointEPNS_6ThreadERKNS_"
407 "20CodeItemDataAccessorEPNS_11ShadowFrameE+234)\n"
408 " #57 pc 00684362 libartd.so (artQuickToInterpreterBridge+1058)\n"
409 " #58 pc 006b35bd libartd.so (art_quick_to_interpreter_bridge+77)\n"
410 " #59 pc 006ad6a2 libartd.so (art_quick_invoke_static_stub+418)\n"
411 " #60 pc 00146acb libartd.so "
412 "(_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+907)\n"
413 " #61 pc 005aac95 libartd.so "
414 "(_ZN3artL18InvokeWithArgArrayERKNS_33ScopedObjectAccessAlreadyRunnableEPNS_9ArtMethodEPNS_"
415 "8ArgArrayEPNS_6JValueEPKc+85)\n"
416 " #62 pc 005aab5a libartd.so "
417 "(_ZN3art17InvokeWithVarArgsERKNS_33ScopedObjectAccessAlreadyRunnableEP8_jobjectP10_"
418 "jmethodIDPc+362)\n"
419 " #63 pc 0048a3dd libartd.so "
420 "(_ZN3art3JNI21CallStaticVoidMethodVEP7_JNIEnvP7_jclassP10_jmethodIDPc+125)\n"
421 " #64 pc 0018448c libartd.so "
422 "(_ZN3art8CheckJNI11CallMethodVEPKcP7_JNIEnvP8_jobjectP7_jclassP10_jmethodIDPcNS_"
423 "9Primitive4TypeENS_10InvokeTypeE+1964)\n"
424 " #65 pc 0017cf06 libartd.so "
425 "(_ZN3art8CheckJNI21CallStaticVoidMethodVEP7_JNIEnvP7_jclassP10_jmethodIDPc+70)\n"
426 " #66 pc 00001d8c dalvikvm32 "
427 "(_ZN7_JNIEnv20CallStaticVoidMethodEP7_jclassP10_jmethodIDz+60)\n"
428 " #67 pc 00001a80 dalvikvm32 (main+1312)\n"
429 " #68 pc 00018275 libc.so\n",
430 frame_info);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800431 EXPECT_EQ(0xeb89bfb8U, unwinder.frames()[0].pc);
432 EXPECT_EQ(0xffeb5280U, unwinder.frames()[0].sp);
433 EXPECT_EQ(0xeb89af00U, unwinder.frames()[1].pc);
434 EXPECT_EQ(0xffeb52a0U, unwinder.frames()[1].sp);
435 EXPECT_EQ(0xec6061a8U, unwinder.frames()[2].pc);
436 EXPECT_EQ(0xffeb5ce0U, unwinder.frames()[2].sp);
Christopher Ferrisfd6b7282018-03-28 15:12:49 -0700437 EXPECT_EQ(0xee75be80U, unwinder.frames()[3].pc);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800438 EXPECT_EQ(0xffeb5d30U, unwinder.frames()[3].sp);
439 EXPECT_EQ(0xf728e4d2U, unwinder.frames()[4].pc);
440 EXPECT_EQ(0xffeb5d60U, unwinder.frames()[4].sp);
441 EXPECT_EQ(0xf6d27ab5U, unwinder.frames()[5].pc);
442 EXPECT_EQ(0xffeb5d80U, unwinder.frames()[5].sp);
443 EXPECT_EQ(0xf6f7df0dU, unwinder.frames()[6].pc);
444 EXPECT_EQ(0xffeb5e20U, unwinder.frames()[6].sp);
445 EXPECT_EQ(0xf6f73552U, unwinder.frames()[7].pc);
446 EXPECT_EQ(0xffeb5ec0U, unwinder.frames()[7].sp);
447 EXPECT_EQ(0xf6f7499aU, unwinder.frames()[8].pc);
448 EXPECT_EQ(0xffeb5f40U, unwinder.frames()[8].sp);
449 EXPECT_EQ(0xf7265362U, unwinder.frames()[9].pc);
450 EXPECT_EQ(0xffeb5fb0U, unwinder.frames()[9].sp);
451 EXPECT_EQ(0xf72945bdU, unwinder.frames()[10].pc);
452 EXPECT_EQ(0xffeb6110U, unwinder.frames()[10].sp);
Christopher Ferrisfd6b7282018-03-28 15:12:49 -0700453 EXPECT_EQ(0xee75be03U, unwinder.frames()[11].pc);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800454 EXPECT_EQ(0xffeb6160U, unwinder.frames()[11].sp);
455 EXPECT_EQ(0xf728e4d2U, unwinder.frames()[12].pc);
456 EXPECT_EQ(0xffeb6180U, unwinder.frames()[12].sp);
457 EXPECT_EQ(0xf6d27ab5U, unwinder.frames()[13].pc);
458 EXPECT_EQ(0xffeb61b0U, unwinder.frames()[13].sp);
459 EXPECT_EQ(0xf6f7df0dU, unwinder.frames()[14].pc);
460 EXPECT_EQ(0xffeb6250U, unwinder.frames()[14].sp);
461 EXPECT_EQ(0xf6f73552U, unwinder.frames()[15].pc);
462 EXPECT_EQ(0xffeb62f0U, unwinder.frames()[15].sp);
463 EXPECT_EQ(0xf6f7499aU, unwinder.frames()[16].pc);
464 EXPECT_EQ(0xffeb6370U, unwinder.frames()[16].sp);
465 EXPECT_EQ(0xf7265362U, unwinder.frames()[17].pc);
466 EXPECT_EQ(0xffeb63e0U, unwinder.frames()[17].sp);
467 EXPECT_EQ(0xf72945bdU, unwinder.frames()[18].pc);
468 EXPECT_EQ(0xffeb6530U, unwinder.frames()[18].sp);
Christopher Ferrisfd6b7282018-03-28 15:12:49 -0700469 EXPECT_EQ(0xee75bd3bU, unwinder.frames()[19].pc);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800470 EXPECT_EQ(0xffeb6580U, unwinder.frames()[19].sp);
471 EXPECT_EQ(0xf728e4d2U, unwinder.frames()[20].pc);
472 EXPECT_EQ(0xffeb65b0U, unwinder.frames()[20].sp);
473 EXPECT_EQ(0xf6d27ab5U, unwinder.frames()[21].pc);
474 EXPECT_EQ(0xffeb65e0U, unwinder.frames()[21].sp);
475 EXPECT_EQ(0xf6f7df0dU, unwinder.frames()[22].pc);
476 EXPECT_EQ(0xffeb6680U, unwinder.frames()[22].sp);
477 EXPECT_EQ(0xf6f73552U, unwinder.frames()[23].pc);
478 EXPECT_EQ(0xffeb6720U, unwinder.frames()[23].sp);
479 EXPECT_EQ(0xf6f7499aU, unwinder.frames()[24].pc);
480 EXPECT_EQ(0xffeb67a0U, unwinder.frames()[24].sp);
481 EXPECT_EQ(0xf7265362U, unwinder.frames()[25].pc);
482 EXPECT_EQ(0xffeb6810U, unwinder.frames()[25].sp);
483 EXPECT_EQ(0xf72945bdU, unwinder.frames()[26].pc);
484 EXPECT_EQ(0xffeb6960U, unwinder.frames()[26].sp);
Christopher Ferrisfd6b7282018-03-28 15:12:49 -0700485 EXPECT_EQ(0xee75bbdbU, unwinder.frames()[27].pc);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800486 EXPECT_EQ(0xffeb69b0U, unwinder.frames()[27].sp);
487 EXPECT_EQ(0xf728e6a2U, unwinder.frames()[28].pc);
488 EXPECT_EQ(0xffeb69f0U, unwinder.frames()[28].sp);
489 EXPECT_EQ(0xf6d27acbU, unwinder.frames()[29].pc);
490 EXPECT_EQ(0xffeb6a20U, unwinder.frames()[29].sp);
491 EXPECT_EQ(0xf6f7df0dU, unwinder.frames()[30].pc);
492 EXPECT_EQ(0xffeb6ac0U, unwinder.frames()[30].sp);
493 EXPECT_EQ(0xf6f73552U, unwinder.frames()[31].pc);
494 EXPECT_EQ(0xffeb6b60U, unwinder.frames()[31].sp);
495 EXPECT_EQ(0xf6f7499aU, unwinder.frames()[32].pc);
496 EXPECT_EQ(0xffeb6be0U, unwinder.frames()[32].sp);
497 EXPECT_EQ(0xf7265362U, unwinder.frames()[33].pc);
498 EXPECT_EQ(0xffeb6c50U, unwinder.frames()[33].sp);
499 EXPECT_EQ(0xf72945bdU, unwinder.frames()[34].pc);
500 EXPECT_EQ(0xffeb6dd0U, unwinder.frames()[34].sp);
Christopher Ferrisfd6b7282018-03-28 15:12:49 -0700501 EXPECT_EQ(0xee75b624U, unwinder.frames()[35].pc);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800502 EXPECT_EQ(0xffeb6e20U, unwinder.frames()[35].sp);
503 EXPECT_EQ(0xf728e4d2U, unwinder.frames()[36].pc);
504 EXPECT_EQ(0xffeb6e50U, unwinder.frames()[36].sp);
505 EXPECT_EQ(0xf6d27ab5U, unwinder.frames()[37].pc);
506 EXPECT_EQ(0xffeb6e70U, unwinder.frames()[37].sp);
507 EXPECT_EQ(0xf6f7df0dU, unwinder.frames()[38].pc);
508 EXPECT_EQ(0xffeb6f10U, unwinder.frames()[38].sp);
509 EXPECT_EQ(0xf6f73552U, unwinder.frames()[39].pc);
510 EXPECT_EQ(0xffeb6fb0U, unwinder.frames()[39].sp);
511 EXPECT_EQ(0xf6f7499aU, unwinder.frames()[40].pc);
512 EXPECT_EQ(0xffeb7030U, unwinder.frames()[40].sp);
513 EXPECT_EQ(0xf7265362U, unwinder.frames()[41].pc);
514 EXPECT_EQ(0xffeb70a0U, unwinder.frames()[41].sp);
515 EXPECT_EQ(0xf72945bdU, unwinder.frames()[42].pc);
516 EXPECT_EQ(0xffeb71f0U, unwinder.frames()[42].sp);
Christopher Ferrisfd6b7282018-03-28 15:12:49 -0700517 EXPECT_EQ(0xee75aedbU, unwinder.frames()[43].pc);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800518 EXPECT_EQ(0xffeb7240U, unwinder.frames()[43].sp);
519 EXPECT_EQ(0xf728e4d2U, unwinder.frames()[44].pc);
520 EXPECT_EQ(0xffeb72a0U, unwinder.frames()[44].sp);
521 EXPECT_EQ(0xf6d27ab5U, unwinder.frames()[45].pc);
522 EXPECT_EQ(0xffeb72c0U, unwinder.frames()[45].sp);
523 EXPECT_EQ(0xf6f7df0dU, unwinder.frames()[46].pc);
524 EXPECT_EQ(0xffeb7360U, unwinder.frames()[46].sp);
525 EXPECT_EQ(0xf6f73552U, unwinder.frames()[47].pc);
526 EXPECT_EQ(0xffeb7400U, unwinder.frames()[47].sp);
527 EXPECT_EQ(0xf6f7499aU, unwinder.frames()[48].pc);
528 EXPECT_EQ(0xffeb7480U, unwinder.frames()[48].sp);
529 EXPECT_EQ(0xf7265362U, unwinder.frames()[49].pc);
530 EXPECT_EQ(0xffeb74f0U, unwinder.frames()[49].sp);
531 EXPECT_EQ(0xf72945bdU, unwinder.frames()[50].pc);
532 EXPECT_EQ(0xffeb7680U, unwinder.frames()[50].sp);
Christopher Ferrisfd6b7282018-03-28 15:12:49 -0700533 EXPECT_EQ(0xee756c21U, unwinder.frames()[51].pc);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800534 EXPECT_EQ(0xffeb76d0U, unwinder.frames()[51].sp);
535 EXPECT_EQ(0xf728e6a2U, unwinder.frames()[52].pc);
536 EXPECT_EQ(0xffeb76f0U, unwinder.frames()[52].sp);
537 EXPECT_EQ(0xf6d27acbU, unwinder.frames()[53].pc);
538 EXPECT_EQ(0xffeb7710U, unwinder.frames()[53].sp);
539 EXPECT_EQ(0xf6f7df0dU, unwinder.frames()[54].pc);
540 EXPECT_EQ(0xffeb77b0U, unwinder.frames()[54].sp);
541 EXPECT_EQ(0xf6f73552U, unwinder.frames()[55].pc);
542 EXPECT_EQ(0xffeb7850U, unwinder.frames()[55].sp);
543 EXPECT_EQ(0xf6f7499aU, unwinder.frames()[56].pc);
544 EXPECT_EQ(0xffeb78d0U, unwinder.frames()[56].sp);
545 EXPECT_EQ(0xf7265362U, unwinder.frames()[57].pc);
546 EXPECT_EQ(0xffeb7940U, unwinder.frames()[57].sp);
547 EXPECT_EQ(0xf72945bdU, unwinder.frames()[58].pc);
548 EXPECT_EQ(0xffeb7a80U, unwinder.frames()[58].sp);
549 EXPECT_EQ(0xf728e6a2U, unwinder.frames()[59].pc);
550 EXPECT_EQ(0xffeb7ad0U, unwinder.frames()[59].sp);
551 EXPECT_EQ(0xf6d27acbU, unwinder.frames()[60].pc);
552 EXPECT_EQ(0xffeb7af0U, unwinder.frames()[60].sp);
553 EXPECT_EQ(0xf718bc95U, unwinder.frames()[61].pc);
554 EXPECT_EQ(0xffeb7b90U, unwinder.frames()[61].sp);
555 EXPECT_EQ(0xf718bb5aU, unwinder.frames()[62].pc);
556 EXPECT_EQ(0xffeb7c50U, unwinder.frames()[62].sp);
557 EXPECT_EQ(0xf706b3ddU, unwinder.frames()[63].pc);
558 EXPECT_EQ(0xffeb7d10U, unwinder.frames()[63].sp);
559 EXPECT_EQ(0xf6d6548cU, unwinder.frames()[64].pc);
560 EXPECT_EQ(0xffeb7d70U, unwinder.frames()[64].sp);
561 EXPECT_EQ(0xf6d5df06U, unwinder.frames()[65].pc);
562 EXPECT_EQ(0xffeb7df0U, unwinder.frames()[65].sp);
563 EXPECT_EQ(0x56574d8cU, unwinder.frames()[66].pc);
564 EXPECT_EQ(0xffeb7e40U, unwinder.frames()[66].sp);
565 EXPECT_EQ(0x56574a80U, unwinder.frames()[67].pc);
566 EXPECT_EQ(0xffeb7e70U, unwinder.frames()[67].sp);
567 EXPECT_EQ(0xf7363275U, unwinder.frames()[68].pc);
568 EXPECT_EQ(0xffeb7ef0U, unwinder.frames()[68].sp);
Christopher Ferris150db122017-12-20 18:49:01 -0800569}
570
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800571TEST_F(UnwindOfflineTest, jit_debug_arm) {
Christopher Ferrisd299a7a2018-05-17 18:37:38 -0700572 ASSERT_NO_FATAL_FAILURE(Init("jit_debug_arm/", ARCH_ARM));
Christopher Ferrised37aca2018-01-12 15:53:19 -0800573
574 MemoryOfflineParts* memory = new MemoryOfflineParts;
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800575 AddMemory(dir_ + "descriptor.data", memory);
576 AddMemory(dir_ + "descriptor1.data", memory);
577 AddMemory(dir_ + "stack.data", memory);
Christopher Ferrised37aca2018-01-12 15:53:19 -0800578 for (size_t i = 0; i < 7; i++) {
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800579 AddMemory(dir_ + "entry" + std::to_string(i) + ".data", memory);
580 AddMemory(dir_ + "jit" + std::to_string(i) + ".data", memory);
Christopher Ferrised37aca2018-01-12 15:53:19 -0800581 }
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800582 process_memory_.reset(memory);
Christopher Ferrised37aca2018-01-12 15:53:19 -0800583
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800584 JitDebug jit_debug(process_memory_);
585 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
586 unwinder.SetJitDebug(&jit_debug, regs_->Arch());
Christopher Ferrised37aca2018-01-12 15:53:19 -0800587 unwinder.Unwind();
Christopher Ferrised37aca2018-01-12 15:53:19 -0800588
589 std::string frame_info(DumpFrames(unwinder));
590 ASSERT_EQ(76U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
591 EXPECT_EQ(
Christopher Ferrisb70b4a52018-03-15 14:35:01 -0700592 " #00 pc 00018a5e libarttestd.so (Java_Main_unwindInProcess+866)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800593 " #01 pc 0000212d (offset 0x2000) 137-cfi.odex (boolean Main.unwindInProcess(boolean, int, "
594 "boolean)+92)\n"
595 " #02 pc 00011cb1 anonymous:e2796000 (boolean Main.bar(boolean)+72)\n"
596 " #03 pc 00462175 libartd.so (art_quick_invoke_stub_internal+68)\n"
597 " #04 pc 00467129 libartd.so (art_quick_invoke_stub+228)\n"
598 " #05 pc 000bf7a9 libartd.so "
599 "(_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+864)\n"
600 " #06 pc 00247833 libartd.so "
601 "(_ZN3art11interpreter34ArtInterpreterToCompiledCodeBridgeEPNS_6ThreadEPNS_9ArtMethodEPNS_"
602 "11ShadowFrameEtPNS_6JValueE+382)\n"
603 " #07 pc 0022e935 libartd.so "
604 "(_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_"
605 "6JValueEb+244)\n"
606 " #08 pc 0022f71d libartd.so "
607 "(_ZN3art11interpreter30EnterInterpreterFromEntryPointEPNS_6ThreadERKNS_"
608 "20CodeItemDataAccessorEPNS_11ShadowFrameE+128)\n"
609 " #09 pc 00442865 libartd.so (artQuickToInterpreterBridge+796)\n"
610 " #10 pc 004666ff libartd.so (art_quick_to_interpreter_bridge+30)\n"
611 " #11 pc 00011c31 anonymous:e2796000 (int Main.compare(Main, Main)+64)\n"
612 " #12 pc 00462175 libartd.so (art_quick_invoke_stub_internal+68)\n"
613 " #13 pc 00467129 libartd.so (art_quick_invoke_stub+228)\n"
614 " #14 pc 000bf7a9 libartd.so "
615 "(_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+864)\n"
616 " #15 pc 00247833 libartd.so "
617 "(_ZN3art11interpreter34ArtInterpreterToCompiledCodeBridgeEPNS_6ThreadEPNS_9ArtMethodEPNS_"
618 "11ShadowFrameEtPNS_6JValueE+382)\n"
619 " #16 pc 0022e935 libartd.so "
620 "(_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_"
621 "6JValueEb+244)\n"
622 " #17 pc 0022f71d libartd.so "
623 "(_ZN3art11interpreter30EnterInterpreterFromEntryPointEPNS_6ThreadERKNS_"
624 "20CodeItemDataAccessorEPNS_11ShadowFrameE+128)\n"
625 " #18 pc 00442865 libartd.so (artQuickToInterpreterBridge+796)\n"
626 " #19 pc 004666ff libartd.so (art_quick_to_interpreter_bridge+30)\n"
627 " #20 pc 00011b77 anonymous:e2796000 (int Main.compare(java.lang.Object, "
628 "java.lang.Object)+118)\n"
629 " #21 pc 00462175 libartd.so (art_quick_invoke_stub_internal+68)\n"
630 " #22 pc 00467129 libartd.so (art_quick_invoke_stub+228)\n"
631 " #23 pc 000bf7a9 libartd.so "
632 "(_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+864)\n"
633 " #24 pc 00247833 libartd.so "
634 "(_ZN3art11interpreter34ArtInterpreterToCompiledCodeBridgeEPNS_6ThreadEPNS_9ArtMethodEPNS_"
635 "11ShadowFrameEtPNS_6JValueE+382)\n"
636 " #25 pc 0022e935 libartd.so "
637 "(_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_"
638 "6JValueEb+244)\n"
639 " #26 pc 0022f71d libartd.so "
640 "(_ZN3art11interpreter30EnterInterpreterFromEntryPointEPNS_6ThreadERKNS_"
641 "20CodeItemDataAccessorEPNS_11ShadowFrameE+128)\n"
642 " #27 pc 00442865 libartd.so (artQuickToInterpreterBridge+796)\n"
643 " #28 pc 004666ff libartd.so (art_quick_to_interpreter_bridge+30)\n"
644 " #29 pc 00011a29 anonymous:e2796000 (int "
645 "java.util.Arrays.binarySearch0(java.lang.Object[], int, int, java.lang.Object, "
646 "java.util.Comparator)+304)\n"
647 " #30 pc 00462175 libartd.so (art_quick_invoke_stub_internal+68)\n"
648 " #31 pc 0046722f libartd.so (art_quick_invoke_static_stub+226)\n"
649 " #32 pc 000bf7bb libartd.so "
650 "(_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+882)\n"
651 " #33 pc 00247833 libartd.so "
652 "(_ZN3art11interpreter34ArtInterpreterToCompiledCodeBridgeEPNS_6ThreadEPNS_9ArtMethodEPNS_"
653 "11ShadowFrameEtPNS_6JValueE+382)\n"
654 " #34 pc 0022e935 libartd.so "
655 "(_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_"
656 "6JValueEb+244)\n"
657 " #35 pc 0022f71d libartd.so "
658 "(_ZN3art11interpreter30EnterInterpreterFromEntryPointEPNS_6ThreadERKNS_"
659 "20CodeItemDataAccessorEPNS_11ShadowFrameE+128)\n"
660 " #36 pc 00442865 libartd.so (artQuickToInterpreterBridge+796)\n"
661 " #37 pc 004666ff libartd.so (art_quick_to_interpreter_bridge+30)\n"
662 " #38 pc 0001139b anonymous:e2796000 (boolean Main.foo()+178)\n"
663 " #39 pc 00462175 libartd.so (art_quick_invoke_stub_internal+68)\n"
664 " #40 pc 00467129 libartd.so (art_quick_invoke_stub+228)\n"
665 " #41 pc 000bf7a9 libartd.so "
666 "(_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+864)\n"
667 " #42 pc 00247833 libartd.so "
668 "(_ZN3art11interpreter34ArtInterpreterToCompiledCodeBridgeEPNS_6ThreadEPNS_9ArtMethodEPNS_"
669 "11ShadowFrameEtPNS_6JValueE+382)\n"
670 " #43 pc 0022e935 libartd.so "
671 "(_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_"
672 "6JValueEb+244)\n"
673 " #44 pc 0022f71d libartd.so "
674 "(_ZN3art11interpreter30EnterInterpreterFromEntryPointEPNS_6ThreadERKNS_"
675 "20CodeItemDataAccessorEPNS_11ShadowFrameE+128)\n"
676 " #45 pc 00442865 libartd.so (artQuickToInterpreterBridge+796)\n"
677 " #46 pc 004666ff libartd.so (art_quick_to_interpreter_bridge+30)\n"
678 " #47 pc 00010aa7 anonymous:e2796000 (void Main.runPrimary()+70)\n"
679 " #48 pc 00462175 libartd.so (art_quick_invoke_stub_internal+68)\n"
680 " #49 pc 00467129 libartd.so (art_quick_invoke_stub+228)\n"
681 " #50 pc 000bf7a9 libartd.so "
682 "(_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+864)\n"
683 " #51 pc 00247833 libartd.so "
684 "(_ZN3art11interpreter34ArtInterpreterToCompiledCodeBridgeEPNS_6ThreadEPNS_9ArtMethodEPNS_"
685 "11ShadowFrameEtPNS_6JValueE+382)\n"
686 " #52 pc 0022e935 libartd.so "
687 "(_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_"
688 "6JValueEb+244)\n"
689 " #53 pc 0022f71d libartd.so "
690 "(_ZN3art11interpreter30EnterInterpreterFromEntryPointEPNS_6ThreadERKNS_"
691 "20CodeItemDataAccessorEPNS_11ShadowFrameE+128)\n"
692 " #54 pc 00442865 libartd.so (artQuickToInterpreterBridge+796)\n"
693 " #55 pc 004666ff libartd.so (art_quick_to_interpreter_bridge+30)\n"
694 " #56 pc 0000ba99 anonymous:e2796000 (void Main.main(java.lang.String[])+144)\n"
695 " #57 pc 00462175 libartd.so (art_quick_invoke_stub_internal+68)\n"
696 " #58 pc 0046722f libartd.so (art_quick_invoke_static_stub+226)\n"
697 " #59 pc 000bf7bb libartd.so "
698 "(_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+882)\n"
699 " #60 pc 00247833 libartd.so "
700 "(_ZN3art11interpreter34ArtInterpreterToCompiledCodeBridgeEPNS_6ThreadEPNS_9ArtMethodEPNS_"
701 "11ShadowFrameEtPNS_6JValueE+382)\n"
702 " #61 pc 0022e935 libartd.so "
703 "(_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_"
704 "6JValueEb+244)\n"
705 " #62 pc 0022f71d libartd.so "
706 "(_ZN3art11interpreter30EnterInterpreterFromEntryPointEPNS_6ThreadERKNS_"
707 "20CodeItemDataAccessorEPNS_11ShadowFrameE+128)\n"
708 " #63 pc 00442865 libartd.so (artQuickToInterpreterBridge+796)\n"
709 " #64 pc 004666ff libartd.so (art_quick_to_interpreter_bridge+30)\n"
710 " #65 pc 00462175 libartd.so (art_quick_invoke_stub_internal+68)\n"
711 " #66 pc 0046722f libartd.so (art_quick_invoke_static_stub+226)\n"
712 " #67 pc 000bf7bb libartd.so "
713 "(_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+882)\n"
714 " #68 pc 003b292d libartd.so "
715 "(_ZN3artL18InvokeWithArgArrayERKNS_33ScopedObjectAccessAlreadyRunnableEPNS_9ArtMethodEPNS_"
716 "8ArgArrayEPNS_6JValueEPKc+52)\n"
717 " #69 pc 003b26c3 libartd.so "
718 "(_ZN3art17InvokeWithVarArgsERKNS_33ScopedObjectAccessAlreadyRunnableEP8_jobjectP10_"
719 "jmethodIDSt9__va_list+210)\n"
720 " #70 pc 00308411 libartd.so "
721 "(_ZN3art3JNI21CallStaticVoidMethodVEP7_JNIEnvP7_jclassP10_jmethodIDSt9__va_list+76)\n"
722 " #71 pc 000e6a9f libartd.so "
723 "(_ZN3art8CheckJNI11CallMethodVEPKcP7_JNIEnvP8_jobjectP7_jclassP10_jmethodIDSt9__va_listNS_"
724 "9Primitive4TypeENS_10InvokeTypeE+1486)\n"
725 " #72 pc 000e19b9 libartd.so "
726 "(_ZN3art8CheckJNI21CallStaticVoidMethodVEP7_JNIEnvP7_jclassP10_jmethodIDSt9__va_list+40)\n"
727 " #73 pc 0000159f dalvikvm32 "
728 "(_ZN7_JNIEnv20CallStaticVoidMethodEP7_jclassP10_jmethodIDz+30)\n"
729 " #74 pc 00001349 dalvikvm32 (main+896)\n"
730 " #75 pc 000850c9 libc.so\n",
731 frame_info);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800732 EXPECT_EQ(0xdfe66a5eU, unwinder.frames()[0].pc);
733 EXPECT_EQ(0xff85d180U, unwinder.frames()[0].sp);
734 EXPECT_EQ(0xe044712dU, unwinder.frames()[1].pc);
735 EXPECT_EQ(0xff85d200U, unwinder.frames()[1].sp);
736 EXPECT_EQ(0xe27a7cb1U, unwinder.frames()[2].pc);
737 EXPECT_EQ(0xff85d290U, unwinder.frames()[2].sp);
738 EXPECT_EQ(0xed75c175U, unwinder.frames()[3].pc);
739 EXPECT_EQ(0xff85d2b0U, unwinder.frames()[3].sp);
740 EXPECT_EQ(0xed761129U, unwinder.frames()[4].pc);
741 EXPECT_EQ(0xff85d2e8U, unwinder.frames()[4].sp);
742 EXPECT_EQ(0xed3b97a9U, unwinder.frames()[5].pc);
743 EXPECT_EQ(0xff85d370U, unwinder.frames()[5].sp);
744 EXPECT_EQ(0xed541833U, unwinder.frames()[6].pc);
745 EXPECT_EQ(0xff85d3d8U, unwinder.frames()[6].sp);
746 EXPECT_EQ(0xed528935U, unwinder.frames()[7].pc);
747 EXPECT_EQ(0xff85d428U, unwinder.frames()[7].sp);
748 EXPECT_EQ(0xed52971dU, unwinder.frames()[8].pc);
749 EXPECT_EQ(0xff85d470U, unwinder.frames()[8].sp);
750 EXPECT_EQ(0xed73c865U, unwinder.frames()[9].pc);
751 EXPECT_EQ(0xff85d4b0U, unwinder.frames()[9].sp);
752 EXPECT_EQ(0xed7606ffU, unwinder.frames()[10].pc);
753 EXPECT_EQ(0xff85d5d0U, unwinder.frames()[10].sp);
754 EXPECT_EQ(0xe27a7c31U, unwinder.frames()[11].pc);
755 EXPECT_EQ(0xff85d640U, unwinder.frames()[11].sp);
756 EXPECT_EQ(0xed75c175U, unwinder.frames()[12].pc);
757 EXPECT_EQ(0xff85d660U, unwinder.frames()[12].sp);
758 EXPECT_EQ(0xed761129U, unwinder.frames()[13].pc);
759 EXPECT_EQ(0xff85d698U, unwinder.frames()[13].sp);
760 EXPECT_EQ(0xed3b97a9U, unwinder.frames()[14].pc);
761 EXPECT_EQ(0xff85d720U, unwinder.frames()[14].sp);
762 EXPECT_EQ(0xed541833U, unwinder.frames()[15].pc);
763 EXPECT_EQ(0xff85d788U, unwinder.frames()[15].sp);
764 EXPECT_EQ(0xed528935U, unwinder.frames()[16].pc);
765 EXPECT_EQ(0xff85d7d8U, unwinder.frames()[16].sp);
766 EXPECT_EQ(0xed52971dU, unwinder.frames()[17].pc);
767 EXPECT_EQ(0xff85d820U, unwinder.frames()[17].sp);
768 EXPECT_EQ(0xed73c865U, unwinder.frames()[18].pc);
769 EXPECT_EQ(0xff85d860U, unwinder.frames()[18].sp);
770 EXPECT_EQ(0xed7606ffU, unwinder.frames()[19].pc);
771 EXPECT_EQ(0xff85d970U, unwinder.frames()[19].sp);
772 EXPECT_EQ(0xe27a7b77U, unwinder.frames()[20].pc);
773 EXPECT_EQ(0xff85d9e0U, unwinder.frames()[20].sp);
774 EXPECT_EQ(0xed75c175U, unwinder.frames()[21].pc);
775 EXPECT_EQ(0xff85da10U, unwinder.frames()[21].sp);
776 EXPECT_EQ(0xed761129U, unwinder.frames()[22].pc);
777 EXPECT_EQ(0xff85da48U, unwinder.frames()[22].sp);
778 EXPECT_EQ(0xed3b97a9U, unwinder.frames()[23].pc);
779 EXPECT_EQ(0xff85dad0U, unwinder.frames()[23].sp);
780 EXPECT_EQ(0xed541833U, unwinder.frames()[24].pc);
781 EXPECT_EQ(0xff85db38U, unwinder.frames()[24].sp);
782 EXPECT_EQ(0xed528935U, unwinder.frames()[25].pc);
783 EXPECT_EQ(0xff85db88U, unwinder.frames()[25].sp);
784 EXPECT_EQ(0xed52971dU, unwinder.frames()[26].pc);
785 EXPECT_EQ(0xff85dbd0U, unwinder.frames()[26].sp);
786 EXPECT_EQ(0xed73c865U, unwinder.frames()[27].pc);
787 EXPECT_EQ(0xff85dc10U, unwinder.frames()[27].sp);
788 EXPECT_EQ(0xed7606ffU, unwinder.frames()[28].pc);
789 EXPECT_EQ(0xff85dd20U, unwinder.frames()[28].sp);
790 EXPECT_EQ(0xe27a7a29U, unwinder.frames()[29].pc);
791 EXPECT_EQ(0xff85dd90U, unwinder.frames()[29].sp);
792 EXPECT_EQ(0xed75c175U, unwinder.frames()[30].pc);
793 EXPECT_EQ(0xff85ddc0U, unwinder.frames()[30].sp);
794 EXPECT_EQ(0xed76122fU, unwinder.frames()[31].pc);
795 EXPECT_EQ(0xff85de08U, unwinder.frames()[31].sp);
796 EXPECT_EQ(0xed3b97bbU, unwinder.frames()[32].pc);
797 EXPECT_EQ(0xff85de90U, unwinder.frames()[32].sp);
798 EXPECT_EQ(0xed541833U, unwinder.frames()[33].pc);
799 EXPECT_EQ(0xff85def8U, unwinder.frames()[33].sp);
800 EXPECT_EQ(0xed528935U, unwinder.frames()[34].pc);
801 EXPECT_EQ(0xff85df48U, unwinder.frames()[34].sp);
802 EXPECT_EQ(0xed52971dU, unwinder.frames()[35].pc);
803 EXPECT_EQ(0xff85df90U, unwinder.frames()[35].sp);
804 EXPECT_EQ(0xed73c865U, unwinder.frames()[36].pc);
805 EXPECT_EQ(0xff85dfd0U, unwinder.frames()[36].sp);
806 EXPECT_EQ(0xed7606ffU, unwinder.frames()[37].pc);
807 EXPECT_EQ(0xff85e110U, unwinder.frames()[37].sp);
808 EXPECT_EQ(0xe27a739bU, unwinder.frames()[38].pc);
809 EXPECT_EQ(0xff85e180U, unwinder.frames()[38].sp);
810 EXPECT_EQ(0xed75c175U, unwinder.frames()[39].pc);
811 EXPECT_EQ(0xff85e1b0U, unwinder.frames()[39].sp);
812 EXPECT_EQ(0xed761129U, unwinder.frames()[40].pc);
813 EXPECT_EQ(0xff85e1e0U, unwinder.frames()[40].sp);
814 EXPECT_EQ(0xed3b97a9U, unwinder.frames()[41].pc);
815 EXPECT_EQ(0xff85e268U, unwinder.frames()[41].sp);
816 EXPECT_EQ(0xed541833U, unwinder.frames()[42].pc);
817 EXPECT_EQ(0xff85e2d0U, unwinder.frames()[42].sp);
818 EXPECT_EQ(0xed528935U, unwinder.frames()[43].pc);
819 EXPECT_EQ(0xff85e320U, unwinder.frames()[43].sp);
820 EXPECT_EQ(0xed52971dU, unwinder.frames()[44].pc);
821 EXPECT_EQ(0xff85e368U, unwinder.frames()[44].sp);
822 EXPECT_EQ(0xed73c865U, unwinder.frames()[45].pc);
823 EXPECT_EQ(0xff85e3a8U, unwinder.frames()[45].sp);
824 EXPECT_EQ(0xed7606ffU, unwinder.frames()[46].pc);
825 EXPECT_EQ(0xff85e4c0U, unwinder.frames()[46].sp);
826 EXPECT_EQ(0xe27a6aa7U, unwinder.frames()[47].pc);
827 EXPECT_EQ(0xff85e530U, unwinder.frames()[47].sp);
828 EXPECT_EQ(0xed75c175U, unwinder.frames()[48].pc);
829 EXPECT_EQ(0xff85e5a0U, unwinder.frames()[48].sp);
830 EXPECT_EQ(0xed761129U, unwinder.frames()[49].pc);
831 EXPECT_EQ(0xff85e5d8U, unwinder.frames()[49].sp);
832 EXPECT_EQ(0xed3b97a9U, unwinder.frames()[50].pc);
833 EXPECT_EQ(0xff85e660U, unwinder.frames()[50].sp);
834 EXPECT_EQ(0xed541833U, unwinder.frames()[51].pc);
835 EXPECT_EQ(0xff85e6c8U, unwinder.frames()[51].sp);
836 EXPECT_EQ(0xed528935U, unwinder.frames()[52].pc);
837 EXPECT_EQ(0xff85e718U, unwinder.frames()[52].sp);
838 EXPECT_EQ(0xed52971dU, unwinder.frames()[53].pc);
839 EXPECT_EQ(0xff85e760U, unwinder.frames()[53].sp);
840 EXPECT_EQ(0xed73c865U, unwinder.frames()[54].pc);
841 EXPECT_EQ(0xff85e7a0U, unwinder.frames()[54].sp);
842 EXPECT_EQ(0xed7606ffU, unwinder.frames()[55].pc);
843 EXPECT_EQ(0xff85e8f0U, unwinder.frames()[55].sp);
844 EXPECT_EQ(0xe27a1a99U, unwinder.frames()[56].pc);
845 EXPECT_EQ(0xff85e960U, unwinder.frames()[56].sp);
846 EXPECT_EQ(0xed75c175U, unwinder.frames()[57].pc);
847 EXPECT_EQ(0xff85e990U, unwinder.frames()[57].sp);
848 EXPECT_EQ(0xed76122fU, unwinder.frames()[58].pc);
849 EXPECT_EQ(0xff85e9c8U, unwinder.frames()[58].sp);
850 EXPECT_EQ(0xed3b97bbU, unwinder.frames()[59].pc);
851 EXPECT_EQ(0xff85ea50U, unwinder.frames()[59].sp);
852 EXPECT_EQ(0xed541833U, unwinder.frames()[60].pc);
853 EXPECT_EQ(0xff85eab8U, unwinder.frames()[60].sp);
854 EXPECT_EQ(0xed528935U, unwinder.frames()[61].pc);
855 EXPECT_EQ(0xff85eb08U, unwinder.frames()[61].sp);
856 EXPECT_EQ(0xed52971dU, unwinder.frames()[62].pc);
857 EXPECT_EQ(0xff85eb50U, unwinder.frames()[62].sp);
858 EXPECT_EQ(0xed73c865U, unwinder.frames()[63].pc);
859 EXPECT_EQ(0xff85eb90U, unwinder.frames()[63].sp);
860 EXPECT_EQ(0xed7606ffU, unwinder.frames()[64].pc);
861 EXPECT_EQ(0xff85ec90U, unwinder.frames()[64].sp);
862 EXPECT_EQ(0xed75c175U, unwinder.frames()[65].pc);
863 EXPECT_EQ(0xff85ed00U, unwinder.frames()[65].sp);
864 EXPECT_EQ(0xed76122fU, unwinder.frames()[66].pc);
865 EXPECT_EQ(0xff85ed38U, unwinder.frames()[66].sp);
866 EXPECT_EQ(0xed3b97bbU, unwinder.frames()[67].pc);
867 EXPECT_EQ(0xff85edc0U, unwinder.frames()[67].sp);
868 EXPECT_EQ(0xed6ac92dU, unwinder.frames()[68].pc);
869 EXPECT_EQ(0xff85ee28U, unwinder.frames()[68].sp);
870 EXPECT_EQ(0xed6ac6c3U, unwinder.frames()[69].pc);
871 EXPECT_EQ(0xff85eeb8U, unwinder.frames()[69].sp);
872 EXPECT_EQ(0xed602411U, unwinder.frames()[70].pc);
873 EXPECT_EQ(0xff85ef48U, unwinder.frames()[70].sp);
874 EXPECT_EQ(0xed3e0a9fU, unwinder.frames()[71].pc);
875 EXPECT_EQ(0xff85ef90U, unwinder.frames()[71].sp);
876 EXPECT_EQ(0xed3db9b9U, unwinder.frames()[72].pc);
877 EXPECT_EQ(0xff85f008U, unwinder.frames()[72].sp);
878 EXPECT_EQ(0xab0d459fU, unwinder.frames()[73].pc);
879 EXPECT_EQ(0xff85f038U, unwinder.frames()[73].sp);
880 EXPECT_EQ(0xab0d4349U, unwinder.frames()[74].pc);
881 EXPECT_EQ(0xff85f050U, unwinder.frames()[74].sp);
882 EXPECT_EQ(0xedb0d0c9U, unwinder.frames()[75].pc);
883 EXPECT_EQ(0xff85f0c0U, unwinder.frames()[75].sp);
Christopher Ferrised37aca2018-01-12 15:53:19 -0800884}
885
Christopher Ferris1a141a02018-01-24 08:52:47 -0800886// The eh_frame_hdr data is present but set to zero fdes. This should
887// fallback to iterating over the cies/fdes and ignore the eh_frame_hdr.
888// No .gnu_debugdata section in the elf file, so no symbols.
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800889TEST_F(UnwindOfflineTest, bad_eh_frame_hdr_arm64) {
Christopher Ferrisd299a7a2018-05-17 18:37:38 -0700890 ASSERT_NO_FATAL_FAILURE(Init("bad_eh_frame_hdr_arm64/", ARCH_ARM64));
Christopher Ferris1a141a02018-01-24 08:52:47 -0800891
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800892 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
Christopher Ferris1a141a02018-01-24 08:52:47 -0800893 unwinder.Unwind();
Christopher Ferris1a141a02018-01-24 08:52:47 -0800894
895 std::string frame_info(DumpFrames(unwinder));
896 ASSERT_EQ(5U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
897 EXPECT_EQ(
898 " #00 pc 0000000000000550 waiter64\n"
899 " #01 pc 0000000000000568 waiter64\n"
900 " #02 pc 000000000000057c waiter64\n"
901 " #03 pc 0000000000000590 waiter64\n"
902 " #04 pc 00000000000a8e98 libc.so (__libc_init+88)\n",
903 frame_info);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800904 EXPECT_EQ(0x60a9fdf550U, unwinder.frames()[0].pc);
905 EXPECT_EQ(0x7fdd141990U, unwinder.frames()[0].sp);
906 EXPECT_EQ(0x60a9fdf568U, unwinder.frames()[1].pc);
907 EXPECT_EQ(0x7fdd1419a0U, unwinder.frames()[1].sp);
908 EXPECT_EQ(0x60a9fdf57cU, unwinder.frames()[2].pc);
909 EXPECT_EQ(0x7fdd1419b0U, unwinder.frames()[2].sp);
910 EXPECT_EQ(0x60a9fdf590U, unwinder.frames()[3].pc);
911 EXPECT_EQ(0x7fdd1419c0U, unwinder.frames()[3].sp);
912 EXPECT_EQ(0x7542d68e98U, unwinder.frames()[4].pc);
913 EXPECT_EQ(0x7fdd1419d0U, unwinder.frames()[4].sp);
Christopher Ferris1a141a02018-01-24 08:52:47 -0800914}
915
916// The elf has bad eh_frame unwind information for the pcs. If eh_frame
917// is used first, the unwind will not match the expected output.
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800918TEST_F(UnwindOfflineTest, debug_frame_first_x86) {
Christopher Ferrisd299a7a2018-05-17 18:37:38 -0700919 ASSERT_NO_FATAL_FAILURE(Init("debug_frame_first_x86/", ARCH_X86));
Christopher Ferris1a141a02018-01-24 08:52:47 -0800920
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800921 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
Christopher Ferris1a141a02018-01-24 08:52:47 -0800922 unwinder.Unwind();
Christopher Ferris1a141a02018-01-24 08:52:47 -0800923
924 std::string frame_info(DumpFrames(unwinder));
925 ASSERT_EQ(5U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
926 EXPECT_EQ(
927 " #00 pc 00000685 waiter (call_level3+53)\n"
928 " #01 pc 000006b7 waiter (call_level2+23)\n"
929 " #02 pc 000006d7 waiter (call_level1+23)\n"
930 " #03 pc 000006f7 waiter (main+23)\n"
931 " #04 pc 00018275 libc.so\n",
932 frame_info);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800933 EXPECT_EQ(0x56598685U, unwinder.frames()[0].pc);
934 EXPECT_EQ(0xffcf9e38U, unwinder.frames()[0].sp);
935 EXPECT_EQ(0x565986b7U, unwinder.frames()[1].pc);
936 EXPECT_EQ(0xffcf9e50U, unwinder.frames()[1].sp);
937 EXPECT_EQ(0x565986d7U, unwinder.frames()[2].pc);
938 EXPECT_EQ(0xffcf9e60U, unwinder.frames()[2].sp);
939 EXPECT_EQ(0x565986f7U, unwinder.frames()[3].pc);
940 EXPECT_EQ(0xffcf9e70U, unwinder.frames()[3].sp);
941 EXPECT_EQ(0xf744a275U, unwinder.frames()[4].pc);
942 EXPECT_EQ(0xffcf9e80U, unwinder.frames()[4].sp);
Christopher Ferris1a141a02018-01-24 08:52:47 -0800943}
944
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800945// Make sure that a pc that is at the beginning of an fde unwinds correctly.
946TEST_F(UnwindOfflineTest, eh_frame_hdr_begin_x86_64) {
Christopher Ferrisd299a7a2018-05-17 18:37:38 -0700947 ASSERT_NO_FATAL_FAILURE(Init("eh_frame_hdr_begin_x86_64/", ARCH_X86_64));
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800948
949 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
950 unwinder.Unwind();
951
952 std::string frame_info(DumpFrames(unwinder));
953 ASSERT_EQ(5U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
954 EXPECT_EQ(
955 " #00 pc 0000000000000a80 unwind_test64 (calling3)\n"
956 " #01 pc 0000000000000dd9 unwind_test64 (calling2+633)\n"
957 " #02 pc 000000000000121e unwind_test64 (calling1+638)\n"
958 " #03 pc 00000000000013ed unwind_test64 (main+13)\n"
959 " #04 pc 00000000000202b0 libc.so\n",
960 frame_info);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800961 EXPECT_EQ(0x561550b17a80U, unwinder.frames()[0].pc);
962 EXPECT_EQ(0x7ffcc8596ce8U, unwinder.frames()[0].sp);
963 EXPECT_EQ(0x561550b17dd9U, unwinder.frames()[1].pc);
964 EXPECT_EQ(0x7ffcc8596cf0U, unwinder.frames()[1].sp);
965 EXPECT_EQ(0x561550b1821eU, unwinder.frames()[2].pc);
966 EXPECT_EQ(0x7ffcc8596f40U, unwinder.frames()[2].sp);
967 EXPECT_EQ(0x561550b183edU, unwinder.frames()[3].pc);
968 EXPECT_EQ(0x7ffcc8597190U, unwinder.frames()[3].sp);
969 EXPECT_EQ(0x7f4de62162b0U, unwinder.frames()[4].pc);
970 EXPECT_EQ(0x7ffcc85971a0U, unwinder.frames()[4].sp);
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800971}
972
Yabin Cui414df3e2018-03-14 18:16:22 -0700973TEST_F(UnwindOfflineTest, art_quick_osr_stub_arm) {
Christopher Ferrisd299a7a2018-05-17 18:37:38 -0700974 ASSERT_NO_FATAL_FAILURE(Init("art_quick_osr_stub_arm/", ARCH_ARM));
Yabin Cui414df3e2018-03-14 18:16:22 -0700975
976 MemoryOfflineParts* memory = new MemoryOfflineParts;
977 AddMemory(dir_ + "descriptor.data", memory);
978 AddMemory(dir_ + "stack.data", memory);
979 for (size_t i = 0; i < 2; i++) {
980 AddMemory(dir_ + "entry" + std::to_string(i) + ".data", memory);
981 AddMemory(dir_ + "jit" + std::to_string(i) + ".data", memory);
982 }
983 process_memory_.reset(memory);
984
985 JitDebug jit_debug(process_memory_);
986 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
987 unwinder.SetJitDebug(&jit_debug, regs_->Arch());
988 unwinder.Unwind();
989
990 std::string frame_info(DumpFrames(unwinder));
991 ASSERT_EQ(25U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
992 EXPECT_EQ(
993 " #00 pc 0000c788 <anonymous:d0250000> "
994 "(com.example.simpleperf.simpleperfexamplewithnative.MixActivity.access$000)\n"
995 " #01 pc 0000cdd5 <anonymous:d0250000> "
996 "(com.example.simpleperf.simpleperfexamplewithnative.MixActivity$1.run+60)\n"
997 " #02 pc 004135bb libart.so (art_quick_osr_stub+42)\n"
998 " #03 pc 002657a5 libart.so "
999 "(_ZN3art3jit3Jit25MaybeDoOnStackReplacementEPNS_6ThreadEPNS_9ArtMethodEjiPNS_6JValueE+876)\n"
1000 " #04 pc 004021a7 libart.so (MterpMaybeDoOnStackReplacement+86)\n"
1001 " #05 pc 00412474 libart.so (ExecuteMterpImpl+66164)\n"
1002 " #06 pc cd8365b0 <unknown>\n" // symbol in dex file
1003 " #07 pc 001d7f1b libart.so "
1004 "(_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_"
1005 "6JValueEb+374)\n"
1006 " #08 pc 001dc593 libart.so "
1007 "(_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadERKNS_"
1008 "20CodeItemDataAccessorEPNS_11ShadowFrameEPNS_6JValueE+154)\n"
1009 " #09 pc 001f4d01 libart.so "
1010 "(_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_"
1011 "11InstructionEtPNS_6JValueE+732)\n"
1012 " #10 pc 003fe427 libart.so (MterpInvokeInterface+1354)\n"
1013 " #11 pc 00405b94 libart.so (ExecuteMterpImpl+14740)\n"
1014 " #12 pc 7004873e <unknown>\n" // symbol in dex file
1015 " #13 pc 001d7f1b libart.so "
1016 "(_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_"
1017 "6JValueEb+374)\n"
1018 " #14 pc 001dc4d5 libart.so "
1019 "(_ZN3art11interpreter30EnterInterpreterFromEntryPointEPNS_6ThreadERKNS_"
1020 "20CodeItemDataAccessorEPNS_11ShadowFrameE+92)\n"
1021 " #15 pc 003f25ab libart.so (artQuickToInterpreterBridge+970)\n"
1022 " #16 pc 00417aff libart.so (art_quick_to_interpreter_bridge+30)\n"
1023 " #17 pc 00413575 libart.so (art_quick_invoke_stub_internal+68)\n"
1024 " #18 pc 00418531 libart.so (art_quick_invoke_stub+236)\n"
1025 " #19 pc 000b468d libart.so (_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+136)\n"
1026 " #20 pc 00362f49 libart.so "
1027 "(_ZN3art12_GLOBAL__N_118InvokeWithArgArrayERKNS_33ScopedObjectAccessAlreadyRunnableEPNS_"
1028 "9ArtMethodEPNS0_8ArgArrayEPNS_6JValueEPKc+52)\n"
1029 " #21 pc 00363cd9 libart.so "
1030 "(_ZN3art35InvokeVirtualOrInterfaceWithJValuesERKNS_33ScopedObjectAccessAlreadyRunnableEP8_"
1031 "jobjectP10_jmethodIDP6jvalue+332)\n"
1032 " #22 pc 003851dd libart.so (_ZN3art6Thread14CreateCallbackEPv+868)\n"
1033 " #23 pc 00062925 libc.so (_ZL15__pthread_startPv+22)\n"
1034 " #24 pc 0001de39 libc.so (__start_thread+24)\n",
1035 frame_info);
1036 EXPECT_EQ(0xd025c788U, unwinder.frames()[0].pc);
1037 EXPECT_EQ(0xcd4ff140U, unwinder.frames()[0].sp);
1038 EXPECT_EQ(0xd025cdd5U, unwinder.frames()[1].pc);
1039 EXPECT_EQ(0xcd4ff140U, unwinder.frames()[1].sp);
1040 EXPECT_EQ(0xe4a755bbU, unwinder.frames()[2].pc);
1041 EXPECT_EQ(0xcd4ff160U, unwinder.frames()[2].sp);
1042 EXPECT_EQ(0xe48c77a5U, unwinder.frames()[3].pc);
1043 EXPECT_EQ(0xcd4ff190U, unwinder.frames()[3].sp);
1044 EXPECT_EQ(0xe4a641a7U, unwinder.frames()[4].pc);
1045 EXPECT_EQ(0xcd4ff298U, unwinder.frames()[4].sp);
1046 EXPECT_EQ(0xe4a74474U, unwinder.frames()[5].pc);
1047 EXPECT_EQ(0xcd4ff2b8U, unwinder.frames()[5].sp);
1048 EXPECT_EQ(0xcd8365b0U, unwinder.frames()[6].pc);
1049 EXPECT_EQ(0xcd4ff2e0U, unwinder.frames()[6].sp);
1050 EXPECT_EQ(0xe4839f1bU, unwinder.frames()[7].pc);
1051 EXPECT_EQ(0xcd4ff2e0U, unwinder.frames()[7].sp);
1052 EXPECT_EQ(0xe483e593U, unwinder.frames()[8].pc);
1053 EXPECT_EQ(0xcd4ff330U, unwinder.frames()[8].sp);
1054 EXPECT_EQ(0xe4856d01U, unwinder.frames()[9].pc);
1055 EXPECT_EQ(0xcd4ff380U, unwinder.frames()[9].sp);
1056 EXPECT_EQ(0xe4a60427U, unwinder.frames()[10].pc);
1057 EXPECT_EQ(0xcd4ff430U, unwinder.frames()[10].sp);
1058 EXPECT_EQ(0xe4a67b94U, unwinder.frames()[11].pc);
1059 EXPECT_EQ(0xcd4ff498U, unwinder.frames()[11].sp);
1060 EXPECT_EQ(0x7004873eU, unwinder.frames()[12].pc);
1061 EXPECT_EQ(0xcd4ff4c0U, unwinder.frames()[12].sp);
1062 EXPECT_EQ(0xe4839f1bU, unwinder.frames()[13].pc);
1063 EXPECT_EQ(0xcd4ff4c0U, unwinder.frames()[13].sp);
1064 EXPECT_EQ(0xe483e4d5U, unwinder.frames()[14].pc);
1065 EXPECT_EQ(0xcd4ff510U, unwinder.frames()[14].sp);
1066 EXPECT_EQ(0xe4a545abU, unwinder.frames()[15].pc);
1067 EXPECT_EQ(0xcd4ff538U, unwinder.frames()[15].sp);
1068 EXPECT_EQ(0xe4a79affU, unwinder.frames()[16].pc);
1069 EXPECT_EQ(0xcd4ff640U, unwinder.frames()[16].sp);
1070 EXPECT_EQ(0xe4a75575U, unwinder.frames()[17].pc);
1071 EXPECT_EQ(0xcd4ff6b0U, unwinder.frames()[17].sp);
1072 EXPECT_EQ(0xe4a7a531U, unwinder.frames()[18].pc);
1073 EXPECT_EQ(0xcd4ff6e8U, unwinder.frames()[18].sp);
1074 EXPECT_EQ(0xe471668dU, unwinder.frames()[19].pc);
1075 EXPECT_EQ(0xcd4ff770U, unwinder.frames()[19].sp);
1076 EXPECT_EQ(0xe49c4f49U, unwinder.frames()[20].pc);
1077 EXPECT_EQ(0xcd4ff7c8U, unwinder.frames()[20].sp);
1078 EXPECT_EQ(0xe49c5cd9U, unwinder.frames()[21].pc);
1079 EXPECT_EQ(0xcd4ff850U, unwinder.frames()[21].sp);
1080 EXPECT_EQ(0xe49e71ddU, unwinder.frames()[22].pc);
1081 EXPECT_EQ(0xcd4ff8e8U, unwinder.frames()[22].sp);
1082 EXPECT_EQ(0xe7df3925U, unwinder.frames()[23].pc);
1083 EXPECT_EQ(0xcd4ff958U, unwinder.frames()[23].sp);
1084 EXPECT_EQ(0xe7daee39U, unwinder.frames()[24].pc);
1085 EXPECT_EQ(0xcd4ff960U, unwinder.frames()[24].sp);
1086}
1087
Christopher Ferrisd299a7a2018-05-17 18:37:38 -07001088TEST_F(UnwindOfflineTest, offset_arm) {
1089 ASSERT_NO_FATAL_FAILURE(Init("offset_arm/", ARCH_ARM));
1090
1091 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
1092 unwinder.Unwind();
1093
1094 std::string frame_info(DumpFrames(unwinder));
1095 ASSERT_EQ(19U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
1096 EXPECT_EQ(
1097 " #00 pc 0032bfa0 (offset 0x42000) libunwindstack_test (SignalInnerFunction+40)\n"
1098 " #01 pc 0032bfeb (offset 0x42000) libunwindstack_test (SignalMiddleFunction+2)\n"
1099 " #02 pc 0032bff3 (offset 0x42000) libunwindstack_test (SignalOuterFunction+2)\n"
1100 " #03 pc 0032fed3 (offset 0x42000) libunwindstack_test "
1101 "(_ZN11unwindstackL19SignalCallerHandlerEiP7siginfoPv+26)\n"
1102 " #04 pc 00026528 (offset 0x25000) libc.so\n"
1103 " #05 pc 00000000 <unknown>\n"
1104 " #06 pc 0032c2d9 (offset 0x42000) libunwindstack_test (InnerFunction+736)\n"
1105 " #07 pc 0032cc4f (offset 0x42000) libunwindstack_test (MiddleFunction+42)\n"
1106 " #08 pc 0032cc81 (offset 0x42000) libunwindstack_test (OuterFunction+42)\n"
1107 " #09 pc 0032e547 (offset 0x42000) libunwindstack_test "
1108 "(_ZN11unwindstackL19RemoteThroughSignalEij+270)\n"
1109 " #10 pc 0032ed99 (offset 0x42000) libunwindstack_test "
1110 "(_ZN11unwindstack55UnwindTest_remote_through_signal_with_invalid_func_Test8TestBodyEv+16)\n"
1111 " #11 pc 00354453 (offset 0x42000) libunwindstack_test (_ZN7testing4Test3RunEv+154)\n"
1112 " #12 pc 00354de7 (offset 0x42000) libunwindstack_test (_ZN7testing8TestInfo3RunEv+194)\n"
1113 " #13 pc 00355105 (offset 0x42000) libunwindstack_test (_ZN7testing8TestCase3RunEv+180)\n"
1114 " #14 pc 0035a215 (offset 0x42000) libunwindstack_test "
1115 "(_ZN7testing8internal12UnitTestImpl11RunAllTestsEv+664)\n"
1116 " #15 pc 00359f4f (offset 0x42000) libunwindstack_test (_ZN7testing8UnitTest3RunEv+110)\n"
1117 " #16 pc 0034d3db (offset 0x42000) libunwindstack_test (main+38)\n"
1118 " #17 pc 00092c0d (offset 0x25000) libc.so (__libc_init+48)\n"
1119 " #18 pc 0004202f (offset 0x42000) libunwindstack_test (_start_main+38)\n",
1120 frame_info);
1121
1122 EXPECT_EQ(0x2e55fa0U, unwinder.frames()[0].pc);
1123 EXPECT_EQ(0xf43d2cccU, unwinder.frames()[0].sp);
1124 EXPECT_EQ(0x2e55febU, unwinder.frames()[1].pc);
1125 EXPECT_EQ(0xf43d2ce0U, unwinder.frames()[1].sp);
1126 EXPECT_EQ(0x2e55ff3U, unwinder.frames()[2].pc);
1127 EXPECT_EQ(0xf43d2ce8U, unwinder.frames()[2].sp);
1128 EXPECT_EQ(0x2e59ed3U, unwinder.frames()[3].pc);
1129 EXPECT_EQ(0xf43d2cf0U, unwinder.frames()[3].sp);
1130 EXPECT_EQ(0xf4136528U, unwinder.frames()[4].pc);
1131 EXPECT_EQ(0xf43d2d10U, unwinder.frames()[4].sp);
1132 EXPECT_EQ(0U, unwinder.frames()[5].pc);
1133 EXPECT_EQ(0xffcc0ee0U, unwinder.frames()[5].sp);
1134 EXPECT_EQ(0x2e562d9U, unwinder.frames()[6].pc);
1135 EXPECT_EQ(0xffcc0ee0U, unwinder.frames()[6].sp);
1136 EXPECT_EQ(0x2e56c4fU, unwinder.frames()[7].pc);
1137 EXPECT_EQ(0xffcc1060U, unwinder.frames()[7].sp);
1138 EXPECT_EQ(0x2e56c81U, unwinder.frames()[8].pc);
1139 EXPECT_EQ(0xffcc1078U, unwinder.frames()[8].sp);
1140 EXPECT_EQ(0x2e58547U, unwinder.frames()[9].pc);
1141 EXPECT_EQ(0xffcc1090U, unwinder.frames()[9].sp);
1142 EXPECT_EQ(0x2e58d99U, unwinder.frames()[10].pc);
1143 EXPECT_EQ(0xffcc1438U, unwinder.frames()[10].sp);
1144 EXPECT_EQ(0x2e7e453U, unwinder.frames()[11].pc);
1145 EXPECT_EQ(0xffcc1448U, unwinder.frames()[11].sp);
1146 EXPECT_EQ(0x2e7ede7U, unwinder.frames()[12].pc);
1147 EXPECT_EQ(0xffcc1458U, unwinder.frames()[12].sp);
1148 EXPECT_EQ(0x2e7f105U, unwinder.frames()[13].pc);
1149 EXPECT_EQ(0xffcc1490U, unwinder.frames()[13].sp);
1150 EXPECT_EQ(0x2e84215U, unwinder.frames()[14].pc);
1151 EXPECT_EQ(0xffcc14c0U, unwinder.frames()[14].sp);
1152 EXPECT_EQ(0x2e83f4fU, unwinder.frames()[15].pc);
1153 EXPECT_EQ(0xffcc1510U, unwinder.frames()[15].sp);
1154 EXPECT_EQ(0x2e773dbU, unwinder.frames()[16].pc);
1155 EXPECT_EQ(0xffcc1528U, unwinder.frames()[16].sp);
1156 EXPECT_EQ(0xf41a2c0dU, unwinder.frames()[17].pc);
1157 EXPECT_EQ(0xffcc1540U, unwinder.frames()[17].sp);
1158 EXPECT_EQ(0x2b6c02fU, unwinder.frames()[18].pc);
1159 EXPECT_EQ(0xffcc1558U, unwinder.frames()[18].sp);
1160}
1161
Christopher Ferrisc3d79f72017-11-28 19:14:54 -08001162} // namespace unwindstack