blob: 655579e84e90fa62dfa6f386f84cf9f830e8f616 [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>
Yabin Cuid5b22c52018-02-22 17:11:31 -080021#include <sys/mman.h>
Christopher Ferrisc3d79f72017-11-28 19:14:54 -080022#include <unistd.h>
23
24#include <gtest/gtest.h>
25
26#include <string>
Christopher Ferrise37e2d02018-02-09 15:57:39 -080027#include <unordered_map>
Christopher Ferrisc3d79f72017-11-28 19:14:54 -080028#include <vector>
29
Christopher Ferrise37e2d02018-02-09 15:57:39 -080030#include <android-base/file.h>
31
Christopher Ferris150db122017-12-20 18:49:01 -080032#include <unwindstack/JitDebug.h>
Christopher Ferris53914162018-02-08 19:27:47 -080033#include <unwindstack/MachineArm.h>
34#include <unwindstack/MachineArm64.h>
35#include <unwindstack/MachineX86.h>
Christopher Ferrise37e2d02018-02-09 15:57:39 -080036#include <unwindstack/MachineX86_64.h>
Christopher Ferrisc3d79f72017-11-28 19:14:54 -080037#include <unwindstack/Maps.h>
38#include <unwindstack/Memory.h>
Christopher Ferrisd06001d2017-11-30 18:56:01 -080039#include <unwindstack/RegsArm.h>
40#include <unwindstack/RegsArm64.h>
Christopher Ferris150db122017-12-20 18:49:01 -080041#include <unwindstack/RegsX86.h>
Christopher Ferrise37e2d02018-02-09 15:57:39 -080042#include <unwindstack/RegsX86_64.h>
Christopher Ferrisc3d79f72017-11-28 19:14:54 -080043#include <unwindstack/Unwinder.h>
44
Christopher Ferrisc3d79f72017-11-28 19:14:54 -080045#include "ElfTestUtils.h"
Christopher Ferrise1f7a632019-01-24 12:22:03 -080046#include "TestUtils.h"
Christopher Ferrisc3d79f72017-11-28 19:14:54 -080047
48namespace unwindstack {
49
Christopher Ferris239425b2018-05-17 18:37:38 -070050static void AddMemory(std::string file_name, MemoryOfflineParts* parts) {
51 MemoryOffline* memory = new MemoryOffline;
52 ASSERT_TRUE(memory->Init(file_name.c_str(), 0));
53 parts->Add(memory);
54}
55
Christopher Ferrise37e2d02018-02-09 15:57:39 -080056class UnwindOfflineTest : public ::testing::Test {
57 protected:
58 void TearDown() override {
59 if (cwd_ != nullptr) {
60 ASSERT_EQ(0, chdir(cwd_));
61 }
62 free(cwd_);
63 }
64
65 void Init(const char* file_dir, ArchEnum arch) {
66 dir_ = TestGetFileDirectory() + "offline/" + file_dir;
67
68 std::string data;
69 ASSERT_TRUE(android::base::ReadFileToString((dir_ + "maps.txt"), &data));
70
71 maps_.reset(new BufferMaps(data.c_str()));
72 ASSERT_TRUE(maps_->Parse());
73
Christopher Ferris239425b2018-05-17 18:37:38 -070074 std::string stack_name(dir_ + "stack.data");
75 struct stat st;
76 if (stat(stack_name.c_str(), &st) == 0 && S_ISREG(st.st_mode)) {
77 std::unique_ptr<MemoryOffline> stack_memory(new MemoryOffline);
78 ASSERT_TRUE(stack_memory->Init((dir_ + "stack.data").c_str(), 0));
79 process_memory_.reset(stack_memory.release());
80 } else {
81 std::unique_ptr<MemoryOfflineParts> stack_memory(new MemoryOfflineParts);
82 for (size_t i = 0;; i++) {
83 stack_name = dir_ + "stack" + std::to_string(i) + ".data";
84 if (stat(stack_name.c_str(), &st) == -1 || !S_ISREG(st.st_mode)) {
85 ASSERT_TRUE(i != 0) << "No stack data files found.";
86 break;
87 }
88 AddMemory(stack_name, stack_memory.get());
89 }
90 process_memory_.reset(stack_memory.release());
91 }
Christopher Ferrise37e2d02018-02-09 15:57:39 -080092
93 switch (arch) {
94 case ARCH_ARM: {
95 RegsArm* regs = new RegsArm;
96 regs_.reset(regs);
97 ReadRegs<uint32_t>(regs, arm_regs_);
98 break;
99 }
100 case ARCH_ARM64: {
101 RegsArm64* regs = new RegsArm64;
102 regs_.reset(regs);
103 ReadRegs<uint64_t>(regs, arm64_regs_);
104 break;
105 }
106 case ARCH_X86: {
107 RegsX86* regs = new RegsX86;
108 regs_.reset(regs);
109 ReadRegs<uint32_t>(regs, x86_regs_);
110 break;
111 }
112 case ARCH_X86_64: {
113 RegsX86_64* regs = new RegsX86_64;
114 regs_.reset(regs);
115 ReadRegs<uint64_t>(regs, x86_64_regs_);
116 break;
117 }
118 default:
119 ASSERT_TRUE(false) << "Unknown arch " << std::to_string(arch);
120 }
121 cwd_ = getcwd(nullptr, 0);
122 // Make dir_ an absolute directory.
123 if (dir_.empty() || dir_[0] != '/') {
124 dir_ = std::string(cwd_) + '/' + dir_;
125 }
126 ASSERT_EQ(0, chdir(dir_.c_str()));
127 }
128
129 template <typename AddressType>
130 void ReadRegs(RegsImpl<AddressType>* regs,
131 const std::unordered_map<std::string, uint32_t>& name_to_reg) {
132 FILE* fp = fopen((dir_ + "regs.txt").c_str(), "r");
133 ASSERT_TRUE(fp != nullptr);
134 while (!feof(fp)) {
135 uint64_t value;
136 char reg_name[100];
137 ASSERT_EQ(2, fscanf(fp, "%s %" SCNx64 "\n", reg_name, &value));
138 std::string name(reg_name);
139 if (!name.empty()) {
140 // Remove the : from the end.
141 name.resize(name.size() - 1);
142 }
143 auto entry = name_to_reg.find(name);
144 ASSERT_TRUE(entry != name_to_reg.end()) << "Unknown register named " << name;
145 (*regs)[entry->second] = value;
146 }
147 fclose(fp);
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800148 }
149
150 static std::unordered_map<std::string, uint32_t> arm_regs_;
151 static std::unordered_map<std::string, uint32_t> arm64_regs_;
152 static std::unordered_map<std::string, uint32_t> x86_regs_;
153 static std::unordered_map<std::string, uint32_t> x86_64_regs_;
154
155 char* cwd_ = nullptr;
156 std::string dir_;
157 std::unique_ptr<Regs> regs_;
158 std::unique_ptr<Maps> maps_;
159 std::shared_ptr<Memory> process_memory_;
160};
161
162std::unordered_map<std::string, uint32_t> UnwindOfflineTest::arm_regs_ = {
163 {"r0", ARM_REG_R0}, {"r1", ARM_REG_R1}, {"r2", ARM_REG_R2}, {"r3", ARM_REG_R3},
164 {"r4", ARM_REG_R4}, {"r5", ARM_REG_R5}, {"r6", ARM_REG_R6}, {"r7", ARM_REG_R7},
165 {"r8", ARM_REG_R8}, {"r9", ARM_REG_R9}, {"r10", ARM_REG_R10}, {"r11", ARM_REG_R11},
166 {"ip", ARM_REG_R12}, {"sp", ARM_REG_SP}, {"lr", ARM_REG_LR}, {"pc", ARM_REG_PC},
167};
168
169std::unordered_map<std::string, uint32_t> UnwindOfflineTest::arm64_regs_ = {
170 {"x0", ARM64_REG_R0}, {"x1", ARM64_REG_R1}, {"x2", ARM64_REG_R2}, {"x3", ARM64_REG_R3},
171 {"x4", ARM64_REG_R4}, {"x5", ARM64_REG_R5}, {"x6", ARM64_REG_R6}, {"x7", ARM64_REG_R7},
172 {"x8", ARM64_REG_R8}, {"x9", ARM64_REG_R9}, {"x10", ARM64_REG_R10}, {"x11", ARM64_REG_R11},
173 {"x12", ARM64_REG_R12}, {"x13", ARM64_REG_R13}, {"x14", ARM64_REG_R14}, {"x15", ARM64_REG_R15},
174 {"x16", ARM64_REG_R16}, {"x17", ARM64_REG_R17}, {"x18", ARM64_REG_R18}, {"x19", ARM64_REG_R19},
175 {"x20", ARM64_REG_R20}, {"x21", ARM64_REG_R21}, {"x22", ARM64_REG_R22}, {"x23", ARM64_REG_R23},
176 {"x24", ARM64_REG_R24}, {"x25", ARM64_REG_R25}, {"x26", ARM64_REG_R26}, {"x27", ARM64_REG_R27},
177 {"x28", ARM64_REG_R28}, {"x29", ARM64_REG_R29}, {"sp", ARM64_REG_SP}, {"lr", ARM64_REG_LR},
178 {"pc", ARM64_REG_PC},
179};
180
181std::unordered_map<std::string, uint32_t> UnwindOfflineTest::x86_regs_ = {
182 {"eax", X86_REG_EAX}, {"ebx", X86_REG_EBX}, {"ecx", X86_REG_ECX},
183 {"edx", X86_REG_EDX}, {"ebp", X86_REG_EBP}, {"edi", X86_REG_EDI},
184 {"esi", X86_REG_ESI}, {"esp", X86_REG_ESP}, {"eip", X86_REG_EIP},
185};
186
187std::unordered_map<std::string, uint32_t> UnwindOfflineTest::x86_64_regs_ = {
188 {"rax", X86_64_REG_RAX}, {"rbx", X86_64_REG_RBX}, {"rcx", X86_64_REG_RCX},
189 {"rdx", X86_64_REG_RDX}, {"r8", X86_64_REG_R8}, {"r9", X86_64_REG_R9},
190 {"r10", X86_64_REG_R10}, {"r11", X86_64_REG_R11}, {"r12", X86_64_REG_R12},
191 {"r13", X86_64_REG_R13}, {"r14", X86_64_REG_R14}, {"r15", X86_64_REG_R15},
192 {"rdi", X86_64_REG_RDI}, {"rsi", X86_64_REG_RSI}, {"rbp", X86_64_REG_RBP},
193 {"rsp", X86_64_REG_RSP}, {"rip", X86_64_REG_RIP},
194};
195
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800196static std::string DumpFrames(Unwinder& unwinder) {
197 std::string str;
198 for (size_t i = 0; i < unwinder.NumFrames(); i++) {
199 str += unwinder.FormatFrame(i) + "\n";
200 }
201 return str;
202}
203
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800204TEST_F(UnwindOfflineTest, pc_straddle_arm) {
Christopher Ferris239425b2018-05-17 18:37:38 -0700205 ASSERT_NO_FATAL_FAILURE(Init("straddle_arm/", ARCH_ARM));
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800206
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800207 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800208 unwinder.Unwind();
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800209
210 std::string frame_info(DumpFrames(unwinder));
211 ASSERT_EQ(4U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
212 EXPECT_EQ(
Christopher Ferris704ec9a2018-03-15 14:35:01 -0700213 " #00 pc 0001a9f8 libc.so (abort+64)\n"
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800214 " #01 pc 00006a1b libbase.so (android::base::DefaultAborter(char const*)+6)\n"
215 " #02 pc 00007441 libbase.so (android::base::LogMessage::~LogMessage()+748)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800216 " #03 pc 00015147 /does/not/exist/libhidlbase.so\n",
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800217 frame_info);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800218 EXPECT_EQ(0xf31ea9f8U, unwinder.frames()[0].pc);
219 EXPECT_EQ(0xe9c866f8U, unwinder.frames()[0].sp);
220 EXPECT_EQ(0xf2da0a1bU, unwinder.frames()[1].pc);
221 EXPECT_EQ(0xe9c86728U, unwinder.frames()[1].sp);
222 EXPECT_EQ(0xf2da1441U, unwinder.frames()[2].pc);
223 EXPECT_EQ(0xe9c86730U, unwinder.frames()[2].sp);
224 EXPECT_EQ(0xf3367147U, unwinder.frames()[3].pc);
225 EXPECT_EQ(0xe9c86778U, unwinder.frames()[3].sp);
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800226}
227
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800228TEST_F(UnwindOfflineTest, pc_in_gnu_debugdata_arm) {
Christopher Ferris239425b2018-05-17 18:37:38 -0700229 ASSERT_NO_FATAL_FAILURE(Init("gnu_debugdata_arm/", ARCH_ARM));
Christopher Ferrise7b66242017-12-15 11:17:45 -0800230
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800231 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
Christopher Ferrise7b66242017-12-15 11:17:45 -0800232 unwinder.Unwind();
Christopher Ferrise7b66242017-12-15 11:17:45 -0800233
234 std::string frame_info(DumpFrames(unwinder));
235 ASSERT_EQ(2U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
236 EXPECT_EQ(
237 " #00 pc 0006dc49 libandroid_runtime.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800238 "(android::AndroidRuntime::javaThreadShell(void*)+80)\n"
Christopher Ferrise7b66242017-12-15 11:17:45 -0800239 " #01 pc 0006dce5 libandroid_runtime.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800240 "(android::AndroidRuntime::javaCreateThreadEtc(int (*)(void*), void*, char const*, int, "
241 "unsigned int, void**))\n",
Christopher Ferrise7b66242017-12-15 11:17:45 -0800242 frame_info);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800243 EXPECT_EQ(0xf1f6dc49U, unwinder.frames()[0].pc);
244 EXPECT_EQ(0xd8fe6930U, unwinder.frames()[0].sp);
245 EXPECT_EQ(0xf1f6dce5U, unwinder.frames()[1].pc);
246 EXPECT_EQ(0xd8fe6958U, unwinder.frames()[1].sp);
Christopher Ferrise7b66242017-12-15 11:17:45 -0800247}
248
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800249TEST_F(UnwindOfflineTest, pc_straddle_arm64) {
Christopher Ferris239425b2018-05-17 18:37:38 -0700250 ASSERT_NO_FATAL_FAILURE(Init("straddle_arm64/", ARCH_ARM64));
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800251
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800252 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800253 unwinder.Unwind();
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800254
255 std::string frame_info(DumpFrames(unwinder));
256 ASSERT_EQ(6U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
257 EXPECT_EQ(
258 " #00 pc 0000000000429fd8 libunwindstack_test (SignalInnerFunction+24)\n"
259 " #01 pc 000000000042a078 libunwindstack_test (SignalMiddleFunction+8)\n"
260 " #02 pc 000000000042a08c libunwindstack_test (SignalOuterFunction+8)\n"
261 " #03 pc 000000000042d8fc libunwindstack_test "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800262 "(unwindstack::RemoteThroughSignal(int, unsigned int)+20)\n"
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800263 " #04 pc 000000000042d8d8 libunwindstack_test "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800264 "(unwindstack::UnwindTest_remote_through_signal_Test::TestBody()+32)\n"
265 " #05 pc 0000000000455d70 libunwindstack_test (testing::Test::Run()+392)\n",
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800266 frame_info);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800267 EXPECT_EQ(0x64d09d4fd8U, unwinder.frames()[0].pc);
268 EXPECT_EQ(0x7fe0d84040U, unwinder.frames()[0].sp);
269 EXPECT_EQ(0x64d09d5078U, unwinder.frames()[1].pc);
270 EXPECT_EQ(0x7fe0d84070U, unwinder.frames()[1].sp);
271 EXPECT_EQ(0x64d09d508cU, unwinder.frames()[2].pc);
272 EXPECT_EQ(0x7fe0d84080U, unwinder.frames()[2].sp);
273 EXPECT_EQ(0x64d09d88fcU, unwinder.frames()[3].pc);
274 EXPECT_EQ(0x7fe0d84090U, unwinder.frames()[3].sp);
275 EXPECT_EQ(0x64d09d88d8U, unwinder.frames()[4].pc);
276 EXPECT_EQ(0x7fe0d840f0U, unwinder.frames()[4].sp);
277 EXPECT_EQ(0x64d0a00d70U, unwinder.frames()[5].pc);
278 EXPECT_EQ(0x7fe0d84110U, unwinder.frames()[5].sp);
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800279}
280
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800281TEST_F(UnwindOfflineTest, jit_debug_x86) {
Christopher Ferris239425b2018-05-17 18:37:38 -0700282 ASSERT_NO_FATAL_FAILURE(Init("jit_debug_x86/", ARCH_X86));
Christopher Ferris150db122017-12-20 18:49:01 -0800283
284 MemoryOfflineParts* memory = new MemoryOfflineParts;
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800285 AddMemory(dir_ + "descriptor.data", memory);
286 AddMemory(dir_ + "stack.data", memory);
Christopher Ferris150db122017-12-20 18:49:01 -0800287 for (size_t i = 0; i < 7; i++) {
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800288 AddMemory(dir_ + "entry" + std::to_string(i) + ".data", memory);
289 AddMemory(dir_ + "jit" + std::to_string(i) + ".data", memory);
Christopher Ferris150db122017-12-20 18:49:01 -0800290 }
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800291 process_memory_.reset(memory);
Christopher Ferris150db122017-12-20 18:49:01 -0800292
David Srbeckyb9cc4fb2019-04-05 18:23:32 +0000293 JitDebug jit_debug(process_memory_);
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800294 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
David Srbeckyb9cc4fb2019-04-05 18:23:32 +0000295 unwinder.SetJitDebug(&jit_debug, regs_->Arch());
Christopher Ferris150db122017-12-20 18:49:01 -0800296 unwinder.Unwind();
Christopher Ferris150db122017-12-20 18:49:01 -0800297
298 std::string frame_info(DumpFrames(unwinder));
299 ASSERT_EQ(69U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
300 EXPECT_EQ(
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800301 " #00 pc 00068fb8 libarttestd.so (art::CauseSegfault()+72)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800302 " #01 pc 00067f00 libarttestd.so (Java_Main_unwindInProcess+10032)\n"
Christopher Ferris02a6c442019-03-11 14:43:33 -0700303 " #02 pc 000021a8 137-cfi.odex (boolean Main.unwindInProcess(boolean, int, "
Christopher Ferris150db122017-12-20 18:49:01 -0800304 "boolean)+136)\n"
Christopher Ferris6dbc28e2018-03-28 15:12:49 -0700305 " #03 pc 0000fe80 anonymous:ee74c000 (boolean Main.bar(boolean)+64)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800306 " #04 pc 006ad4d2 libartd.so (art_quick_invoke_stub+338)\n"
307 " #05 pc 00146ab5 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800308 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
309 "const*)+885)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800310 " #06 pc 0039cf0d libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800311 "(art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, "
312 "art::ShadowFrame*, unsigned short, art::JValue*)+653)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800313 " #07 pc 00392552 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800314 "(art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, "
315 "art::ShadowFrame&, art::JValue, bool)+354)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800316 " #08 pc 0039399a libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800317 "(art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor "
318 "const&, art::ShadowFrame*)+234)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800319 " #09 pc 00684362 libartd.so (artQuickToInterpreterBridge+1058)\n"
320 " #10 pc 006b35bd libartd.so (art_quick_to_interpreter_bridge+77)\n"
Christopher Ferris6dbc28e2018-03-28 15:12:49 -0700321 " #11 pc 0000fe03 anonymous:ee74c000 (int Main.compare(Main, Main)+51)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800322 " #12 pc 006ad4d2 libartd.so (art_quick_invoke_stub+338)\n"
323 " #13 pc 00146ab5 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800324 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
325 "const*)+885)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800326 " #14 pc 0039cf0d libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800327 "(art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, "
328 "art::ShadowFrame*, unsigned short, art::JValue*)+653)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800329 " #15 pc 00392552 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800330 "(art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, "
331 "art::ShadowFrame&, art::JValue, bool)+354)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800332 " #16 pc 0039399a libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800333 "(art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor "
334 "const&, art::ShadowFrame*)+234)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800335 " #17 pc 00684362 libartd.so (artQuickToInterpreterBridge+1058)\n"
336 " #18 pc 006b35bd libartd.so (art_quick_to_interpreter_bridge+77)\n"
Christopher Ferris6dbc28e2018-03-28 15:12:49 -0700337 " #19 pc 0000fd3b anonymous:ee74c000 (int Main.compare(java.lang.Object, "
338 "java.lang.Object)+107)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800339 " #20 pc 006ad4d2 libartd.so (art_quick_invoke_stub+338)\n"
340 " #21 pc 00146ab5 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800341 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
342 "const*)+885)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800343 " #22 pc 0039cf0d libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800344 "(art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, "
345 "art::ShadowFrame*, unsigned short, art::JValue*)+653)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800346 " #23 pc 00392552 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800347 "(art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, "
348 "art::ShadowFrame&, art::JValue, bool)+354)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800349 " #24 pc 0039399a libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800350 "(art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor "
351 "const&, art::ShadowFrame*)+234)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800352 " #25 pc 00684362 libartd.so (artQuickToInterpreterBridge+1058)\n"
353 " #26 pc 006b35bd libartd.so (art_quick_to_interpreter_bridge+77)\n"
Christopher Ferris6dbc28e2018-03-28 15:12:49 -0700354 " #27 pc 0000fbdb anonymous:ee74c000 (int "
Christopher Ferris150db122017-12-20 18:49:01 -0800355 "java.util.Arrays.binarySearch0(java.lang.Object[], int, int, java.lang.Object, "
Christopher Ferris6dbc28e2018-03-28 15:12:49 -0700356 "java.util.Comparator)+331)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800357 " #28 pc 006ad6a2 libartd.so (art_quick_invoke_static_stub+418)\n"
358 " #29 pc 00146acb libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800359 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
360 "const*)+907)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800361 " #30 pc 0039cf0d libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800362 "(art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, "
363 "art::ShadowFrame*, unsigned short, art::JValue*)+653)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800364 " #31 pc 00392552 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800365 "(art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, "
366 "art::ShadowFrame&, art::JValue, bool)+354)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800367 " #32 pc 0039399a libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800368 "(art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor "
369 "const&, art::ShadowFrame*)+234)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800370 " #33 pc 00684362 libartd.so (artQuickToInterpreterBridge+1058)\n"
371 " #34 pc 006b35bd libartd.so (art_quick_to_interpreter_bridge+77)\n"
Christopher Ferris6dbc28e2018-03-28 15:12:49 -0700372 " #35 pc 0000f624 anonymous:ee74c000 (boolean Main.foo()+164)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800373 " #36 pc 006ad4d2 libartd.so (art_quick_invoke_stub+338)\n"
374 " #37 pc 00146ab5 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800375 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
376 "const*)+885)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800377 " #38 pc 0039cf0d libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800378 "(art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, "
379 "art::ShadowFrame*, unsigned short, art::JValue*)+653)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800380 " #39 pc 00392552 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800381 "(art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, "
382 "art::ShadowFrame&, art::JValue, bool)+354)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800383 " #40 pc 0039399a libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800384 "(art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor "
385 "const&, art::ShadowFrame*)+234)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800386 " #41 pc 00684362 libartd.so (artQuickToInterpreterBridge+1058)\n"
387 " #42 pc 006b35bd libartd.so (art_quick_to_interpreter_bridge+77)\n"
Christopher Ferris6dbc28e2018-03-28 15:12:49 -0700388 " #43 pc 0000eedb anonymous:ee74c000 (void Main.runPrimary()+59)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800389 " #44 pc 006ad4d2 libartd.so (art_quick_invoke_stub+338)\n"
390 " #45 pc 00146ab5 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800391 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
392 "const*)+885)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800393 " #46 pc 0039cf0d libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800394 "(art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, "
395 "art::ShadowFrame*, unsigned short, art::JValue*)+653)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800396 " #47 pc 00392552 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800397 "(art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, "
398 "art::ShadowFrame&, art::JValue, bool)+354)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800399 " #48 pc 0039399a libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800400 "(art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor "
401 "const&, art::ShadowFrame*)+234)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800402 " #49 pc 00684362 libartd.so (artQuickToInterpreterBridge+1058)\n"
403 " #50 pc 006b35bd libartd.so (art_quick_to_interpreter_bridge+77)\n"
Christopher Ferris6dbc28e2018-03-28 15:12:49 -0700404 " #51 pc 0000ac21 anonymous:ee74c000 (void Main.main(java.lang.String[])+97)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800405 " #52 pc 006ad6a2 libartd.so (art_quick_invoke_static_stub+418)\n"
406 " #53 pc 00146acb libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800407 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
408 "const*)+907)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800409 " #54 pc 0039cf0d libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800410 "(art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, "
411 "art::ShadowFrame*, unsigned short, art::JValue*)+653)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800412 " #55 pc 00392552 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800413 "(art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, "
414 "art::ShadowFrame&, art::JValue, bool)+354)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800415 " #56 pc 0039399a libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800416 "(art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor "
417 "const&, art::ShadowFrame*)+234)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800418 " #57 pc 00684362 libartd.so (artQuickToInterpreterBridge+1058)\n"
419 " #58 pc 006b35bd libartd.so (art_quick_to_interpreter_bridge+77)\n"
420 " #59 pc 006ad6a2 libartd.so (art_quick_invoke_static_stub+418)\n"
421 " #60 pc 00146acb libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800422 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
423 "const*)+907)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800424 " #61 pc 005aac95 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800425 "(art::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, "
426 "art::ArgArray*, art::JValue*, char const*)+85)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800427 " #62 pc 005aab5a libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800428 "(art::InvokeWithVarArgs(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, "
429 "_jmethodID*, char*)+362)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800430 " #63 pc 0048a3dd libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800431 "(art::JNI::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, char*)+125)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800432 " #64 pc 0018448c libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800433 "(art::CheckJNI::CallMethodV(char const*, _JNIEnv*, _jobject*, _jclass*, _jmethodID*, char*, "
434 "art::Primitive::Type, art::InvokeType)+1964)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800435 " #65 pc 0017cf06 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800436 "(art::CheckJNI::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, char*)+70)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800437 " #66 pc 00001d8c dalvikvm32 "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800438 "(_JNIEnv::CallStaticVoidMethod(_jclass*, _jmethodID*, ...)+60)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800439 " #67 pc 00001a80 dalvikvm32 (main+1312)\n"
440 " #68 pc 00018275 libc.so\n",
441 frame_info);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800442 EXPECT_EQ(0xeb89bfb8U, unwinder.frames()[0].pc);
443 EXPECT_EQ(0xffeb5280U, unwinder.frames()[0].sp);
444 EXPECT_EQ(0xeb89af00U, unwinder.frames()[1].pc);
445 EXPECT_EQ(0xffeb52a0U, unwinder.frames()[1].sp);
446 EXPECT_EQ(0xec6061a8U, unwinder.frames()[2].pc);
447 EXPECT_EQ(0xffeb5ce0U, unwinder.frames()[2].sp);
Christopher Ferris6dbc28e2018-03-28 15:12:49 -0700448 EXPECT_EQ(0xee75be80U, unwinder.frames()[3].pc);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800449 EXPECT_EQ(0xffeb5d30U, unwinder.frames()[3].sp);
450 EXPECT_EQ(0xf728e4d2U, unwinder.frames()[4].pc);
451 EXPECT_EQ(0xffeb5d60U, unwinder.frames()[4].sp);
452 EXPECT_EQ(0xf6d27ab5U, unwinder.frames()[5].pc);
453 EXPECT_EQ(0xffeb5d80U, unwinder.frames()[5].sp);
454 EXPECT_EQ(0xf6f7df0dU, unwinder.frames()[6].pc);
455 EXPECT_EQ(0xffeb5e20U, unwinder.frames()[6].sp);
456 EXPECT_EQ(0xf6f73552U, unwinder.frames()[7].pc);
457 EXPECT_EQ(0xffeb5ec0U, unwinder.frames()[7].sp);
458 EXPECT_EQ(0xf6f7499aU, unwinder.frames()[8].pc);
459 EXPECT_EQ(0xffeb5f40U, unwinder.frames()[8].sp);
460 EXPECT_EQ(0xf7265362U, unwinder.frames()[9].pc);
461 EXPECT_EQ(0xffeb5fb0U, unwinder.frames()[9].sp);
462 EXPECT_EQ(0xf72945bdU, unwinder.frames()[10].pc);
463 EXPECT_EQ(0xffeb6110U, unwinder.frames()[10].sp);
Christopher Ferris6dbc28e2018-03-28 15:12:49 -0700464 EXPECT_EQ(0xee75be03U, unwinder.frames()[11].pc);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800465 EXPECT_EQ(0xffeb6160U, unwinder.frames()[11].sp);
466 EXPECT_EQ(0xf728e4d2U, unwinder.frames()[12].pc);
467 EXPECT_EQ(0xffeb6180U, unwinder.frames()[12].sp);
468 EXPECT_EQ(0xf6d27ab5U, unwinder.frames()[13].pc);
469 EXPECT_EQ(0xffeb61b0U, unwinder.frames()[13].sp);
470 EXPECT_EQ(0xf6f7df0dU, unwinder.frames()[14].pc);
471 EXPECT_EQ(0xffeb6250U, unwinder.frames()[14].sp);
472 EXPECT_EQ(0xf6f73552U, unwinder.frames()[15].pc);
473 EXPECT_EQ(0xffeb62f0U, unwinder.frames()[15].sp);
474 EXPECT_EQ(0xf6f7499aU, unwinder.frames()[16].pc);
475 EXPECT_EQ(0xffeb6370U, unwinder.frames()[16].sp);
476 EXPECT_EQ(0xf7265362U, unwinder.frames()[17].pc);
477 EXPECT_EQ(0xffeb63e0U, unwinder.frames()[17].sp);
478 EXPECT_EQ(0xf72945bdU, unwinder.frames()[18].pc);
479 EXPECT_EQ(0xffeb6530U, unwinder.frames()[18].sp);
Christopher Ferris6dbc28e2018-03-28 15:12:49 -0700480 EXPECT_EQ(0xee75bd3bU, unwinder.frames()[19].pc);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800481 EXPECT_EQ(0xffeb6580U, unwinder.frames()[19].sp);
482 EXPECT_EQ(0xf728e4d2U, unwinder.frames()[20].pc);
483 EXPECT_EQ(0xffeb65b0U, unwinder.frames()[20].sp);
484 EXPECT_EQ(0xf6d27ab5U, unwinder.frames()[21].pc);
485 EXPECT_EQ(0xffeb65e0U, unwinder.frames()[21].sp);
486 EXPECT_EQ(0xf6f7df0dU, unwinder.frames()[22].pc);
487 EXPECT_EQ(0xffeb6680U, unwinder.frames()[22].sp);
488 EXPECT_EQ(0xf6f73552U, unwinder.frames()[23].pc);
489 EXPECT_EQ(0xffeb6720U, unwinder.frames()[23].sp);
490 EXPECT_EQ(0xf6f7499aU, unwinder.frames()[24].pc);
491 EXPECT_EQ(0xffeb67a0U, unwinder.frames()[24].sp);
492 EXPECT_EQ(0xf7265362U, unwinder.frames()[25].pc);
493 EXPECT_EQ(0xffeb6810U, unwinder.frames()[25].sp);
494 EXPECT_EQ(0xf72945bdU, unwinder.frames()[26].pc);
495 EXPECT_EQ(0xffeb6960U, unwinder.frames()[26].sp);
Christopher Ferris6dbc28e2018-03-28 15:12:49 -0700496 EXPECT_EQ(0xee75bbdbU, unwinder.frames()[27].pc);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800497 EXPECT_EQ(0xffeb69b0U, unwinder.frames()[27].sp);
498 EXPECT_EQ(0xf728e6a2U, unwinder.frames()[28].pc);
499 EXPECT_EQ(0xffeb69f0U, unwinder.frames()[28].sp);
500 EXPECT_EQ(0xf6d27acbU, unwinder.frames()[29].pc);
501 EXPECT_EQ(0xffeb6a20U, unwinder.frames()[29].sp);
502 EXPECT_EQ(0xf6f7df0dU, unwinder.frames()[30].pc);
503 EXPECT_EQ(0xffeb6ac0U, unwinder.frames()[30].sp);
504 EXPECT_EQ(0xf6f73552U, unwinder.frames()[31].pc);
505 EXPECT_EQ(0xffeb6b60U, unwinder.frames()[31].sp);
506 EXPECT_EQ(0xf6f7499aU, unwinder.frames()[32].pc);
507 EXPECT_EQ(0xffeb6be0U, unwinder.frames()[32].sp);
508 EXPECT_EQ(0xf7265362U, unwinder.frames()[33].pc);
509 EXPECT_EQ(0xffeb6c50U, unwinder.frames()[33].sp);
510 EXPECT_EQ(0xf72945bdU, unwinder.frames()[34].pc);
511 EXPECT_EQ(0xffeb6dd0U, unwinder.frames()[34].sp);
Christopher Ferris6dbc28e2018-03-28 15:12:49 -0700512 EXPECT_EQ(0xee75b624U, unwinder.frames()[35].pc);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800513 EXPECT_EQ(0xffeb6e20U, unwinder.frames()[35].sp);
514 EXPECT_EQ(0xf728e4d2U, unwinder.frames()[36].pc);
515 EXPECT_EQ(0xffeb6e50U, unwinder.frames()[36].sp);
516 EXPECT_EQ(0xf6d27ab5U, unwinder.frames()[37].pc);
517 EXPECT_EQ(0xffeb6e70U, unwinder.frames()[37].sp);
518 EXPECT_EQ(0xf6f7df0dU, unwinder.frames()[38].pc);
519 EXPECT_EQ(0xffeb6f10U, unwinder.frames()[38].sp);
520 EXPECT_EQ(0xf6f73552U, unwinder.frames()[39].pc);
521 EXPECT_EQ(0xffeb6fb0U, unwinder.frames()[39].sp);
522 EXPECT_EQ(0xf6f7499aU, unwinder.frames()[40].pc);
523 EXPECT_EQ(0xffeb7030U, unwinder.frames()[40].sp);
524 EXPECT_EQ(0xf7265362U, unwinder.frames()[41].pc);
525 EXPECT_EQ(0xffeb70a0U, unwinder.frames()[41].sp);
526 EXPECT_EQ(0xf72945bdU, unwinder.frames()[42].pc);
527 EXPECT_EQ(0xffeb71f0U, unwinder.frames()[42].sp);
Christopher Ferris6dbc28e2018-03-28 15:12:49 -0700528 EXPECT_EQ(0xee75aedbU, unwinder.frames()[43].pc);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800529 EXPECT_EQ(0xffeb7240U, unwinder.frames()[43].sp);
530 EXPECT_EQ(0xf728e4d2U, unwinder.frames()[44].pc);
531 EXPECT_EQ(0xffeb72a0U, unwinder.frames()[44].sp);
532 EXPECT_EQ(0xf6d27ab5U, unwinder.frames()[45].pc);
533 EXPECT_EQ(0xffeb72c0U, unwinder.frames()[45].sp);
534 EXPECT_EQ(0xf6f7df0dU, unwinder.frames()[46].pc);
535 EXPECT_EQ(0xffeb7360U, unwinder.frames()[46].sp);
536 EXPECT_EQ(0xf6f73552U, unwinder.frames()[47].pc);
537 EXPECT_EQ(0xffeb7400U, unwinder.frames()[47].sp);
538 EXPECT_EQ(0xf6f7499aU, unwinder.frames()[48].pc);
539 EXPECT_EQ(0xffeb7480U, unwinder.frames()[48].sp);
540 EXPECT_EQ(0xf7265362U, unwinder.frames()[49].pc);
541 EXPECT_EQ(0xffeb74f0U, unwinder.frames()[49].sp);
542 EXPECT_EQ(0xf72945bdU, unwinder.frames()[50].pc);
543 EXPECT_EQ(0xffeb7680U, unwinder.frames()[50].sp);
Christopher Ferris6dbc28e2018-03-28 15:12:49 -0700544 EXPECT_EQ(0xee756c21U, unwinder.frames()[51].pc);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800545 EXPECT_EQ(0xffeb76d0U, unwinder.frames()[51].sp);
546 EXPECT_EQ(0xf728e6a2U, unwinder.frames()[52].pc);
547 EXPECT_EQ(0xffeb76f0U, unwinder.frames()[52].sp);
548 EXPECT_EQ(0xf6d27acbU, unwinder.frames()[53].pc);
549 EXPECT_EQ(0xffeb7710U, unwinder.frames()[53].sp);
550 EXPECT_EQ(0xf6f7df0dU, unwinder.frames()[54].pc);
551 EXPECT_EQ(0xffeb77b0U, unwinder.frames()[54].sp);
552 EXPECT_EQ(0xf6f73552U, unwinder.frames()[55].pc);
553 EXPECT_EQ(0xffeb7850U, unwinder.frames()[55].sp);
554 EXPECT_EQ(0xf6f7499aU, unwinder.frames()[56].pc);
555 EXPECT_EQ(0xffeb78d0U, unwinder.frames()[56].sp);
556 EXPECT_EQ(0xf7265362U, unwinder.frames()[57].pc);
557 EXPECT_EQ(0xffeb7940U, unwinder.frames()[57].sp);
558 EXPECT_EQ(0xf72945bdU, unwinder.frames()[58].pc);
559 EXPECT_EQ(0xffeb7a80U, unwinder.frames()[58].sp);
560 EXPECT_EQ(0xf728e6a2U, unwinder.frames()[59].pc);
561 EXPECT_EQ(0xffeb7ad0U, unwinder.frames()[59].sp);
562 EXPECT_EQ(0xf6d27acbU, unwinder.frames()[60].pc);
563 EXPECT_EQ(0xffeb7af0U, unwinder.frames()[60].sp);
564 EXPECT_EQ(0xf718bc95U, unwinder.frames()[61].pc);
565 EXPECT_EQ(0xffeb7b90U, unwinder.frames()[61].sp);
566 EXPECT_EQ(0xf718bb5aU, unwinder.frames()[62].pc);
567 EXPECT_EQ(0xffeb7c50U, unwinder.frames()[62].sp);
568 EXPECT_EQ(0xf706b3ddU, unwinder.frames()[63].pc);
569 EXPECT_EQ(0xffeb7d10U, unwinder.frames()[63].sp);
570 EXPECT_EQ(0xf6d6548cU, unwinder.frames()[64].pc);
571 EXPECT_EQ(0xffeb7d70U, unwinder.frames()[64].sp);
572 EXPECT_EQ(0xf6d5df06U, unwinder.frames()[65].pc);
573 EXPECT_EQ(0xffeb7df0U, unwinder.frames()[65].sp);
574 EXPECT_EQ(0x56574d8cU, unwinder.frames()[66].pc);
575 EXPECT_EQ(0xffeb7e40U, unwinder.frames()[66].sp);
576 EXPECT_EQ(0x56574a80U, unwinder.frames()[67].pc);
577 EXPECT_EQ(0xffeb7e70U, unwinder.frames()[67].sp);
578 EXPECT_EQ(0xf7363275U, unwinder.frames()[68].pc);
579 EXPECT_EQ(0xffeb7ef0U, unwinder.frames()[68].sp);
Christopher Ferris150db122017-12-20 18:49:01 -0800580}
581
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800582TEST_F(UnwindOfflineTest, jit_debug_arm) {
Christopher Ferris239425b2018-05-17 18:37:38 -0700583 ASSERT_NO_FATAL_FAILURE(Init("jit_debug_arm/", ARCH_ARM));
Christopher Ferrised37aca2018-01-12 15:53:19 -0800584
585 MemoryOfflineParts* memory = new MemoryOfflineParts;
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800586 AddMemory(dir_ + "descriptor.data", memory);
587 AddMemory(dir_ + "descriptor1.data", memory);
588 AddMemory(dir_ + "stack.data", memory);
Christopher Ferrised37aca2018-01-12 15:53:19 -0800589 for (size_t i = 0; i < 7; i++) {
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800590 AddMemory(dir_ + "entry" + std::to_string(i) + ".data", memory);
591 AddMemory(dir_ + "jit" + std::to_string(i) + ".data", memory);
Christopher Ferrised37aca2018-01-12 15:53:19 -0800592 }
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800593 process_memory_.reset(memory);
Christopher Ferrised37aca2018-01-12 15:53:19 -0800594
David Srbeckyb9cc4fb2019-04-05 18:23:32 +0000595 JitDebug jit_debug(process_memory_);
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800596 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
David Srbeckyb9cc4fb2019-04-05 18:23:32 +0000597 unwinder.SetJitDebug(&jit_debug, regs_->Arch());
Christopher Ferrised37aca2018-01-12 15:53:19 -0800598 unwinder.Unwind();
Christopher Ferrised37aca2018-01-12 15:53:19 -0800599
600 std::string frame_info(DumpFrames(unwinder));
601 ASSERT_EQ(76U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
602 EXPECT_EQ(
Christopher Ferris704ec9a2018-03-15 14:35:01 -0700603 " #00 pc 00018a5e libarttestd.so (Java_Main_unwindInProcess+866)\n"
Christopher Ferris02a6c442019-03-11 14:43:33 -0700604 " #01 pc 0000212d 137-cfi.odex (boolean Main.unwindInProcess(boolean, int, "
Christopher Ferrised37aca2018-01-12 15:53:19 -0800605 "boolean)+92)\n"
606 " #02 pc 00011cb1 anonymous:e2796000 (boolean Main.bar(boolean)+72)\n"
607 " #03 pc 00462175 libartd.so (art_quick_invoke_stub_internal+68)\n"
608 " #04 pc 00467129 libartd.so (art_quick_invoke_stub+228)\n"
609 " #05 pc 000bf7a9 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800610 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
611 "const*)+864)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800612 " #06 pc 00247833 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800613 "(art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, "
614 "art::ShadowFrame*, unsigned short, art::JValue*)+382)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800615 " #07 pc 0022e935 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800616 "(art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, "
617 "art::ShadowFrame&, art::JValue, bool)+244)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800618 " #08 pc 0022f71d libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800619 "(art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor "
620 "const&, art::ShadowFrame*)+128)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800621 " #09 pc 00442865 libartd.so (artQuickToInterpreterBridge+796)\n"
622 " #10 pc 004666ff libartd.so (art_quick_to_interpreter_bridge+30)\n"
623 " #11 pc 00011c31 anonymous:e2796000 (int Main.compare(Main, Main)+64)\n"
624 " #12 pc 00462175 libartd.so (art_quick_invoke_stub_internal+68)\n"
625 " #13 pc 00467129 libartd.so (art_quick_invoke_stub+228)\n"
626 " #14 pc 000bf7a9 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800627 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
628 "const*)+864)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800629 " #15 pc 00247833 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800630 "(art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, "
631 "art::ShadowFrame*, unsigned short, art::JValue*)+382)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800632 " #16 pc 0022e935 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800633 "(art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, "
634 "art::ShadowFrame&, art::JValue, bool)+244)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800635 " #17 pc 0022f71d libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800636 "(art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor "
637 "const&, art::ShadowFrame*)+128)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800638 " #18 pc 00442865 libartd.so (artQuickToInterpreterBridge+796)\n"
639 " #19 pc 004666ff libartd.so (art_quick_to_interpreter_bridge+30)\n"
640 " #20 pc 00011b77 anonymous:e2796000 (int Main.compare(java.lang.Object, "
641 "java.lang.Object)+118)\n"
642 " #21 pc 00462175 libartd.so (art_quick_invoke_stub_internal+68)\n"
643 " #22 pc 00467129 libartd.so (art_quick_invoke_stub+228)\n"
644 " #23 pc 000bf7a9 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800645 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
646 "const*)+864)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800647 " #24 pc 00247833 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800648 "(art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, "
649 "art::ShadowFrame*, unsigned short, art::JValue*)+382)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800650 " #25 pc 0022e935 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800651 "(art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, "
652 "art::ShadowFrame&, art::JValue, bool)+244)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800653 " #26 pc 0022f71d libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800654 "(art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor "
655 "const&, art::ShadowFrame*)+128)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800656 " #27 pc 00442865 libartd.so (artQuickToInterpreterBridge+796)\n"
657 " #28 pc 004666ff libartd.so (art_quick_to_interpreter_bridge+30)\n"
658 " #29 pc 00011a29 anonymous:e2796000 (int "
659 "java.util.Arrays.binarySearch0(java.lang.Object[], int, int, java.lang.Object, "
660 "java.util.Comparator)+304)\n"
661 " #30 pc 00462175 libartd.so (art_quick_invoke_stub_internal+68)\n"
662 " #31 pc 0046722f libartd.so (art_quick_invoke_static_stub+226)\n"
663 " #32 pc 000bf7bb libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800664 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
665 "const*)+882)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800666 " #33 pc 00247833 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800667 "(art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, "
668 "art::ShadowFrame*, unsigned short, art::JValue*)+382)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800669 " #34 pc 0022e935 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800670 "(art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, "
671 "art::ShadowFrame&, art::JValue, bool)+244)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800672 " #35 pc 0022f71d libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800673 "(art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor "
674 "const&, art::ShadowFrame*)+128)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800675 " #36 pc 00442865 libartd.so (artQuickToInterpreterBridge+796)\n"
676 " #37 pc 004666ff libartd.so (art_quick_to_interpreter_bridge+30)\n"
677 " #38 pc 0001139b anonymous:e2796000 (boolean Main.foo()+178)\n"
678 " #39 pc 00462175 libartd.so (art_quick_invoke_stub_internal+68)\n"
679 " #40 pc 00467129 libartd.so (art_quick_invoke_stub+228)\n"
680 " #41 pc 000bf7a9 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800681 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
682 "const*)+864)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800683 " #42 pc 00247833 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800684 "(art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, "
685 "art::ShadowFrame*, unsigned short, art::JValue*)+382)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800686 " #43 pc 0022e935 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800687 "(art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, "
688 "art::ShadowFrame&, art::JValue, bool)+244)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800689 " #44 pc 0022f71d libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800690 "(art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor "
691 "const&, art::ShadowFrame*)+128)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800692 " #45 pc 00442865 libartd.so (artQuickToInterpreterBridge+796)\n"
693 " #46 pc 004666ff libartd.so (art_quick_to_interpreter_bridge+30)\n"
694 " #47 pc 00010aa7 anonymous:e2796000 (void Main.runPrimary()+70)\n"
695 " #48 pc 00462175 libartd.so (art_quick_invoke_stub_internal+68)\n"
696 " #49 pc 00467129 libartd.so (art_quick_invoke_stub+228)\n"
697 " #50 pc 000bf7a9 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800698 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
699 "const*)+864)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800700 " #51 pc 00247833 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800701 "(art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, "
702 "art::ShadowFrame*, unsigned short, art::JValue*)+382)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800703 " #52 pc 0022e935 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800704 "(art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, "
705 "art::ShadowFrame&, art::JValue, bool)+244)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800706 " #53 pc 0022f71d libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800707 "(art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor "
708 "const&, art::ShadowFrame*)+128)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800709 " #54 pc 00442865 libartd.so (artQuickToInterpreterBridge+796)\n"
710 " #55 pc 004666ff libartd.so (art_quick_to_interpreter_bridge+30)\n"
711 " #56 pc 0000ba99 anonymous:e2796000 (void Main.main(java.lang.String[])+144)\n"
712 " #57 pc 00462175 libartd.so (art_quick_invoke_stub_internal+68)\n"
713 " #58 pc 0046722f libartd.so (art_quick_invoke_static_stub+226)\n"
714 " #59 pc 000bf7bb libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800715 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
716 "const*)+882)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800717 " #60 pc 00247833 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800718 "(art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, "
719 "art::ShadowFrame*, unsigned short, art::JValue*)+382)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800720 " #61 pc 0022e935 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800721 "(art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, "
722 "art::ShadowFrame&, art::JValue, bool)+244)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800723 " #62 pc 0022f71d libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800724 "(art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor "
725 "const&, art::ShadowFrame*)+128)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800726 " #63 pc 00442865 libartd.so (artQuickToInterpreterBridge+796)\n"
727 " #64 pc 004666ff libartd.so (art_quick_to_interpreter_bridge+30)\n"
728 " #65 pc 00462175 libartd.so (art_quick_invoke_stub_internal+68)\n"
729 " #66 pc 0046722f libartd.so (art_quick_invoke_static_stub+226)\n"
730 " #67 pc 000bf7bb libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800731 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
732 "const*)+882)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800733 " #68 pc 003b292d libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800734 "(art::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, "
735 "art::ArgArray*, art::JValue*, char const*)+52)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800736 " #69 pc 003b26c3 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800737 "(art::InvokeWithVarArgs(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, "
738 "_jmethodID*, std::__va_list)+210)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800739 " #70 pc 00308411 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800740 "(art::JNI::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, std::__va_list)+76)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800741 " #71 pc 000e6a9f libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800742 "(art::CheckJNI::CallMethodV(char const*, _JNIEnv*, _jobject*, _jclass*, _jmethodID*, "
743 "std::__va_list, art::Primitive::Type, art::InvokeType)+1486)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800744 " #72 pc 000e19b9 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800745 "(art::CheckJNI::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, std::__va_list)+40)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800746 " #73 pc 0000159f dalvikvm32 "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800747 "(_JNIEnv::CallStaticVoidMethod(_jclass*, _jmethodID*, ...)+30)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800748 " #74 pc 00001349 dalvikvm32 (main+896)\n"
749 " #75 pc 000850c9 libc.so\n",
750 frame_info);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800751 EXPECT_EQ(0xdfe66a5eU, unwinder.frames()[0].pc);
752 EXPECT_EQ(0xff85d180U, unwinder.frames()[0].sp);
753 EXPECT_EQ(0xe044712dU, unwinder.frames()[1].pc);
754 EXPECT_EQ(0xff85d200U, unwinder.frames()[1].sp);
755 EXPECT_EQ(0xe27a7cb1U, unwinder.frames()[2].pc);
756 EXPECT_EQ(0xff85d290U, unwinder.frames()[2].sp);
757 EXPECT_EQ(0xed75c175U, unwinder.frames()[3].pc);
758 EXPECT_EQ(0xff85d2b0U, unwinder.frames()[3].sp);
759 EXPECT_EQ(0xed761129U, unwinder.frames()[4].pc);
760 EXPECT_EQ(0xff85d2e8U, unwinder.frames()[4].sp);
761 EXPECT_EQ(0xed3b97a9U, unwinder.frames()[5].pc);
762 EXPECT_EQ(0xff85d370U, unwinder.frames()[5].sp);
763 EXPECT_EQ(0xed541833U, unwinder.frames()[6].pc);
764 EXPECT_EQ(0xff85d3d8U, unwinder.frames()[6].sp);
765 EXPECT_EQ(0xed528935U, unwinder.frames()[7].pc);
766 EXPECT_EQ(0xff85d428U, unwinder.frames()[7].sp);
767 EXPECT_EQ(0xed52971dU, unwinder.frames()[8].pc);
768 EXPECT_EQ(0xff85d470U, unwinder.frames()[8].sp);
769 EXPECT_EQ(0xed73c865U, unwinder.frames()[9].pc);
770 EXPECT_EQ(0xff85d4b0U, unwinder.frames()[9].sp);
771 EXPECT_EQ(0xed7606ffU, unwinder.frames()[10].pc);
772 EXPECT_EQ(0xff85d5d0U, unwinder.frames()[10].sp);
773 EXPECT_EQ(0xe27a7c31U, unwinder.frames()[11].pc);
774 EXPECT_EQ(0xff85d640U, unwinder.frames()[11].sp);
775 EXPECT_EQ(0xed75c175U, unwinder.frames()[12].pc);
776 EXPECT_EQ(0xff85d660U, unwinder.frames()[12].sp);
777 EXPECT_EQ(0xed761129U, unwinder.frames()[13].pc);
778 EXPECT_EQ(0xff85d698U, unwinder.frames()[13].sp);
779 EXPECT_EQ(0xed3b97a9U, unwinder.frames()[14].pc);
780 EXPECT_EQ(0xff85d720U, unwinder.frames()[14].sp);
781 EXPECT_EQ(0xed541833U, unwinder.frames()[15].pc);
782 EXPECT_EQ(0xff85d788U, unwinder.frames()[15].sp);
783 EXPECT_EQ(0xed528935U, unwinder.frames()[16].pc);
784 EXPECT_EQ(0xff85d7d8U, unwinder.frames()[16].sp);
785 EXPECT_EQ(0xed52971dU, unwinder.frames()[17].pc);
786 EXPECT_EQ(0xff85d820U, unwinder.frames()[17].sp);
787 EXPECT_EQ(0xed73c865U, unwinder.frames()[18].pc);
788 EXPECT_EQ(0xff85d860U, unwinder.frames()[18].sp);
789 EXPECT_EQ(0xed7606ffU, unwinder.frames()[19].pc);
790 EXPECT_EQ(0xff85d970U, unwinder.frames()[19].sp);
791 EXPECT_EQ(0xe27a7b77U, unwinder.frames()[20].pc);
792 EXPECT_EQ(0xff85d9e0U, unwinder.frames()[20].sp);
793 EXPECT_EQ(0xed75c175U, unwinder.frames()[21].pc);
794 EXPECT_EQ(0xff85da10U, unwinder.frames()[21].sp);
795 EXPECT_EQ(0xed761129U, unwinder.frames()[22].pc);
796 EXPECT_EQ(0xff85da48U, unwinder.frames()[22].sp);
797 EXPECT_EQ(0xed3b97a9U, unwinder.frames()[23].pc);
798 EXPECT_EQ(0xff85dad0U, unwinder.frames()[23].sp);
799 EXPECT_EQ(0xed541833U, unwinder.frames()[24].pc);
800 EXPECT_EQ(0xff85db38U, unwinder.frames()[24].sp);
801 EXPECT_EQ(0xed528935U, unwinder.frames()[25].pc);
802 EXPECT_EQ(0xff85db88U, unwinder.frames()[25].sp);
803 EXPECT_EQ(0xed52971dU, unwinder.frames()[26].pc);
804 EXPECT_EQ(0xff85dbd0U, unwinder.frames()[26].sp);
805 EXPECT_EQ(0xed73c865U, unwinder.frames()[27].pc);
806 EXPECT_EQ(0xff85dc10U, unwinder.frames()[27].sp);
807 EXPECT_EQ(0xed7606ffU, unwinder.frames()[28].pc);
808 EXPECT_EQ(0xff85dd20U, unwinder.frames()[28].sp);
809 EXPECT_EQ(0xe27a7a29U, unwinder.frames()[29].pc);
810 EXPECT_EQ(0xff85dd90U, unwinder.frames()[29].sp);
811 EXPECT_EQ(0xed75c175U, unwinder.frames()[30].pc);
812 EXPECT_EQ(0xff85ddc0U, unwinder.frames()[30].sp);
813 EXPECT_EQ(0xed76122fU, unwinder.frames()[31].pc);
814 EXPECT_EQ(0xff85de08U, unwinder.frames()[31].sp);
815 EXPECT_EQ(0xed3b97bbU, unwinder.frames()[32].pc);
816 EXPECT_EQ(0xff85de90U, unwinder.frames()[32].sp);
817 EXPECT_EQ(0xed541833U, unwinder.frames()[33].pc);
818 EXPECT_EQ(0xff85def8U, unwinder.frames()[33].sp);
819 EXPECT_EQ(0xed528935U, unwinder.frames()[34].pc);
820 EXPECT_EQ(0xff85df48U, unwinder.frames()[34].sp);
821 EXPECT_EQ(0xed52971dU, unwinder.frames()[35].pc);
822 EXPECT_EQ(0xff85df90U, unwinder.frames()[35].sp);
823 EXPECT_EQ(0xed73c865U, unwinder.frames()[36].pc);
824 EXPECT_EQ(0xff85dfd0U, unwinder.frames()[36].sp);
825 EXPECT_EQ(0xed7606ffU, unwinder.frames()[37].pc);
826 EXPECT_EQ(0xff85e110U, unwinder.frames()[37].sp);
827 EXPECT_EQ(0xe27a739bU, unwinder.frames()[38].pc);
828 EXPECT_EQ(0xff85e180U, unwinder.frames()[38].sp);
829 EXPECT_EQ(0xed75c175U, unwinder.frames()[39].pc);
830 EXPECT_EQ(0xff85e1b0U, unwinder.frames()[39].sp);
831 EXPECT_EQ(0xed761129U, unwinder.frames()[40].pc);
832 EXPECT_EQ(0xff85e1e0U, unwinder.frames()[40].sp);
833 EXPECT_EQ(0xed3b97a9U, unwinder.frames()[41].pc);
834 EXPECT_EQ(0xff85e268U, unwinder.frames()[41].sp);
835 EXPECT_EQ(0xed541833U, unwinder.frames()[42].pc);
836 EXPECT_EQ(0xff85e2d0U, unwinder.frames()[42].sp);
837 EXPECT_EQ(0xed528935U, unwinder.frames()[43].pc);
838 EXPECT_EQ(0xff85e320U, unwinder.frames()[43].sp);
839 EXPECT_EQ(0xed52971dU, unwinder.frames()[44].pc);
840 EXPECT_EQ(0xff85e368U, unwinder.frames()[44].sp);
841 EXPECT_EQ(0xed73c865U, unwinder.frames()[45].pc);
842 EXPECT_EQ(0xff85e3a8U, unwinder.frames()[45].sp);
843 EXPECT_EQ(0xed7606ffU, unwinder.frames()[46].pc);
844 EXPECT_EQ(0xff85e4c0U, unwinder.frames()[46].sp);
845 EXPECT_EQ(0xe27a6aa7U, unwinder.frames()[47].pc);
846 EXPECT_EQ(0xff85e530U, unwinder.frames()[47].sp);
847 EXPECT_EQ(0xed75c175U, unwinder.frames()[48].pc);
848 EXPECT_EQ(0xff85e5a0U, unwinder.frames()[48].sp);
849 EXPECT_EQ(0xed761129U, unwinder.frames()[49].pc);
850 EXPECT_EQ(0xff85e5d8U, unwinder.frames()[49].sp);
851 EXPECT_EQ(0xed3b97a9U, unwinder.frames()[50].pc);
852 EXPECT_EQ(0xff85e660U, unwinder.frames()[50].sp);
853 EXPECT_EQ(0xed541833U, unwinder.frames()[51].pc);
854 EXPECT_EQ(0xff85e6c8U, unwinder.frames()[51].sp);
855 EXPECT_EQ(0xed528935U, unwinder.frames()[52].pc);
856 EXPECT_EQ(0xff85e718U, unwinder.frames()[52].sp);
857 EXPECT_EQ(0xed52971dU, unwinder.frames()[53].pc);
858 EXPECT_EQ(0xff85e760U, unwinder.frames()[53].sp);
859 EXPECT_EQ(0xed73c865U, unwinder.frames()[54].pc);
860 EXPECT_EQ(0xff85e7a0U, unwinder.frames()[54].sp);
861 EXPECT_EQ(0xed7606ffU, unwinder.frames()[55].pc);
862 EXPECT_EQ(0xff85e8f0U, unwinder.frames()[55].sp);
863 EXPECT_EQ(0xe27a1a99U, unwinder.frames()[56].pc);
864 EXPECT_EQ(0xff85e960U, unwinder.frames()[56].sp);
865 EXPECT_EQ(0xed75c175U, unwinder.frames()[57].pc);
866 EXPECT_EQ(0xff85e990U, unwinder.frames()[57].sp);
867 EXPECT_EQ(0xed76122fU, unwinder.frames()[58].pc);
868 EXPECT_EQ(0xff85e9c8U, unwinder.frames()[58].sp);
869 EXPECT_EQ(0xed3b97bbU, unwinder.frames()[59].pc);
870 EXPECT_EQ(0xff85ea50U, unwinder.frames()[59].sp);
871 EXPECT_EQ(0xed541833U, unwinder.frames()[60].pc);
872 EXPECT_EQ(0xff85eab8U, unwinder.frames()[60].sp);
873 EXPECT_EQ(0xed528935U, unwinder.frames()[61].pc);
874 EXPECT_EQ(0xff85eb08U, unwinder.frames()[61].sp);
875 EXPECT_EQ(0xed52971dU, unwinder.frames()[62].pc);
876 EXPECT_EQ(0xff85eb50U, unwinder.frames()[62].sp);
877 EXPECT_EQ(0xed73c865U, unwinder.frames()[63].pc);
878 EXPECT_EQ(0xff85eb90U, unwinder.frames()[63].sp);
879 EXPECT_EQ(0xed7606ffU, unwinder.frames()[64].pc);
880 EXPECT_EQ(0xff85ec90U, unwinder.frames()[64].sp);
881 EXPECT_EQ(0xed75c175U, unwinder.frames()[65].pc);
882 EXPECT_EQ(0xff85ed00U, unwinder.frames()[65].sp);
883 EXPECT_EQ(0xed76122fU, unwinder.frames()[66].pc);
884 EXPECT_EQ(0xff85ed38U, unwinder.frames()[66].sp);
885 EXPECT_EQ(0xed3b97bbU, unwinder.frames()[67].pc);
886 EXPECT_EQ(0xff85edc0U, unwinder.frames()[67].sp);
887 EXPECT_EQ(0xed6ac92dU, unwinder.frames()[68].pc);
888 EXPECT_EQ(0xff85ee28U, unwinder.frames()[68].sp);
889 EXPECT_EQ(0xed6ac6c3U, unwinder.frames()[69].pc);
890 EXPECT_EQ(0xff85eeb8U, unwinder.frames()[69].sp);
891 EXPECT_EQ(0xed602411U, unwinder.frames()[70].pc);
892 EXPECT_EQ(0xff85ef48U, unwinder.frames()[70].sp);
893 EXPECT_EQ(0xed3e0a9fU, unwinder.frames()[71].pc);
894 EXPECT_EQ(0xff85ef90U, unwinder.frames()[71].sp);
895 EXPECT_EQ(0xed3db9b9U, unwinder.frames()[72].pc);
896 EXPECT_EQ(0xff85f008U, unwinder.frames()[72].sp);
897 EXPECT_EQ(0xab0d459fU, unwinder.frames()[73].pc);
898 EXPECT_EQ(0xff85f038U, unwinder.frames()[73].sp);
899 EXPECT_EQ(0xab0d4349U, unwinder.frames()[74].pc);
900 EXPECT_EQ(0xff85f050U, unwinder.frames()[74].sp);
901 EXPECT_EQ(0xedb0d0c9U, unwinder.frames()[75].pc);
902 EXPECT_EQ(0xff85f0c0U, unwinder.frames()[75].sp);
Christopher Ferrised37aca2018-01-12 15:53:19 -0800903}
904
Christopher Ferrise1f7a632019-01-24 12:22:03 -0800905struct LeakType {
906 LeakType(Maps* maps, Regs* regs, std::shared_ptr<Memory>& process_memory)
907 : maps(maps), regs(regs), process_memory(process_memory) {}
908
909 Maps* maps;
910 Regs* regs;
911 std::shared_ptr<Memory>& process_memory;
912};
913
914static void OfflineUnwind(void* data) {
915 LeakType* leak_data = reinterpret_cast<LeakType*>(data);
916
917 std::unique_ptr<Regs> regs_copy(leak_data->regs->Clone());
David Srbeckyb9cc4fb2019-04-05 18:23:32 +0000918 JitDebug jit_debug(leak_data->process_memory);
Christopher Ferrise1f7a632019-01-24 12:22:03 -0800919 Unwinder unwinder(128, leak_data->maps, regs_copy.get(), leak_data->process_memory);
David Srbeckyb9cc4fb2019-04-05 18:23:32 +0000920 unwinder.SetJitDebug(&jit_debug, regs_copy->Arch());
Christopher Ferrise1f7a632019-01-24 12:22:03 -0800921 unwinder.Unwind();
922 ASSERT_EQ(76U, unwinder.NumFrames());
923}
924
925TEST_F(UnwindOfflineTest, unwind_offline_check_for_leaks) {
926 ASSERT_NO_FATAL_FAILURE(Init("jit_debug_arm/", ARCH_ARM));
927
928 MemoryOfflineParts* memory = new MemoryOfflineParts;
929 AddMemory(dir_ + "descriptor.data", memory);
930 AddMemory(dir_ + "descriptor1.data", memory);
931 AddMemory(dir_ + "stack.data", memory);
932 for (size_t i = 0; i < 7; i++) {
933 AddMemory(dir_ + "entry" + std::to_string(i) + ".data", memory);
934 AddMemory(dir_ + "jit" + std::to_string(i) + ".data", memory);
935 }
936 process_memory_.reset(memory);
937
938 LeakType data(maps_.get(), regs_.get(), process_memory_);
939 TestCheckForLeaks(OfflineUnwind, &data);
940}
941
Christopher Ferris1a141a02018-01-24 08:52:47 -0800942// The eh_frame_hdr data is present but set to zero fdes. This should
943// fallback to iterating over the cies/fdes and ignore the eh_frame_hdr.
944// No .gnu_debugdata section in the elf file, so no symbols.
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800945TEST_F(UnwindOfflineTest, bad_eh_frame_hdr_arm64) {
Christopher Ferris239425b2018-05-17 18:37:38 -0700946 ASSERT_NO_FATAL_FAILURE(Init("bad_eh_frame_hdr_arm64/", ARCH_ARM64));
Christopher Ferris1a141a02018-01-24 08:52:47 -0800947
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800948 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
Christopher Ferris1a141a02018-01-24 08:52:47 -0800949 unwinder.Unwind();
Christopher Ferris1a141a02018-01-24 08:52:47 -0800950
951 std::string frame_info(DumpFrames(unwinder));
952 ASSERT_EQ(5U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
953 EXPECT_EQ(
954 " #00 pc 0000000000000550 waiter64\n"
955 " #01 pc 0000000000000568 waiter64\n"
956 " #02 pc 000000000000057c waiter64\n"
957 " #03 pc 0000000000000590 waiter64\n"
958 " #04 pc 00000000000a8e98 libc.so (__libc_init+88)\n",
959 frame_info);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800960 EXPECT_EQ(0x60a9fdf550U, unwinder.frames()[0].pc);
961 EXPECT_EQ(0x7fdd141990U, unwinder.frames()[0].sp);
962 EXPECT_EQ(0x60a9fdf568U, unwinder.frames()[1].pc);
963 EXPECT_EQ(0x7fdd1419a0U, unwinder.frames()[1].sp);
964 EXPECT_EQ(0x60a9fdf57cU, unwinder.frames()[2].pc);
965 EXPECT_EQ(0x7fdd1419b0U, unwinder.frames()[2].sp);
966 EXPECT_EQ(0x60a9fdf590U, unwinder.frames()[3].pc);
967 EXPECT_EQ(0x7fdd1419c0U, unwinder.frames()[3].sp);
968 EXPECT_EQ(0x7542d68e98U, unwinder.frames()[4].pc);
969 EXPECT_EQ(0x7fdd1419d0U, unwinder.frames()[4].sp);
Christopher Ferris1a141a02018-01-24 08:52:47 -0800970}
971
972// The elf has bad eh_frame unwind information for the pcs. If eh_frame
973// is used first, the unwind will not match the expected output.
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800974TEST_F(UnwindOfflineTest, debug_frame_first_x86) {
Christopher Ferris239425b2018-05-17 18:37:38 -0700975 ASSERT_NO_FATAL_FAILURE(Init("debug_frame_first_x86/", ARCH_X86));
Christopher Ferris1a141a02018-01-24 08:52:47 -0800976
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800977 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
Christopher Ferris1a141a02018-01-24 08:52:47 -0800978 unwinder.Unwind();
Christopher Ferris1a141a02018-01-24 08:52:47 -0800979
980 std::string frame_info(DumpFrames(unwinder));
981 ASSERT_EQ(5U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
982 EXPECT_EQ(
983 " #00 pc 00000685 waiter (call_level3+53)\n"
984 " #01 pc 000006b7 waiter (call_level2+23)\n"
985 " #02 pc 000006d7 waiter (call_level1+23)\n"
986 " #03 pc 000006f7 waiter (main+23)\n"
987 " #04 pc 00018275 libc.so\n",
988 frame_info);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800989 EXPECT_EQ(0x56598685U, unwinder.frames()[0].pc);
990 EXPECT_EQ(0xffcf9e38U, unwinder.frames()[0].sp);
991 EXPECT_EQ(0x565986b7U, unwinder.frames()[1].pc);
992 EXPECT_EQ(0xffcf9e50U, unwinder.frames()[1].sp);
993 EXPECT_EQ(0x565986d7U, unwinder.frames()[2].pc);
994 EXPECT_EQ(0xffcf9e60U, unwinder.frames()[2].sp);
995 EXPECT_EQ(0x565986f7U, unwinder.frames()[3].pc);
996 EXPECT_EQ(0xffcf9e70U, unwinder.frames()[3].sp);
997 EXPECT_EQ(0xf744a275U, unwinder.frames()[4].pc);
998 EXPECT_EQ(0xffcf9e80U, unwinder.frames()[4].sp);
Christopher Ferris1a141a02018-01-24 08:52:47 -0800999}
1000
Christopher Ferrise37e2d02018-02-09 15:57:39 -08001001// Make sure that a pc that is at the beginning of an fde unwinds correctly.
1002TEST_F(UnwindOfflineTest, eh_frame_hdr_begin_x86_64) {
Christopher Ferris239425b2018-05-17 18:37:38 -07001003 ASSERT_NO_FATAL_FAILURE(Init("eh_frame_hdr_begin_x86_64/", ARCH_X86_64));
Christopher Ferrise37e2d02018-02-09 15:57:39 -08001004
1005 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
1006 unwinder.Unwind();
1007
1008 std::string frame_info(DumpFrames(unwinder));
1009 ASSERT_EQ(5U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
1010 EXPECT_EQ(
1011 " #00 pc 0000000000000a80 unwind_test64 (calling3)\n"
1012 " #01 pc 0000000000000dd9 unwind_test64 (calling2+633)\n"
1013 " #02 pc 000000000000121e unwind_test64 (calling1+638)\n"
1014 " #03 pc 00000000000013ed unwind_test64 (main+13)\n"
1015 " #04 pc 00000000000202b0 libc.so\n",
1016 frame_info);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -08001017 EXPECT_EQ(0x561550b17a80U, unwinder.frames()[0].pc);
1018 EXPECT_EQ(0x7ffcc8596ce8U, unwinder.frames()[0].sp);
1019 EXPECT_EQ(0x561550b17dd9U, unwinder.frames()[1].pc);
1020 EXPECT_EQ(0x7ffcc8596cf0U, unwinder.frames()[1].sp);
1021 EXPECT_EQ(0x561550b1821eU, unwinder.frames()[2].pc);
1022 EXPECT_EQ(0x7ffcc8596f40U, unwinder.frames()[2].sp);
1023 EXPECT_EQ(0x561550b183edU, unwinder.frames()[3].pc);
1024 EXPECT_EQ(0x7ffcc8597190U, unwinder.frames()[3].sp);
1025 EXPECT_EQ(0x7f4de62162b0U, unwinder.frames()[4].pc);
1026 EXPECT_EQ(0x7ffcc85971a0U, unwinder.frames()[4].sp);
Christopher Ferrise37e2d02018-02-09 15:57:39 -08001027}
1028
Yabin Cui11e96fe2018-03-14 18:16:22 -07001029TEST_F(UnwindOfflineTest, art_quick_osr_stub_arm) {
Christopher Ferris239425b2018-05-17 18:37:38 -07001030 ASSERT_NO_FATAL_FAILURE(Init("art_quick_osr_stub_arm/", ARCH_ARM));
Yabin Cui11e96fe2018-03-14 18:16:22 -07001031
1032 MemoryOfflineParts* memory = new MemoryOfflineParts;
1033 AddMemory(dir_ + "descriptor.data", memory);
1034 AddMemory(dir_ + "stack.data", memory);
1035 for (size_t i = 0; i < 2; i++) {
1036 AddMemory(dir_ + "entry" + std::to_string(i) + ".data", memory);
1037 AddMemory(dir_ + "jit" + std::to_string(i) + ".data", memory);
1038 }
1039 process_memory_.reset(memory);
1040
David Srbeckyb9cc4fb2019-04-05 18:23:32 +00001041 JitDebug jit_debug(process_memory_);
Yabin Cui11e96fe2018-03-14 18:16:22 -07001042 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
David Srbeckyb9cc4fb2019-04-05 18:23:32 +00001043 unwinder.SetJitDebug(&jit_debug, regs_->Arch());
Yabin Cui11e96fe2018-03-14 18:16:22 -07001044 unwinder.Unwind();
1045
1046 std::string frame_info(DumpFrames(unwinder));
1047 ASSERT_EQ(25U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
1048 EXPECT_EQ(
1049 " #00 pc 0000c788 <anonymous:d0250000> "
1050 "(com.example.simpleperf.simpleperfexamplewithnative.MixActivity.access$000)\n"
1051 " #01 pc 0000cdd5 <anonymous:d0250000> "
1052 "(com.example.simpleperf.simpleperfexamplewithnative.MixActivity$1.run+60)\n"
1053 " #02 pc 004135bb libart.so (art_quick_osr_stub+42)\n"
1054 " #03 pc 002657a5 libart.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -08001055 "(art::jit::Jit::MaybeDoOnStackReplacement(art::Thread*, art::ArtMethod*, unsigned int, int, "
1056 "art::JValue*)+876)\n"
Yabin Cui11e96fe2018-03-14 18:16:22 -07001057 " #04 pc 004021a7 libart.so (MterpMaybeDoOnStackReplacement+86)\n"
1058 " #05 pc 00412474 libart.so (ExecuteMterpImpl+66164)\n"
1059 " #06 pc cd8365b0 <unknown>\n" // symbol in dex file
1060 " #07 pc 001d7f1b libart.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -08001061 "(art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, "
1062 "art::ShadowFrame&, art::JValue, bool)+374)\n"
Yabin Cui11e96fe2018-03-14 18:16:22 -07001063 " #08 pc 001dc593 libart.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -08001064 "(art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, "
1065 "art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+154)\n"
Yabin Cui11e96fe2018-03-14 18:16:22 -07001066 " #09 pc 001f4d01 libart.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -08001067 "(bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, "
1068 "art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+732)\n"
Yabin Cui11e96fe2018-03-14 18:16:22 -07001069 " #10 pc 003fe427 libart.so (MterpInvokeInterface+1354)\n"
1070 " #11 pc 00405b94 libart.so (ExecuteMterpImpl+14740)\n"
1071 " #12 pc 7004873e <unknown>\n" // symbol in dex file
1072 " #13 pc 001d7f1b libart.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -08001073 "(art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, "
1074 "art::ShadowFrame&, art::JValue, bool)+374)\n"
Yabin Cui11e96fe2018-03-14 18:16:22 -07001075 " #14 pc 001dc4d5 libart.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -08001076 "(art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor "
1077 "const&, art::ShadowFrame*)+92)\n"
Yabin Cui11e96fe2018-03-14 18:16:22 -07001078 " #15 pc 003f25ab libart.so (artQuickToInterpreterBridge+970)\n"
1079 " #16 pc 00417aff libart.so (art_quick_to_interpreter_bridge+30)\n"
1080 " #17 pc 00413575 libart.so (art_quick_invoke_stub_internal+68)\n"
1081 " #18 pc 00418531 libart.so (art_quick_invoke_stub+236)\n"
Christopher Ferriseb0772f2018-12-05 15:57:02 -08001082 " #19 pc 000b468d libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned "
1083 "int, art::JValue*, char const*)+136)\n"
Yabin Cui11e96fe2018-03-14 18:16:22 -07001084 " #20 pc 00362f49 libart.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -08001085 "(art::(anonymous namespace)::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable "
1086 "const&, art::ArtMethod*, art::(anonymous namespace)::ArgArray*, art::JValue*, char "
1087 "const*)+52)\n"
Yabin Cui11e96fe2018-03-14 18:16:22 -07001088 " #21 pc 00363cd9 libart.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -08001089 "(art::InvokeVirtualOrInterfaceWithJValues(art::ScopedObjectAccessAlreadyRunnable const&, "
1090 "_jobject*, _jmethodID*, jvalue*)+332)\n"
1091 " #22 pc 003851dd libart.so (art::Thread::CreateCallback(void*)+868)\n"
1092 " #23 pc 00062925 libc.so (__pthread_start(void*)+22)\n"
Yabin Cui11e96fe2018-03-14 18:16:22 -07001093 " #24 pc 0001de39 libc.so (__start_thread+24)\n",
1094 frame_info);
1095 EXPECT_EQ(0xd025c788U, unwinder.frames()[0].pc);
1096 EXPECT_EQ(0xcd4ff140U, unwinder.frames()[0].sp);
1097 EXPECT_EQ(0xd025cdd5U, unwinder.frames()[1].pc);
1098 EXPECT_EQ(0xcd4ff140U, unwinder.frames()[1].sp);
1099 EXPECT_EQ(0xe4a755bbU, unwinder.frames()[2].pc);
1100 EXPECT_EQ(0xcd4ff160U, unwinder.frames()[2].sp);
1101 EXPECT_EQ(0xe48c77a5U, unwinder.frames()[3].pc);
1102 EXPECT_EQ(0xcd4ff190U, unwinder.frames()[3].sp);
1103 EXPECT_EQ(0xe4a641a7U, unwinder.frames()[4].pc);
1104 EXPECT_EQ(0xcd4ff298U, unwinder.frames()[4].sp);
1105 EXPECT_EQ(0xe4a74474U, unwinder.frames()[5].pc);
1106 EXPECT_EQ(0xcd4ff2b8U, unwinder.frames()[5].sp);
1107 EXPECT_EQ(0xcd8365b0U, unwinder.frames()[6].pc);
1108 EXPECT_EQ(0xcd4ff2e0U, unwinder.frames()[6].sp);
1109 EXPECT_EQ(0xe4839f1bU, unwinder.frames()[7].pc);
1110 EXPECT_EQ(0xcd4ff2e0U, unwinder.frames()[7].sp);
1111 EXPECT_EQ(0xe483e593U, unwinder.frames()[8].pc);
1112 EXPECT_EQ(0xcd4ff330U, unwinder.frames()[8].sp);
1113 EXPECT_EQ(0xe4856d01U, unwinder.frames()[9].pc);
1114 EXPECT_EQ(0xcd4ff380U, unwinder.frames()[9].sp);
1115 EXPECT_EQ(0xe4a60427U, unwinder.frames()[10].pc);
1116 EXPECT_EQ(0xcd4ff430U, unwinder.frames()[10].sp);
1117 EXPECT_EQ(0xe4a67b94U, unwinder.frames()[11].pc);
1118 EXPECT_EQ(0xcd4ff498U, unwinder.frames()[11].sp);
1119 EXPECT_EQ(0x7004873eU, unwinder.frames()[12].pc);
1120 EXPECT_EQ(0xcd4ff4c0U, unwinder.frames()[12].sp);
1121 EXPECT_EQ(0xe4839f1bU, unwinder.frames()[13].pc);
1122 EXPECT_EQ(0xcd4ff4c0U, unwinder.frames()[13].sp);
1123 EXPECT_EQ(0xe483e4d5U, unwinder.frames()[14].pc);
1124 EXPECT_EQ(0xcd4ff510U, unwinder.frames()[14].sp);
1125 EXPECT_EQ(0xe4a545abU, unwinder.frames()[15].pc);
1126 EXPECT_EQ(0xcd4ff538U, unwinder.frames()[15].sp);
1127 EXPECT_EQ(0xe4a79affU, unwinder.frames()[16].pc);
1128 EXPECT_EQ(0xcd4ff640U, unwinder.frames()[16].sp);
1129 EXPECT_EQ(0xe4a75575U, unwinder.frames()[17].pc);
1130 EXPECT_EQ(0xcd4ff6b0U, unwinder.frames()[17].sp);
1131 EXPECT_EQ(0xe4a7a531U, unwinder.frames()[18].pc);
1132 EXPECT_EQ(0xcd4ff6e8U, unwinder.frames()[18].sp);
1133 EXPECT_EQ(0xe471668dU, unwinder.frames()[19].pc);
1134 EXPECT_EQ(0xcd4ff770U, unwinder.frames()[19].sp);
1135 EXPECT_EQ(0xe49c4f49U, unwinder.frames()[20].pc);
1136 EXPECT_EQ(0xcd4ff7c8U, unwinder.frames()[20].sp);
1137 EXPECT_EQ(0xe49c5cd9U, unwinder.frames()[21].pc);
1138 EXPECT_EQ(0xcd4ff850U, unwinder.frames()[21].sp);
1139 EXPECT_EQ(0xe49e71ddU, unwinder.frames()[22].pc);
1140 EXPECT_EQ(0xcd4ff8e8U, unwinder.frames()[22].sp);
1141 EXPECT_EQ(0xe7df3925U, unwinder.frames()[23].pc);
1142 EXPECT_EQ(0xcd4ff958U, unwinder.frames()[23].sp);
1143 EXPECT_EQ(0xe7daee39U, unwinder.frames()[24].pc);
1144 EXPECT_EQ(0xcd4ff960U, unwinder.frames()[24].sp);
1145}
1146
Yabin Cuid5b22c52018-02-22 17:11:31 -08001147TEST_F(UnwindOfflineTest, jit_map_arm) {
Christopher Ferris239425b2018-05-17 18:37:38 -07001148 ASSERT_NO_FATAL_FAILURE(Init("jit_map_arm/", ARCH_ARM));
Yabin Cuid5b22c52018-02-22 17:11:31 -08001149
1150 maps_->Add(0xd025c788, 0xd025c9f0, 0, PROT_READ | PROT_EXEC | MAPS_FLAGS_JIT_SYMFILE_MAP,
1151 "jit_map0.so", 0);
1152 maps_->Add(0xd025cd98, 0xd025cff4, 0, PROT_READ | PROT_EXEC | MAPS_FLAGS_JIT_SYMFILE_MAP,
1153 "jit_map1.so", 0);
1154 maps_->Sort();
1155
1156 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
1157 unwinder.Unwind();
1158
1159 std::string frame_info(DumpFrames(unwinder));
1160 ASSERT_EQ(6U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
1161 EXPECT_EQ(
1162 " #00 pc 00000000 jit_map0.so "
1163 "(com.example.simpleperf.simpleperfexamplewithnative.MixActivity.access$000)\n"
1164 " #01 pc 0000003d jit_map1.so "
1165 "(com.example.simpleperf.simpleperfexamplewithnative.MixActivity$1.run+60)\n"
1166 " #02 pc 004135bb libart.so (art_quick_osr_stub+42)\n"
1167
Christopher Ferriseb0772f2018-12-05 15:57:02 -08001168 " #03 pc 003851dd libart.so (art::Thread::CreateCallback(void*)+868)\n"
1169 " #04 pc 00062925 libc.so (__pthread_start(void*)+22)\n"
Yabin Cuid5b22c52018-02-22 17:11:31 -08001170 " #05 pc 0001de39 libc.so (__start_thread+24)\n",
1171 frame_info);
1172
1173 EXPECT_EQ(0xd025c788U, unwinder.frames()[0].pc);
1174 EXPECT_EQ(0xcd4ff140U, unwinder.frames()[0].sp);
1175 EXPECT_EQ(0xd025cdd5U, unwinder.frames()[1].pc);
1176 EXPECT_EQ(0xcd4ff140U, unwinder.frames()[1].sp);
1177 EXPECT_EQ(0xe4a755bbU, unwinder.frames()[2].pc);
1178 EXPECT_EQ(0xcd4ff160U, unwinder.frames()[2].sp);
1179 EXPECT_EQ(0xe49e71ddU, unwinder.frames()[3].pc);
1180 EXPECT_EQ(0xcd4ff8e8U, unwinder.frames()[3].sp);
1181 EXPECT_EQ(0xe7df3925U, unwinder.frames()[4].pc);
1182 EXPECT_EQ(0xcd4ff958U, unwinder.frames()[4].sp);
1183 EXPECT_EQ(0xe7daee39U, unwinder.frames()[5].pc);
1184 EXPECT_EQ(0xcd4ff960U, unwinder.frames()[5].sp);
1185}
1186
Christopher Ferris239425b2018-05-17 18:37:38 -07001187TEST_F(UnwindOfflineTest, offset_arm) {
1188 ASSERT_NO_FATAL_FAILURE(Init("offset_arm/", ARCH_ARM));
1189
1190 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
1191 unwinder.Unwind();
1192
1193 std::string frame_info(DumpFrames(unwinder));
1194 ASSERT_EQ(19U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
1195 EXPECT_EQ(
Christopher Ferrisa09c4a62018-12-13 16:08:50 -08001196 " #00 pc 0032bfa0 libunwindstack_test (SignalInnerFunction+40)\n"
1197 " #01 pc 0032bfeb libunwindstack_test (SignalMiddleFunction+2)\n"
1198 " #02 pc 0032bff3 libunwindstack_test (SignalOuterFunction+2)\n"
1199 " #03 pc 0032fed3 libunwindstack_test "
Christopher Ferriseb0772f2018-12-05 15:57:02 -08001200 "(unwindstack::SignalCallerHandler(int, siginfo*, void*)+26)\n"
Christopher Ferrisa09c4a62018-12-13 16:08:50 -08001201 " #04 pc 00026528 libc.so\n"
Christopher Ferris239425b2018-05-17 18:37:38 -07001202 " #05 pc 00000000 <unknown>\n"
Christopher Ferrisa09c4a62018-12-13 16:08:50 -08001203 " #06 pc 0032c2d9 libunwindstack_test (InnerFunction+736)\n"
1204 " #07 pc 0032cc4f libunwindstack_test (MiddleFunction+42)\n"
1205 " #08 pc 0032cc81 libunwindstack_test (OuterFunction+42)\n"
1206 " #09 pc 0032e547 libunwindstack_test "
Christopher Ferriseb0772f2018-12-05 15:57:02 -08001207 "(unwindstack::RemoteThroughSignal(int, unsigned int)+270)\n"
Christopher Ferrisa09c4a62018-12-13 16:08:50 -08001208 " #10 pc 0032ed99 libunwindstack_test "
Christopher Ferriseb0772f2018-12-05 15:57:02 -08001209 "(unwindstack::UnwindTest_remote_through_signal_with_invalid_func_Test::TestBody()+16)\n"
1210 " #11 pc 00354453 libunwindstack_test (testing::Test::Run()+154)\n"
1211 " #12 pc 00354de7 libunwindstack_test (testing::TestInfo::Run()+194)\n"
1212 " #13 pc 00355105 libunwindstack_test (testing::TestCase::Run()+180)\n"
Christopher Ferrisa09c4a62018-12-13 16:08:50 -08001213 " #14 pc 0035a215 libunwindstack_test "
Christopher Ferriseb0772f2018-12-05 15:57:02 -08001214 "(testing::internal::UnitTestImpl::RunAllTests()+664)\n"
1215 " #15 pc 00359f4f libunwindstack_test (testing::UnitTest::Run()+110)\n"
Christopher Ferrisa09c4a62018-12-13 16:08:50 -08001216 " #16 pc 0034d3db libunwindstack_test (main+38)\n"
1217 " #17 pc 00092c0d libc.so (__libc_init+48)\n"
1218 " #18 pc 0004202f libunwindstack_test (_start_main+38)\n",
Christopher Ferris239425b2018-05-17 18:37:38 -07001219 frame_info);
1220
1221 EXPECT_EQ(0x2e55fa0U, unwinder.frames()[0].pc);
1222 EXPECT_EQ(0xf43d2cccU, unwinder.frames()[0].sp);
1223 EXPECT_EQ(0x2e55febU, unwinder.frames()[1].pc);
1224 EXPECT_EQ(0xf43d2ce0U, unwinder.frames()[1].sp);
1225 EXPECT_EQ(0x2e55ff3U, unwinder.frames()[2].pc);
1226 EXPECT_EQ(0xf43d2ce8U, unwinder.frames()[2].sp);
1227 EXPECT_EQ(0x2e59ed3U, unwinder.frames()[3].pc);
1228 EXPECT_EQ(0xf43d2cf0U, unwinder.frames()[3].sp);
1229 EXPECT_EQ(0xf4136528U, unwinder.frames()[4].pc);
1230 EXPECT_EQ(0xf43d2d10U, unwinder.frames()[4].sp);
1231 EXPECT_EQ(0U, unwinder.frames()[5].pc);
1232 EXPECT_EQ(0xffcc0ee0U, unwinder.frames()[5].sp);
1233 EXPECT_EQ(0x2e562d9U, unwinder.frames()[6].pc);
1234 EXPECT_EQ(0xffcc0ee0U, unwinder.frames()[6].sp);
1235 EXPECT_EQ(0x2e56c4fU, unwinder.frames()[7].pc);
1236 EXPECT_EQ(0xffcc1060U, unwinder.frames()[7].sp);
1237 EXPECT_EQ(0x2e56c81U, unwinder.frames()[8].pc);
1238 EXPECT_EQ(0xffcc1078U, unwinder.frames()[8].sp);
1239 EXPECT_EQ(0x2e58547U, unwinder.frames()[9].pc);
1240 EXPECT_EQ(0xffcc1090U, unwinder.frames()[9].sp);
1241 EXPECT_EQ(0x2e58d99U, unwinder.frames()[10].pc);
1242 EXPECT_EQ(0xffcc1438U, unwinder.frames()[10].sp);
1243 EXPECT_EQ(0x2e7e453U, unwinder.frames()[11].pc);
1244 EXPECT_EQ(0xffcc1448U, unwinder.frames()[11].sp);
1245 EXPECT_EQ(0x2e7ede7U, unwinder.frames()[12].pc);
1246 EXPECT_EQ(0xffcc1458U, unwinder.frames()[12].sp);
1247 EXPECT_EQ(0x2e7f105U, unwinder.frames()[13].pc);
1248 EXPECT_EQ(0xffcc1490U, unwinder.frames()[13].sp);
1249 EXPECT_EQ(0x2e84215U, unwinder.frames()[14].pc);
1250 EXPECT_EQ(0xffcc14c0U, unwinder.frames()[14].sp);
1251 EXPECT_EQ(0x2e83f4fU, unwinder.frames()[15].pc);
1252 EXPECT_EQ(0xffcc1510U, unwinder.frames()[15].sp);
1253 EXPECT_EQ(0x2e773dbU, unwinder.frames()[16].pc);
1254 EXPECT_EQ(0xffcc1528U, unwinder.frames()[16].sp);
1255 EXPECT_EQ(0xf41a2c0dU, unwinder.frames()[17].pc);
1256 EXPECT_EQ(0xffcc1540U, unwinder.frames()[17].sp);
1257 EXPECT_EQ(0x2b6c02fU, unwinder.frames()[18].pc);
1258 EXPECT_EQ(0xffcc1558U, unwinder.frames()[18].sp);
1259}
1260
Christopher Ferris4cc36d22018-06-06 14:47:31 -07001261// Test using a non-zero load bias library that has the fde entries
1262// encoded as 0xb, which is not set as pc relative.
1263TEST_F(UnwindOfflineTest, debug_frame_load_bias_arm) {
1264 ASSERT_NO_FATAL_FAILURE(Init("debug_frame_load_bias_arm/", ARCH_ARM));
1265
1266 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
1267 unwinder.Unwind();
1268
1269 std::string frame_info(DumpFrames(unwinder));
1270 ASSERT_EQ(8U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
1271 EXPECT_EQ(
1272 " #00 pc 0005138c libc.so (__ioctl+8)\n"
1273 " #01 pc 0002140f libc.so (ioctl+30)\n"
Christopher Ferriseb0772f2018-12-05 15:57:02 -08001274 " #02 pc 00039535 libbinder.so (android::IPCThreadState::talkWithDriver(bool)+204)\n"
1275 " #03 pc 00039633 libbinder.so (android::IPCThreadState::getAndExecuteCommand()+10)\n"
1276 " #04 pc 00039b57 libbinder.so (android::IPCThreadState::joinThreadPool(bool)+38)\n"
Christopher Ferris4cc36d22018-06-06 14:47:31 -07001277 " #05 pc 00000c21 mediaserver (main+104)\n"
1278 " #06 pc 00084b89 libc.so (__libc_init+48)\n"
1279 " #07 pc 00000b77 mediaserver (_start_main+38)\n",
1280 frame_info);
1281
1282 EXPECT_EQ(0xf0be238cU, unwinder.frames()[0].pc);
1283 EXPECT_EQ(0xffd4a638U, unwinder.frames()[0].sp);
1284 EXPECT_EQ(0xf0bb240fU, unwinder.frames()[1].pc);
1285 EXPECT_EQ(0xffd4a638U, unwinder.frames()[1].sp);
1286 EXPECT_EQ(0xf1a75535U, unwinder.frames()[2].pc);
1287 EXPECT_EQ(0xffd4a650U, unwinder.frames()[2].sp);
1288 EXPECT_EQ(0xf1a75633U, unwinder.frames()[3].pc);
1289 EXPECT_EQ(0xffd4a6b0U, unwinder.frames()[3].sp);
1290 EXPECT_EQ(0xf1a75b57U, unwinder.frames()[4].pc);
1291 EXPECT_EQ(0xffd4a6d0U, unwinder.frames()[4].sp);
1292 EXPECT_EQ(0x8d1cc21U, unwinder.frames()[5].pc);
1293 EXPECT_EQ(0xffd4a6e8U, unwinder.frames()[5].sp);
1294 EXPECT_EQ(0xf0c15b89U, unwinder.frames()[6].pc);
1295 EXPECT_EQ(0xffd4a700U, unwinder.frames()[6].sp);
1296 EXPECT_EQ(0x8d1cb77U, unwinder.frames()[7].pc);
1297 EXPECT_EQ(0xffd4a718U, unwinder.frames()[7].sp);
1298}
1299
Christopher Ferris01040b12018-12-10 11:13:23 -08001300TEST_F(UnwindOfflineTest, shared_lib_in_apk_arm64) {
1301 ASSERT_NO_FATAL_FAILURE(Init("shared_lib_in_apk_arm64/", ARCH_ARM64));
1302
1303 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
1304 unwinder.Unwind();
1305
1306 std::string frame_info(DumpFrames(unwinder));
1307 ASSERT_EQ(7U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
1308 EXPECT_EQ(
Christopher Ferrisa09c4a62018-12-13 16:08:50 -08001309 " #00 pc 000000000014ccbc linker64 (__dl_syscall+28)\n"
1310 " #01 pc 000000000005426c linker64 "
Christopher Ferris01040b12018-12-10 11:13:23 -08001311 "(__dl__ZL24debuggerd_signal_handleriP7siginfoPv+1128)\n"
1312 " #02 pc 00000000000008bc vdso.so\n"
Christopher Ferrisa09c4a62018-12-13 16:08:50 -08001313 " #03 pc 00000000000846f4 libc.so (abort+172)\n"
1314 " #04 pc 0000000000084ad4 libc.so (__assert2+36)\n"
Christopher Ferris02a6c442019-03-11 14:43:33 -07001315 " #05 pc 000000000003d5b4 ANGLEPrebuilt.apk!libfeature_support_angle.so (offset 0x4000) "
1316 "(ANGLEGetUtilityAPI+56)\n"
Christopher Ferrisa09c4a62018-12-13 16:08:50 -08001317 " #06 pc 000000000007fe68 libc.so (__libc_init)\n",
Christopher Ferris01040b12018-12-10 11:13:23 -08001318 frame_info);
1319
1320 EXPECT_EQ(0x7e82c4fcbcULL, unwinder.frames()[0].pc);
1321 EXPECT_EQ(0x7df8ca3bf0ULL, unwinder.frames()[0].sp);
1322 EXPECT_EQ(0x7e82b5726cULL, unwinder.frames()[1].pc);
1323 EXPECT_EQ(0x7df8ca3bf0ULL, unwinder.frames()[1].sp);
1324 EXPECT_EQ(0x7e82b018bcULL, unwinder.frames()[2].pc);
1325 EXPECT_EQ(0x7df8ca3da0ULL, unwinder.frames()[2].sp);
1326 EXPECT_EQ(0x7e7eecc6f4ULL, unwinder.frames()[3].pc);
1327 EXPECT_EQ(0x7dabf3db60ULL, unwinder.frames()[3].sp);
1328 EXPECT_EQ(0x7e7eeccad4ULL, unwinder.frames()[4].pc);
1329 EXPECT_EQ(0x7dabf3dc40ULL, unwinder.frames()[4].sp);
1330 EXPECT_EQ(0x7dabc405b4ULL, unwinder.frames()[5].pc);
1331 EXPECT_EQ(0x7dabf3dc50ULL, unwinder.frames()[5].sp);
1332 EXPECT_EQ(0x7e7eec7e68ULL, unwinder.frames()[6].pc);
1333 EXPECT_EQ(0x7dabf3dc70ULL, unwinder.frames()[6].sp);
1334 // Ignore top frame since the test code was modified to end in __libc_init.
1335}
1336
1337TEST_F(UnwindOfflineTest, shared_lib_in_apk_memory_only_arm64) {
1338 ASSERT_NO_FATAL_FAILURE(Init("shared_lib_in_apk_memory_only_arm64/", ARCH_ARM64));
1339 // Add the memory that represents the shared library.
1340 MemoryOfflineParts* memory = reinterpret_cast<MemoryOfflineParts*>(process_memory_.get());
1341 AddMemory(dir_ + "lib_mem.data", memory);
1342
1343 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
1344 unwinder.Unwind();
1345
1346 std::string frame_info(DumpFrames(unwinder));
1347 ASSERT_EQ(7U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
1348 EXPECT_EQ(
Christopher Ferrisa09c4a62018-12-13 16:08:50 -08001349 " #00 pc 000000000014ccbc linker64 (__dl_syscall+28)\n"
1350 " #01 pc 000000000005426c linker64 "
Christopher Ferris01040b12018-12-10 11:13:23 -08001351 "(__dl__ZL24debuggerd_signal_handleriP7siginfoPv+1128)\n"
1352 " #02 pc 00000000000008bc vdso.so\n"
Christopher Ferrisa09c4a62018-12-13 16:08:50 -08001353 " #03 pc 00000000000846f4 libc.so (abort+172)\n"
1354 " #04 pc 0000000000084ad4 libc.so (__assert2+36)\n"
1355 " #05 pc 000000000003d5b4 ANGLEPrebuilt.apk (offset 0x21d5000)\n"
1356 " #06 pc 000000000007fe68 libc.so (__libc_init)\n",
Christopher Ferris01040b12018-12-10 11:13:23 -08001357 frame_info);
1358
1359 EXPECT_EQ(0x7e82c4fcbcULL, unwinder.frames()[0].pc);
1360 EXPECT_EQ(0x7df8ca3bf0ULL, unwinder.frames()[0].sp);
1361 EXPECT_EQ(0x7e82b5726cULL, unwinder.frames()[1].pc);
1362 EXPECT_EQ(0x7df8ca3bf0ULL, unwinder.frames()[1].sp);
1363 EXPECT_EQ(0x7e82b018bcULL, unwinder.frames()[2].pc);
1364 EXPECT_EQ(0x7df8ca3da0ULL, unwinder.frames()[2].sp);
1365 EXPECT_EQ(0x7e7eecc6f4ULL, unwinder.frames()[3].pc);
1366 EXPECT_EQ(0x7dabf3db60ULL, unwinder.frames()[3].sp);
1367 EXPECT_EQ(0x7e7eeccad4ULL, unwinder.frames()[4].pc);
1368 EXPECT_EQ(0x7dabf3dc40ULL, unwinder.frames()[4].sp);
1369 EXPECT_EQ(0x7dabc405b4ULL, unwinder.frames()[5].pc);
1370 EXPECT_EQ(0x7dabf3dc50ULL, unwinder.frames()[5].sp);
1371 EXPECT_EQ(0x7e7eec7e68ULL, unwinder.frames()[6].pc);
1372 EXPECT_EQ(0x7dabf3dc70ULL, unwinder.frames()[6].sp);
1373 // Ignore top frame since the test code was modified to end in __libc_init.
1374}
1375
Christopher Ferris86f2d9d2019-03-12 15:17:36 -07001376TEST_F(UnwindOfflineTest, shared_lib_in_apk_single_map_arm64) {
1377 ASSERT_NO_FATAL_FAILURE(Init("shared_lib_in_apk_single_map_arm64/", ARCH_ARM64));
1378
1379 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
1380 unwinder.Unwind();
1381
1382 std::string frame_info(DumpFrames(unwinder));
1383 ASSERT_EQ(13U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
1384 EXPECT_EQ(
1385 " #00 pc 00000000000814bc libc.so (syscall+28)\n"
1386 " #01 pc 00000000008cdf5c test.apk (offset 0x5000)\n"
1387 " #02 pc 00000000008cde9c test.apk (offset 0x5000)\n"
1388 " #03 pc 00000000008cdd70 test.apk (offset 0x5000)\n"
1389 " #04 pc 00000000008ce408 test.apk (offset 0x5000)\n"
1390 " #05 pc 00000000008ce8d8 test.apk (offset 0x5000)\n"
1391 " #06 pc 00000000008ce814 test.apk (offset 0x5000)\n"
1392 " #07 pc 00000000008bcf60 test.apk (offset 0x5000)\n"
1393 " #08 pc 0000000000133024 test.apk (offset 0x5000)\n"
1394 " #09 pc 0000000000134ad0 test.apk (offset 0x5000)\n"
1395 " #10 pc 0000000000134b64 test.apk (offset 0x5000)\n"
1396 " #11 pc 00000000000e406c libc.so (__pthread_start(void*)+36)\n"
1397 " #12 pc 0000000000085e18 libc.so (__start_thread+64)\n",
1398 frame_info);
1399
1400 EXPECT_EQ(0x7cbe0b14bcULL, unwinder.frames()[0].pc);
1401 EXPECT_EQ(0x7be4f077d0ULL, unwinder.frames()[0].sp);
1402 EXPECT_EQ(0x7be6715f5cULL, unwinder.frames()[1].pc);
1403 EXPECT_EQ(0x7be4f077d0ULL, unwinder.frames()[1].sp);
1404 EXPECT_EQ(0x7be6715e9cULL, unwinder.frames()[2].pc);
1405 EXPECT_EQ(0x7be4f07800ULL, unwinder.frames()[2].sp);
1406 EXPECT_EQ(0x7be6715d70ULL, unwinder.frames()[3].pc);
1407 EXPECT_EQ(0x7be4f07840ULL, unwinder.frames()[3].sp);
1408 EXPECT_EQ(0x7be6716408ULL, unwinder.frames()[4].pc);
1409 EXPECT_EQ(0x7be4f07860ULL, unwinder.frames()[4].sp);
1410 EXPECT_EQ(0x7be67168d8ULL, unwinder.frames()[5].pc);
1411 EXPECT_EQ(0x7be4f07880ULL, unwinder.frames()[5].sp);
1412 EXPECT_EQ(0x7be6716814ULL, unwinder.frames()[6].pc);
1413 EXPECT_EQ(0x7be4f078f0ULL, unwinder.frames()[6].sp);
1414 EXPECT_EQ(0x7be6704f60ULL, unwinder.frames()[7].pc);
1415 EXPECT_EQ(0x7be4f07910ULL, unwinder.frames()[7].sp);
1416 EXPECT_EQ(0x7be5f7b024ULL, unwinder.frames()[8].pc);
1417 EXPECT_EQ(0x7be4f07950ULL, unwinder.frames()[8].sp);
1418 EXPECT_EQ(0x7be5f7cad0ULL, unwinder.frames()[9].pc);
1419 EXPECT_EQ(0x7be4f07aa0ULL, unwinder.frames()[9].sp);
1420 EXPECT_EQ(0x7be5f7cb64ULL, unwinder.frames()[10].pc);
1421 EXPECT_EQ(0x7be4f07ce0ULL, unwinder.frames()[10].sp);
1422 EXPECT_EQ(0x7cbe11406cULL, unwinder.frames()[11].pc);
1423 EXPECT_EQ(0x7be4f07d00ULL, unwinder.frames()[11].sp);
1424 EXPECT_EQ(0x7cbe0b5e18ULL, unwinder.frames()[12].pc);
1425 EXPECT_EQ(0x7be4f07d20ULL, unwinder.frames()[12].sp);
1426}
1427
Christopher Ferrisc3d79f72017-11-28 19:14:54 -08001428} // namespace unwindstack