blob: baada8281cacc11c42d7ae2e6e0b83de8e4df98f [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>
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"
Casey Dahlin6b95a0e2019-03-12 17:50:52 -070045#include "MemoryOffline.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
Christopher Ferrisd49499d2019-06-10 18:37:32 -070065 void Init(const char* file_dir, ArchEnum arch, bool add_stack = true) {
Christopher Ferrise37e2d02018-02-09 15:57:39 -080066 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 Ferrisd49499d2019-06-10 18:37:32 -070074 if (add_stack) {
75 std::string stack_name(dir_ + "stack.data");
76 struct stat st;
77 if (stat(stack_name.c_str(), &st) == 0 && S_ISREG(st.st_mode)) {
78 std::unique_ptr<MemoryOffline> stack_memory(new MemoryOffline);
79 ASSERT_TRUE(stack_memory->Init((dir_ + "stack.data").c_str(), 0));
80 process_memory_.reset(stack_memory.release());
81 } else {
82 std::unique_ptr<MemoryOfflineParts> stack_memory(new MemoryOfflineParts);
83 for (size_t i = 0;; i++) {
84 stack_name = dir_ + "stack" + std::to_string(i) + ".data";
85 if (stat(stack_name.c_str(), &st) == -1 || !S_ISREG(st.st_mode)) {
86 ASSERT_TRUE(i != 0) << "No stack data files found.";
87 break;
88 }
89 AddMemory(stack_name, stack_memory.get());
Christopher Ferris239425b2018-05-17 18:37:38 -070090 }
Christopher Ferrisd49499d2019-06-10 18:37:32 -070091 process_memory_.reset(stack_memory.release());
Christopher Ferris239425b2018-05-17 18:37:38 -070092 }
Christopher Ferris239425b2018-05-17 18:37:38 -070093 }
Christopher Ferrise37e2d02018-02-09 15:57:39 -080094
95 switch (arch) {
96 case ARCH_ARM: {
97 RegsArm* regs = new RegsArm;
98 regs_.reset(regs);
99 ReadRegs<uint32_t>(regs, arm_regs_);
100 break;
101 }
102 case ARCH_ARM64: {
103 RegsArm64* regs = new RegsArm64;
104 regs_.reset(regs);
105 ReadRegs<uint64_t>(regs, arm64_regs_);
106 break;
107 }
108 case ARCH_X86: {
109 RegsX86* regs = new RegsX86;
110 regs_.reset(regs);
111 ReadRegs<uint32_t>(regs, x86_regs_);
112 break;
113 }
114 case ARCH_X86_64: {
115 RegsX86_64* regs = new RegsX86_64;
116 regs_.reset(regs);
117 ReadRegs<uint64_t>(regs, x86_64_regs_);
118 break;
119 }
120 default:
121 ASSERT_TRUE(false) << "Unknown arch " << std::to_string(arch);
122 }
123 cwd_ = getcwd(nullptr, 0);
124 // Make dir_ an absolute directory.
125 if (dir_.empty() || dir_[0] != '/') {
126 dir_ = std::string(cwd_) + '/' + dir_;
127 }
128 ASSERT_EQ(0, chdir(dir_.c_str()));
129 }
130
131 template <typename AddressType>
132 void ReadRegs(RegsImpl<AddressType>* regs,
133 const std::unordered_map<std::string, uint32_t>& name_to_reg) {
134 FILE* fp = fopen((dir_ + "regs.txt").c_str(), "r");
135 ASSERT_TRUE(fp != nullptr);
136 while (!feof(fp)) {
137 uint64_t value;
138 char reg_name[100];
139 ASSERT_EQ(2, fscanf(fp, "%s %" SCNx64 "\n", reg_name, &value));
140 std::string name(reg_name);
141 if (!name.empty()) {
142 // Remove the : from the end.
143 name.resize(name.size() - 1);
144 }
145 auto entry = name_to_reg.find(name);
146 ASSERT_TRUE(entry != name_to_reg.end()) << "Unknown register named " << name;
147 (*regs)[entry->second] = value;
148 }
149 fclose(fp);
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800150 }
151
152 static std::unordered_map<std::string, uint32_t> arm_regs_;
153 static std::unordered_map<std::string, uint32_t> arm64_regs_;
154 static std::unordered_map<std::string, uint32_t> x86_regs_;
155 static std::unordered_map<std::string, uint32_t> x86_64_regs_;
156
157 char* cwd_ = nullptr;
158 std::string dir_;
159 std::unique_ptr<Regs> regs_;
160 std::unique_ptr<Maps> maps_;
161 std::shared_ptr<Memory> process_memory_;
162};
163
164std::unordered_map<std::string, uint32_t> UnwindOfflineTest::arm_regs_ = {
165 {"r0", ARM_REG_R0}, {"r1", ARM_REG_R1}, {"r2", ARM_REG_R2}, {"r3", ARM_REG_R3},
166 {"r4", ARM_REG_R4}, {"r5", ARM_REG_R5}, {"r6", ARM_REG_R6}, {"r7", ARM_REG_R7},
167 {"r8", ARM_REG_R8}, {"r9", ARM_REG_R9}, {"r10", ARM_REG_R10}, {"r11", ARM_REG_R11},
168 {"ip", ARM_REG_R12}, {"sp", ARM_REG_SP}, {"lr", ARM_REG_LR}, {"pc", ARM_REG_PC},
169};
170
171std::unordered_map<std::string, uint32_t> UnwindOfflineTest::arm64_regs_ = {
172 {"x0", ARM64_REG_R0}, {"x1", ARM64_REG_R1}, {"x2", ARM64_REG_R2}, {"x3", ARM64_REG_R3},
173 {"x4", ARM64_REG_R4}, {"x5", ARM64_REG_R5}, {"x6", ARM64_REG_R6}, {"x7", ARM64_REG_R7},
174 {"x8", ARM64_REG_R8}, {"x9", ARM64_REG_R9}, {"x10", ARM64_REG_R10}, {"x11", ARM64_REG_R11},
175 {"x12", ARM64_REG_R12}, {"x13", ARM64_REG_R13}, {"x14", ARM64_REG_R14}, {"x15", ARM64_REG_R15},
176 {"x16", ARM64_REG_R16}, {"x17", ARM64_REG_R17}, {"x18", ARM64_REG_R18}, {"x19", ARM64_REG_R19},
177 {"x20", ARM64_REG_R20}, {"x21", ARM64_REG_R21}, {"x22", ARM64_REG_R22}, {"x23", ARM64_REG_R23},
178 {"x24", ARM64_REG_R24}, {"x25", ARM64_REG_R25}, {"x26", ARM64_REG_R26}, {"x27", ARM64_REG_R27},
179 {"x28", ARM64_REG_R28}, {"x29", ARM64_REG_R29}, {"sp", ARM64_REG_SP}, {"lr", ARM64_REG_LR},
180 {"pc", ARM64_REG_PC},
181};
182
183std::unordered_map<std::string, uint32_t> UnwindOfflineTest::x86_regs_ = {
184 {"eax", X86_REG_EAX}, {"ebx", X86_REG_EBX}, {"ecx", X86_REG_ECX},
185 {"edx", X86_REG_EDX}, {"ebp", X86_REG_EBP}, {"edi", X86_REG_EDI},
186 {"esi", X86_REG_ESI}, {"esp", X86_REG_ESP}, {"eip", X86_REG_EIP},
187};
188
189std::unordered_map<std::string, uint32_t> UnwindOfflineTest::x86_64_regs_ = {
190 {"rax", X86_64_REG_RAX}, {"rbx", X86_64_REG_RBX}, {"rcx", X86_64_REG_RCX},
191 {"rdx", X86_64_REG_RDX}, {"r8", X86_64_REG_R8}, {"r9", X86_64_REG_R9},
192 {"r10", X86_64_REG_R10}, {"r11", X86_64_REG_R11}, {"r12", X86_64_REG_R12},
193 {"r13", X86_64_REG_R13}, {"r14", X86_64_REG_R14}, {"r15", X86_64_REG_R15},
194 {"rdi", X86_64_REG_RDI}, {"rsi", X86_64_REG_RSI}, {"rbp", X86_64_REG_RBP},
195 {"rsp", X86_64_REG_RSP}, {"rip", X86_64_REG_RIP},
196};
197
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800198static std::string DumpFrames(Unwinder& unwinder) {
199 std::string str;
200 for (size_t i = 0; i < unwinder.NumFrames(); i++) {
201 str += unwinder.FormatFrame(i) + "\n";
202 }
203 return str;
204}
205
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800206TEST_F(UnwindOfflineTest, pc_straddle_arm) {
Christopher Ferris239425b2018-05-17 18:37:38 -0700207 ASSERT_NO_FATAL_FAILURE(Init("straddle_arm/", ARCH_ARM));
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800208
Christopher Ferris1760b452019-04-03 14:14:30 -0700209 std::unique_ptr<Regs> regs_copy(regs_->Clone());
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800210 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800211 unwinder.Unwind();
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800212
213 std::string frame_info(DumpFrames(unwinder));
214 ASSERT_EQ(4U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
215 EXPECT_EQ(
Christopher Ferris704ec9a2018-03-15 14:35:01 -0700216 " #00 pc 0001a9f8 libc.so (abort+64)\n"
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800217 " #01 pc 00006a1b libbase.so (android::base::DefaultAborter(char const*)+6)\n"
218 " #02 pc 00007441 libbase.so (android::base::LogMessage::~LogMessage()+748)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800219 " #03 pc 00015147 /does/not/exist/libhidlbase.so\n",
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800220 frame_info);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800221 EXPECT_EQ(0xf31ea9f8U, unwinder.frames()[0].pc);
222 EXPECT_EQ(0xe9c866f8U, unwinder.frames()[0].sp);
223 EXPECT_EQ(0xf2da0a1bU, unwinder.frames()[1].pc);
224 EXPECT_EQ(0xe9c86728U, unwinder.frames()[1].sp);
225 EXPECT_EQ(0xf2da1441U, unwinder.frames()[2].pc);
226 EXPECT_EQ(0xe9c86730U, unwinder.frames()[2].sp);
227 EXPECT_EQ(0xf3367147U, unwinder.frames()[3].pc);
228 EXPECT_EQ(0xe9c86778U, unwinder.frames()[3].sp);
Christopher Ferris1760b452019-04-03 14:14:30 -0700229
230 // Display build ids now.
231 unwinder.SetRegs(regs_copy.get());
232 unwinder.SetDisplayBuildID(true);
233 unwinder.Unwind();
234
235 frame_info = DumpFrames(unwinder);
236 ASSERT_EQ(4U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
237 EXPECT_EQ(
238 " #00 pc 0001a9f8 libc.so (abort+64) (BuildId: 2dd0d4ba881322a0edabeed94808048c)\n"
239 " #01 pc 00006a1b libbase.so (android::base::DefaultAborter(char const*)+6) (BuildId: "
240 "ed43842c239cac1a618e600ea91c4cbd)\n"
241 " #02 pc 00007441 libbase.so (android::base::LogMessage::~LogMessage()+748) (BuildId: "
242 "ed43842c239cac1a618e600ea91c4cbd)\n"
243 " #03 pc 00015147 /does/not/exist/libhidlbase.so\n",
244 frame_info);
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800245}
246
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800247TEST_F(UnwindOfflineTest, pc_in_gnu_debugdata_arm) {
Christopher Ferris239425b2018-05-17 18:37:38 -0700248 ASSERT_NO_FATAL_FAILURE(Init("gnu_debugdata_arm/", ARCH_ARM));
Christopher Ferrise7b66242017-12-15 11:17:45 -0800249
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800250 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
Christopher Ferrise7b66242017-12-15 11:17:45 -0800251 unwinder.Unwind();
Christopher Ferrise7b66242017-12-15 11:17:45 -0800252
253 std::string frame_info(DumpFrames(unwinder));
254 ASSERT_EQ(2U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
255 EXPECT_EQ(
256 " #00 pc 0006dc49 libandroid_runtime.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800257 "(android::AndroidRuntime::javaThreadShell(void*)+80)\n"
Christopher Ferrise7b66242017-12-15 11:17:45 -0800258 " #01 pc 0006dce5 libandroid_runtime.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800259 "(android::AndroidRuntime::javaCreateThreadEtc(int (*)(void*), void*, char const*, int, "
260 "unsigned int, void**))\n",
Christopher Ferrise7b66242017-12-15 11:17:45 -0800261 frame_info);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800262 EXPECT_EQ(0xf1f6dc49U, unwinder.frames()[0].pc);
263 EXPECT_EQ(0xd8fe6930U, unwinder.frames()[0].sp);
264 EXPECT_EQ(0xf1f6dce5U, unwinder.frames()[1].pc);
265 EXPECT_EQ(0xd8fe6958U, unwinder.frames()[1].sp);
Christopher Ferrise7b66242017-12-15 11:17:45 -0800266}
267
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800268TEST_F(UnwindOfflineTest, pc_straddle_arm64) {
Christopher Ferris239425b2018-05-17 18:37:38 -0700269 ASSERT_NO_FATAL_FAILURE(Init("straddle_arm64/", ARCH_ARM64));
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800270
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800271 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800272 unwinder.Unwind();
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800273
274 std::string frame_info(DumpFrames(unwinder));
275 ASSERT_EQ(6U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
276 EXPECT_EQ(
277 " #00 pc 0000000000429fd8 libunwindstack_test (SignalInnerFunction+24)\n"
278 " #01 pc 000000000042a078 libunwindstack_test (SignalMiddleFunction+8)\n"
279 " #02 pc 000000000042a08c libunwindstack_test (SignalOuterFunction+8)\n"
280 " #03 pc 000000000042d8fc libunwindstack_test "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800281 "(unwindstack::RemoteThroughSignal(int, unsigned int)+20)\n"
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800282 " #04 pc 000000000042d8d8 libunwindstack_test "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800283 "(unwindstack::UnwindTest_remote_through_signal_Test::TestBody()+32)\n"
284 " #05 pc 0000000000455d70 libunwindstack_test (testing::Test::Run()+392)\n",
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800285 frame_info);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800286 EXPECT_EQ(0x64d09d4fd8U, unwinder.frames()[0].pc);
287 EXPECT_EQ(0x7fe0d84040U, unwinder.frames()[0].sp);
288 EXPECT_EQ(0x64d09d5078U, unwinder.frames()[1].pc);
289 EXPECT_EQ(0x7fe0d84070U, unwinder.frames()[1].sp);
290 EXPECT_EQ(0x64d09d508cU, unwinder.frames()[2].pc);
291 EXPECT_EQ(0x7fe0d84080U, unwinder.frames()[2].sp);
292 EXPECT_EQ(0x64d09d88fcU, unwinder.frames()[3].pc);
293 EXPECT_EQ(0x7fe0d84090U, unwinder.frames()[3].sp);
294 EXPECT_EQ(0x64d09d88d8U, unwinder.frames()[4].pc);
295 EXPECT_EQ(0x7fe0d840f0U, unwinder.frames()[4].sp);
296 EXPECT_EQ(0x64d0a00d70U, unwinder.frames()[5].pc);
297 EXPECT_EQ(0x7fe0d84110U, unwinder.frames()[5].sp);
Christopher Ferrisc3d79f72017-11-28 19:14:54 -0800298}
299
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800300TEST_F(UnwindOfflineTest, jit_debug_x86) {
Christopher Ferris239425b2018-05-17 18:37:38 -0700301 ASSERT_NO_FATAL_FAILURE(Init("jit_debug_x86/", ARCH_X86));
Christopher Ferris150db122017-12-20 18:49:01 -0800302
303 MemoryOfflineParts* memory = new MemoryOfflineParts;
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800304 AddMemory(dir_ + "descriptor.data", memory);
305 AddMemory(dir_ + "stack.data", memory);
Christopher Ferris150db122017-12-20 18:49:01 -0800306 for (size_t i = 0; i < 7; i++) {
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800307 AddMemory(dir_ + "entry" + std::to_string(i) + ".data", memory);
308 AddMemory(dir_ + "jit" + std::to_string(i) + ".data", memory);
Christopher Ferris150db122017-12-20 18:49:01 -0800309 }
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800310 process_memory_.reset(memory);
Christopher Ferris150db122017-12-20 18:49:01 -0800311
David Srbeckyb9cc4fb2019-04-05 18:23:32 +0000312 JitDebug jit_debug(process_memory_);
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800313 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
David Srbeckyb9cc4fb2019-04-05 18:23:32 +0000314 unwinder.SetJitDebug(&jit_debug, regs_->Arch());
Christopher Ferris150db122017-12-20 18:49:01 -0800315 unwinder.Unwind();
Christopher Ferris150db122017-12-20 18:49:01 -0800316
317 std::string frame_info(DumpFrames(unwinder));
318 ASSERT_EQ(69U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
319 EXPECT_EQ(
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800320 " #00 pc 00068fb8 libarttestd.so (art::CauseSegfault()+72)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800321 " #01 pc 00067f00 libarttestd.so (Java_Main_unwindInProcess+10032)\n"
Christopher Ferris02a6c442019-03-11 14:43:33 -0700322 " #02 pc 000021a8 137-cfi.odex (boolean Main.unwindInProcess(boolean, int, "
Christopher Ferris150db122017-12-20 18:49:01 -0800323 "boolean)+136)\n"
Christopher Ferris6dbc28e2018-03-28 15:12:49 -0700324 " #03 pc 0000fe80 anonymous:ee74c000 (boolean Main.bar(boolean)+64)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800325 " #04 pc 006ad4d2 libartd.so (art_quick_invoke_stub+338)\n"
326 " #05 pc 00146ab5 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800327 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
328 "const*)+885)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800329 " #06 pc 0039cf0d libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800330 "(art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, "
331 "art::ShadowFrame*, unsigned short, art::JValue*)+653)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800332 " #07 pc 00392552 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800333 "(art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, "
334 "art::ShadowFrame&, art::JValue, bool)+354)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800335 " #08 pc 0039399a libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800336 "(art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor "
337 "const&, art::ShadowFrame*)+234)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800338 " #09 pc 00684362 libartd.so (artQuickToInterpreterBridge+1058)\n"
339 " #10 pc 006b35bd libartd.so (art_quick_to_interpreter_bridge+77)\n"
Christopher Ferris6dbc28e2018-03-28 15:12:49 -0700340 " #11 pc 0000fe03 anonymous:ee74c000 (int Main.compare(Main, Main)+51)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800341 " #12 pc 006ad4d2 libartd.so (art_quick_invoke_stub+338)\n"
342 " #13 pc 00146ab5 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800343 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
344 "const*)+885)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800345 " #14 pc 0039cf0d libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800346 "(art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, "
347 "art::ShadowFrame*, unsigned short, art::JValue*)+653)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800348 " #15 pc 00392552 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800349 "(art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, "
350 "art::ShadowFrame&, art::JValue, bool)+354)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800351 " #16 pc 0039399a libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800352 "(art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor "
353 "const&, art::ShadowFrame*)+234)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800354 " #17 pc 00684362 libartd.so (artQuickToInterpreterBridge+1058)\n"
355 " #18 pc 006b35bd libartd.so (art_quick_to_interpreter_bridge+77)\n"
Christopher Ferris6dbc28e2018-03-28 15:12:49 -0700356 " #19 pc 0000fd3b anonymous:ee74c000 (int Main.compare(java.lang.Object, "
357 "java.lang.Object)+107)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800358 " #20 pc 006ad4d2 libartd.so (art_quick_invoke_stub+338)\n"
359 " #21 pc 00146ab5 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800360 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
361 "const*)+885)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800362 " #22 pc 0039cf0d libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800363 "(art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, "
364 "art::ShadowFrame*, unsigned short, art::JValue*)+653)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800365 " #23 pc 00392552 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800366 "(art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, "
367 "art::ShadowFrame&, art::JValue, bool)+354)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800368 " #24 pc 0039399a libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800369 "(art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor "
370 "const&, art::ShadowFrame*)+234)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800371 " #25 pc 00684362 libartd.so (artQuickToInterpreterBridge+1058)\n"
372 " #26 pc 006b35bd libartd.so (art_quick_to_interpreter_bridge+77)\n"
Christopher Ferris6dbc28e2018-03-28 15:12:49 -0700373 " #27 pc 0000fbdb anonymous:ee74c000 (int "
Christopher Ferris150db122017-12-20 18:49:01 -0800374 "java.util.Arrays.binarySearch0(java.lang.Object[], int, int, java.lang.Object, "
Christopher Ferris6dbc28e2018-03-28 15:12:49 -0700375 "java.util.Comparator)+331)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800376 " #28 pc 006ad6a2 libartd.so (art_quick_invoke_static_stub+418)\n"
377 " #29 pc 00146acb libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800378 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
379 "const*)+907)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800380 " #30 pc 0039cf0d libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800381 "(art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, "
382 "art::ShadowFrame*, unsigned short, art::JValue*)+653)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800383 " #31 pc 00392552 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800384 "(art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, "
385 "art::ShadowFrame&, art::JValue, bool)+354)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800386 " #32 pc 0039399a libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800387 "(art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor "
388 "const&, art::ShadowFrame*)+234)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800389 " #33 pc 00684362 libartd.so (artQuickToInterpreterBridge+1058)\n"
390 " #34 pc 006b35bd libartd.so (art_quick_to_interpreter_bridge+77)\n"
Christopher Ferris6dbc28e2018-03-28 15:12:49 -0700391 " #35 pc 0000f624 anonymous:ee74c000 (boolean Main.foo()+164)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800392 " #36 pc 006ad4d2 libartd.so (art_quick_invoke_stub+338)\n"
393 " #37 pc 00146ab5 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800394 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
395 "const*)+885)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800396 " #38 pc 0039cf0d libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800397 "(art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, "
398 "art::ShadowFrame*, unsigned short, art::JValue*)+653)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800399 " #39 pc 00392552 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800400 "(art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, "
401 "art::ShadowFrame&, art::JValue, bool)+354)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800402 " #40 pc 0039399a libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800403 "(art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor "
404 "const&, art::ShadowFrame*)+234)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800405 " #41 pc 00684362 libartd.so (artQuickToInterpreterBridge+1058)\n"
406 " #42 pc 006b35bd libartd.so (art_quick_to_interpreter_bridge+77)\n"
Christopher Ferris6dbc28e2018-03-28 15:12:49 -0700407 " #43 pc 0000eedb anonymous:ee74c000 (void Main.runPrimary()+59)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800408 " #44 pc 006ad4d2 libartd.so (art_quick_invoke_stub+338)\n"
409 " #45 pc 00146ab5 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800410 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
411 "const*)+885)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800412 " #46 pc 0039cf0d libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800413 "(art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, "
414 "art::ShadowFrame*, unsigned short, art::JValue*)+653)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800415 " #47 pc 00392552 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800416 "(art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, "
417 "art::ShadowFrame&, art::JValue, bool)+354)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800418 " #48 pc 0039399a libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800419 "(art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor "
420 "const&, art::ShadowFrame*)+234)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800421 " #49 pc 00684362 libartd.so (artQuickToInterpreterBridge+1058)\n"
422 " #50 pc 006b35bd libartd.so (art_quick_to_interpreter_bridge+77)\n"
Christopher Ferris6dbc28e2018-03-28 15:12:49 -0700423 " #51 pc 0000ac21 anonymous:ee74c000 (void Main.main(java.lang.String[])+97)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800424 " #52 pc 006ad6a2 libartd.so (art_quick_invoke_static_stub+418)\n"
425 " #53 pc 00146acb libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800426 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
427 "const*)+907)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800428 " #54 pc 0039cf0d libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800429 "(art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, "
430 "art::ShadowFrame*, unsigned short, art::JValue*)+653)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800431 " #55 pc 00392552 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800432 "(art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, "
433 "art::ShadowFrame&, art::JValue, bool)+354)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800434 " #56 pc 0039399a libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800435 "(art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor "
436 "const&, art::ShadowFrame*)+234)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800437 " #57 pc 00684362 libartd.so (artQuickToInterpreterBridge+1058)\n"
438 " #58 pc 006b35bd libartd.so (art_quick_to_interpreter_bridge+77)\n"
439 " #59 pc 006ad6a2 libartd.so (art_quick_invoke_static_stub+418)\n"
440 " #60 pc 00146acb libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800441 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
442 "const*)+907)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800443 " #61 pc 005aac95 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800444 "(art::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, "
445 "art::ArgArray*, art::JValue*, char const*)+85)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800446 " #62 pc 005aab5a libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800447 "(art::InvokeWithVarArgs(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, "
448 "_jmethodID*, char*)+362)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800449 " #63 pc 0048a3dd libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800450 "(art::JNI::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, char*)+125)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800451 " #64 pc 0018448c libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800452 "(art::CheckJNI::CallMethodV(char const*, _JNIEnv*, _jobject*, _jclass*, _jmethodID*, char*, "
453 "art::Primitive::Type, art::InvokeType)+1964)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800454 " #65 pc 0017cf06 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800455 "(art::CheckJNI::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, char*)+70)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800456 " #66 pc 00001d8c dalvikvm32 "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800457 "(_JNIEnv::CallStaticVoidMethod(_jclass*, _jmethodID*, ...)+60)\n"
Christopher Ferris150db122017-12-20 18:49:01 -0800458 " #67 pc 00001a80 dalvikvm32 (main+1312)\n"
459 " #68 pc 00018275 libc.so\n",
460 frame_info);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800461 EXPECT_EQ(0xeb89bfb8U, unwinder.frames()[0].pc);
462 EXPECT_EQ(0xffeb5280U, unwinder.frames()[0].sp);
463 EXPECT_EQ(0xeb89af00U, unwinder.frames()[1].pc);
464 EXPECT_EQ(0xffeb52a0U, unwinder.frames()[1].sp);
465 EXPECT_EQ(0xec6061a8U, unwinder.frames()[2].pc);
466 EXPECT_EQ(0xffeb5ce0U, unwinder.frames()[2].sp);
Christopher Ferris6dbc28e2018-03-28 15:12:49 -0700467 EXPECT_EQ(0xee75be80U, unwinder.frames()[3].pc);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800468 EXPECT_EQ(0xffeb5d30U, unwinder.frames()[3].sp);
469 EXPECT_EQ(0xf728e4d2U, unwinder.frames()[4].pc);
470 EXPECT_EQ(0xffeb5d60U, unwinder.frames()[4].sp);
471 EXPECT_EQ(0xf6d27ab5U, unwinder.frames()[5].pc);
472 EXPECT_EQ(0xffeb5d80U, unwinder.frames()[5].sp);
473 EXPECT_EQ(0xf6f7df0dU, unwinder.frames()[6].pc);
474 EXPECT_EQ(0xffeb5e20U, unwinder.frames()[6].sp);
475 EXPECT_EQ(0xf6f73552U, unwinder.frames()[7].pc);
476 EXPECT_EQ(0xffeb5ec0U, unwinder.frames()[7].sp);
477 EXPECT_EQ(0xf6f7499aU, unwinder.frames()[8].pc);
478 EXPECT_EQ(0xffeb5f40U, unwinder.frames()[8].sp);
479 EXPECT_EQ(0xf7265362U, unwinder.frames()[9].pc);
480 EXPECT_EQ(0xffeb5fb0U, unwinder.frames()[9].sp);
481 EXPECT_EQ(0xf72945bdU, unwinder.frames()[10].pc);
482 EXPECT_EQ(0xffeb6110U, unwinder.frames()[10].sp);
Christopher Ferris6dbc28e2018-03-28 15:12:49 -0700483 EXPECT_EQ(0xee75be03U, unwinder.frames()[11].pc);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800484 EXPECT_EQ(0xffeb6160U, unwinder.frames()[11].sp);
485 EXPECT_EQ(0xf728e4d2U, unwinder.frames()[12].pc);
486 EXPECT_EQ(0xffeb6180U, unwinder.frames()[12].sp);
487 EXPECT_EQ(0xf6d27ab5U, unwinder.frames()[13].pc);
488 EXPECT_EQ(0xffeb61b0U, unwinder.frames()[13].sp);
489 EXPECT_EQ(0xf6f7df0dU, unwinder.frames()[14].pc);
490 EXPECT_EQ(0xffeb6250U, unwinder.frames()[14].sp);
491 EXPECT_EQ(0xf6f73552U, unwinder.frames()[15].pc);
492 EXPECT_EQ(0xffeb62f0U, unwinder.frames()[15].sp);
493 EXPECT_EQ(0xf6f7499aU, unwinder.frames()[16].pc);
494 EXPECT_EQ(0xffeb6370U, unwinder.frames()[16].sp);
495 EXPECT_EQ(0xf7265362U, unwinder.frames()[17].pc);
496 EXPECT_EQ(0xffeb63e0U, unwinder.frames()[17].sp);
497 EXPECT_EQ(0xf72945bdU, unwinder.frames()[18].pc);
498 EXPECT_EQ(0xffeb6530U, unwinder.frames()[18].sp);
Christopher Ferris6dbc28e2018-03-28 15:12:49 -0700499 EXPECT_EQ(0xee75bd3bU, unwinder.frames()[19].pc);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800500 EXPECT_EQ(0xffeb6580U, unwinder.frames()[19].sp);
501 EXPECT_EQ(0xf728e4d2U, unwinder.frames()[20].pc);
502 EXPECT_EQ(0xffeb65b0U, unwinder.frames()[20].sp);
503 EXPECT_EQ(0xf6d27ab5U, unwinder.frames()[21].pc);
504 EXPECT_EQ(0xffeb65e0U, unwinder.frames()[21].sp);
505 EXPECT_EQ(0xf6f7df0dU, unwinder.frames()[22].pc);
506 EXPECT_EQ(0xffeb6680U, unwinder.frames()[22].sp);
507 EXPECT_EQ(0xf6f73552U, unwinder.frames()[23].pc);
508 EXPECT_EQ(0xffeb6720U, unwinder.frames()[23].sp);
509 EXPECT_EQ(0xf6f7499aU, unwinder.frames()[24].pc);
510 EXPECT_EQ(0xffeb67a0U, unwinder.frames()[24].sp);
511 EXPECT_EQ(0xf7265362U, unwinder.frames()[25].pc);
512 EXPECT_EQ(0xffeb6810U, unwinder.frames()[25].sp);
513 EXPECT_EQ(0xf72945bdU, unwinder.frames()[26].pc);
514 EXPECT_EQ(0xffeb6960U, unwinder.frames()[26].sp);
Christopher Ferris6dbc28e2018-03-28 15:12:49 -0700515 EXPECT_EQ(0xee75bbdbU, unwinder.frames()[27].pc);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800516 EXPECT_EQ(0xffeb69b0U, unwinder.frames()[27].sp);
517 EXPECT_EQ(0xf728e6a2U, unwinder.frames()[28].pc);
518 EXPECT_EQ(0xffeb69f0U, unwinder.frames()[28].sp);
519 EXPECT_EQ(0xf6d27acbU, unwinder.frames()[29].pc);
520 EXPECT_EQ(0xffeb6a20U, unwinder.frames()[29].sp);
521 EXPECT_EQ(0xf6f7df0dU, unwinder.frames()[30].pc);
522 EXPECT_EQ(0xffeb6ac0U, unwinder.frames()[30].sp);
523 EXPECT_EQ(0xf6f73552U, unwinder.frames()[31].pc);
524 EXPECT_EQ(0xffeb6b60U, unwinder.frames()[31].sp);
525 EXPECT_EQ(0xf6f7499aU, unwinder.frames()[32].pc);
526 EXPECT_EQ(0xffeb6be0U, unwinder.frames()[32].sp);
527 EXPECT_EQ(0xf7265362U, unwinder.frames()[33].pc);
528 EXPECT_EQ(0xffeb6c50U, unwinder.frames()[33].sp);
529 EXPECT_EQ(0xf72945bdU, unwinder.frames()[34].pc);
530 EXPECT_EQ(0xffeb6dd0U, unwinder.frames()[34].sp);
Christopher Ferris6dbc28e2018-03-28 15:12:49 -0700531 EXPECT_EQ(0xee75b624U, unwinder.frames()[35].pc);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800532 EXPECT_EQ(0xffeb6e20U, unwinder.frames()[35].sp);
533 EXPECT_EQ(0xf728e4d2U, unwinder.frames()[36].pc);
534 EXPECT_EQ(0xffeb6e50U, unwinder.frames()[36].sp);
535 EXPECT_EQ(0xf6d27ab5U, unwinder.frames()[37].pc);
536 EXPECT_EQ(0xffeb6e70U, unwinder.frames()[37].sp);
537 EXPECT_EQ(0xf6f7df0dU, unwinder.frames()[38].pc);
538 EXPECT_EQ(0xffeb6f10U, unwinder.frames()[38].sp);
539 EXPECT_EQ(0xf6f73552U, unwinder.frames()[39].pc);
540 EXPECT_EQ(0xffeb6fb0U, unwinder.frames()[39].sp);
541 EXPECT_EQ(0xf6f7499aU, unwinder.frames()[40].pc);
542 EXPECT_EQ(0xffeb7030U, unwinder.frames()[40].sp);
543 EXPECT_EQ(0xf7265362U, unwinder.frames()[41].pc);
544 EXPECT_EQ(0xffeb70a0U, unwinder.frames()[41].sp);
545 EXPECT_EQ(0xf72945bdU, unwinder.frames()[42].pc);
546 EXPECT_EQ(0xffeb71f0U, unwinder.frames()[42].sp);
Christopher Ferris6dbc28e2018-03-28 15:12:49 -0700547 EXPECT_EQ(0xee75aedbU, unwinder.frames()[43].pc);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800548 EXPECT_EQ(0xffeb7240U, unwinder.frames()[43].sp);
549 EXPECT_EQ(0xf728e4d2U, unwinder.frames()[44].pc);
550 EXPECT_EQ(0xffeb72a0U, unwinder.frames()[44].sp);
551 EXPECT_EQ(0xf6d27ab5U, unwinder.frames()[45].pc);
552 EXPECT_EQ(0xffeb72c0U, unwinder.frames()[45].sp);
553 EXPECT_EQ(0xf6f7df0dU, unwinder.frames()[46].pc);
554 EXPECT_EQ(0xffeb7360U, unwinder.frames()[46].sp);
555 EXPECT_EQ(0xf6f73552U, unwinder.frames()[47].pc);
556 EXPECT_EQ(0xffeb7400U, unwinder.frames()[47].sp);
557 EXPECT_EQ(0xf6f7499aU, unwinder.frames()[48].pc);
558 EXPECT_EQ(0xffeb7480U, unwinder.frames()[48].sp);
559 EXPECT_EQ(0xf7265362U, unwinder.frames()[49].pc);
560 EXPECT_EQ(0xffeb74f0U, unwinder.frames()[49].sp);
561 EXPECT_EQ(0xf72945bdU, unwinder.frames()[50].pc);
562 EXPECT_EQ(0xffeb7680U, unwinder.frames()[50].sp);
Christopher Ferris6dbc28e2018-03-28 15:12:49 -0700563 EXPECT_EQ(0xee756c21U, unwinder.frames()[51].pc);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800564 EXPECT_EQ(0xffeb76d0U, unwinder.frames()[51].sp);
565 EXPECT_EQ(0xf728e6a2U, unwinder.frames()[52].pc);
566 EXPECT_EQ(0xffeb76f0U, unwinder.frames()[52].sp);
567 EXPECT_EQ(0xf6d27acbU, unwinder.frames()[53].pc);
568 EXPECT_EQ(0xffeb7710U, unwinder.frames()[53].sp);
569 EXPECT_EQ(0xf6f7df0dU, unwinder.frames()[54].pc);
570 EXPECT_EQ(0xffeb77b0U, unwinder.frames()[54].sp);
571 EXPECT_EQ(0xf6f73552U, unwinder.frames()[55].pc);
572 EXPECT_EQ(0xffeb7850U, unwinder.frames()[55].sp);
573 EXPECT_EQ(0xf6f7499aU, unwinder.frames()[56].pc);
574 EXPECT_EQ(0xffeb78d0U, unwinder.frames()[56].sp);
575 EXPECT_EQ(0xf7265362U, unwinder.frames()[57].pc);
576 EXPECT_EQ(0xffeb7940U, unwinder.frames()[57].sp);
577 EXPECT_EQ(0xf72945bdU, unwinder.frames()[58].pc);
578 EXPECT_EQ(0xffeb7a80U, unwinder.frames()[58].sp);
579 EXPECT_EQ(0xf728e6a2U, unwinder.frames()[59].pc);
580 EXPECT_EQ(0xffeb7ad0U, unwinder.frames()[59].sp);
581 EXPECT_EQ(0xf6d27acbU, unwinder.frames()[60].pc);
582 EXPECT_EQ(0xffeb7af0U, unwinder.frames()[60].sp);
583 EXPECT_EQ(0xf718bc95U, unwinder.frames()[61].pc);
584 EXPECT_EQ(0xffeb7b90U, unwinder.frames()[61].sp);
585 EXPECT_EQ(0xf718bb5aU, unwinder.frames()[62].pc);
586 EXPECT_EQ(0xffeb7c50U, unwinder.frames()[62].sp);
587 EXPECT_EQ(0xf706b3ddU, unwinder.frames()[63].pc);
588 EXPECT_EQ(0xffeb7d10U, unwinder.frames()[63].sp);
589 EXPECT_EQ(0xf6d6548cU, unwinder.frames()[64].pc);
590 EXPECT_EQ(0xffeb7d70U, unwinder.frames()[64].sp);
591 EXPECT_EQ(0xf6d5df06U, unwinder.frames()[65].pc);
592 EXPECT_EQ(0xffeb7df0U, unwinder.frames()[65].sp);
593 EXPECT_EQ(0x56574d8cU, unwinder.frames()[66].pc);
594 EXPECT_EQ(0xffeb7e40U, unwinder.frames()[66].sp);
595 EXPECT_EQ(0x56574a80U, unwinder.frames()[67].pc);
596 EXPECT_EQ(0xffeb7e70U, unwinder.frames()[67].sp);
597 EXPECT_EQ(0xf7363275U, unwinder.frames()[68].pc);
598 EXPECT_EQ(0xffeb7ef0U, unwinder.frames()[68].sp);
Christopher Ferris150db122017-12-20 18:49:01 -0800599}
600
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800601TEST_F(UnwindOfflineTest, jit_debug_arm) {
Christopher Ferris239425b2018-05-17 18:37:38 -0700602 ASSERT_NO_FATAL_FAILURE(Init("jit_debug_arm/", ARCH_ARM));
Christopher Ferrised37aca2018-01-12 15:53:19 -0800603
604 MemoryOfflineParts* memory = new MemoryOfflineParts;
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800605 AddMemory(dir_ + "descriptor.data", memory);
606 AddMemory(dir_ + "descriptor1.data", memory);
607 AddMemory(dir_ + "stack.data", memory);
Christopher Ferrised37aca2018-01-12 15:53:19 -0800608 for (size_t i = 0; i < 7; i++) {
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800609 AddMemory(dir_ + "entry" + std::to_string(i) + ".data", memory);
610 AddMemory(dir_ + "jit" + std::to_string(i) + ".data", memory);
Christopher Ferrised37aca2018-01-12 15:53:19 -0800611 }
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800612 process_memory_.reset(memory);
Christopher Ferrised37aca2018-01-12 15:53:19 -0800613
David Srbeckyb9cc4fb2019-04-05 18:23:32 +0000614 JitDebug jit_debug(process_memory_);
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800615 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
David Srbeckyb9cc4fb2019-04-05 18:23:32 +0000616 unwinder.SetJitDebug(&jit_debug, regs_->Arch());
Christopher Ferrised37aca2018-01-12 15:53:19 -0800617 unwinder.Unwind();
Christopher Ferrised37aca2018-01-12 15:53:19 -0800618
619 std::string frame_info(DumpFrames(unwinder));
620 ASSERT_EQ(76U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
621 EXPECT_EQ(
Christopher Ferris704ec9a2018-03-15 14:35:01 -0700622 " #00 pc 00018a5e libarttestd.so (Java_Main_unwindInProcess+866)\n"
Christopher Ferris02a6c442019-03-11 14:43:33 -0700623 " #01 pc 0000212d 137-cfi.odex (boolean Main.unwindInProcess(boolean, int, "
Christopher Ferrised37aca2018-01-12 15:53:19 -0800624 "boolean)+92)\n"
625 " #02 pc 00011cb1 anonymous:e2796000 (boolean Main.bar(boolean)+72)\n"
626 " #03 pc 00462175 libartd.so (art_quick_invoke_stub_internal+68)\n"
627 " #04 pc 00467129 libartd.so (art_quick_invoke_stub+228)\n"
628 " #05 pc 000bf7a9 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800629 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
630 "const*)+864)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800631 " #06 pc 00247833 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800632 "(art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, "
633 "art::ShadowFrame*, unsigned short, art::JValue*)+382)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800634 " #07 pc 0022e935 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800635 "(art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, "
636 "art::ShadowFrame&, art::JValue, bool)+244)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800637 " #08 pc 0022f71d libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800638 "(art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor "
639 "const&, art::ShadowFrame*)+128)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800640 " #09 pc 00442865 libartd.so (artQuickToInterpreterBridge+796)\n"
641 " #10 pc 004666ff libartd.so (art_quick_to_interpreter_bridge+30)\n"
642 " #11 pc 00011c31 anonymous:e2796000 (int Main.compare(Main, Main)+64)\n"
643 " #12 pc 00462175 libartd.so (art_quick_invoke_stub_internal+68)\n"
644 " #13 pc 00467129 libartd.so (art_quick_invoke_stub+228)\n"
645 " #14 pc 000bf7a9 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800646 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
647 "const*)+864)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800648 " #15 pc 00247833 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800649 "(art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, "
650 "art::ShadowFrame*, unsigned short, art::JValue*)+382)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800651 " #16 pc 0022e935 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800652 "(art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, "
653 "art::ShadowFrame&, art::JValue, bool)+244)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800654 " #17 pc 0022f71d libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800655 "(art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor "
656 "const&, art::ShadowFrame*)+128)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800657 " #18 pc 00442865 libartd.so (artQuickToInterpreterBridge+796)\n"
658 " #19 pc 004666ff libartd.so (art_quick_to_interpreter_bridge+30)\n"
659 " #20 pc 00011b77 anonymous:e2796000 (int Main.compare(java.lang.Object, "
660 "java.lang.Object)+118)\n"
661 " #21 pc 00462175 libartd.so (art_quick_invoke_stub_internal+68)\n"
662 " #22 pc 00467129 libartd.so (art_quick_invoke_stub+228)\n"
663 " #23 pc 000bf7a9 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800664 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
665 "const*)+864)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800666 " #24 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 " #25 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 " #26 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 " #27 pc 00442865 libartd.so (artQuickToInterpreterBridge+796)\n"
676 " #28 pc 004666ff libartd.so (art_quick_to_interpreter_bridge+30)\n"
677 " #29 pc 00011a29 anonymous:e2796000 (int "
678 "java.util.Arrays.binarySearch0(java.lang.Object[], int, int, java.lang.Object, "
679 "java.util.Comparator)+304)\n"
680 " #30 pc 00462175 libartd.so (art_quick_invoke_stub_internal+68)\n"
681 " #31 pc 0046722f libartd.so (art_quick_invoke_static_stub+226)\n"
682 " #32 pc 000bf7bb libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800683 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
684 "const*)+882)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800685 " #33 pc 00247833 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800686 "(art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, "
687 "art::ShadowFrame*, unsigned short, art::JValue*)+382)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800688 " #34 pc 0022e935 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800689 "(art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, "
690 "art::ShadowFrame&, art::JValue, bool)+244)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800691 " #35 pc 0022f71d libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800692 "(art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor "
693 "const&, art::ShadowFrame*)+128)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800694 " #36 pc 00442865 libartd.so (artQuickToInterpreterBridge+796)\n"
695 " #37 pc 004666ff libartd.so (art_quick_to_interpreter_bridge+30)\n"
696 " #38 pc 0001139b anonymous:e2796000 (boolean Main.foo()+178)\n"
697 " #39 pc 00462175 libartd.so (art_quick_invoke_stub_internal+68)\n"
698 " #40 pc 00467129 libartd.so (art_quick_invoke_stub+228)\n"
699 " #41 pc 000bf7a9 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800700 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
701 "const*)+864)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800702 " #42 pc 00247833 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800703 "(art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, "
704 "art::ShadowFrame*, unsigned short, art::JValue*)+382)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800705 " #43 pc 0022e935 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800706 "(art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, "
707 "art::ShadowFrame&, art::JValue, bool)+244)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800708 " #44 pc 0022f71d libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800709 "(art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor "
710 "const&, art::ShadowFrame*)+128)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800711 " #45 pc 00442865 libartd.so (artQuickToInterpreterBridge+796)\n"
712 " #46 pc 004666ff libartd.so (art_quick_to_interpreter_bridge+30)\n"
713 " #47 pc 00010aa7 anonymous:e2796000 (void Main.runPrimary()+70)\n"
714 " #48 pc 00462175 libartd.so (art_quick_invoke_stub_internal+68)\n"
715 " #49 pc 00467129 libartd.so (art_quick_invoke_stub+228)\n"
716 " #50 pc 000bf7a9 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800717 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
718 "const*)+864)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800719 " #51 pc 00247833 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800720 "(art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, "
721 "art::ShadowFrame*, unsigned short, art::JValue*)+382)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800722 " #52 pc 0022e935 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800723 "(art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, "
724 "art::ShadowFrame&, art::JValue, bool)+244)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800725 " #53 pc 0022f71d libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800726 "(art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor "
727 "const&, art::ShadowFrame*)+128)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800728 " #54 pc 00442865 libartd.so (artQuickToInterpreterBridge+796)\n"
729 " #55 pc 004666ff libartd.so (art_quick_to_interpreter_bridge+30)\n"
730 " #56 pc 0000ba99 anonymous:e2796000 (void Main.main(java.lang.String[])+144)\n"
731 " #57 pc 00462175 libartd.so (art_quick_invoke_stub_internal+68)\n"
732 " #58 pc 0046722f libartd.so (art_quick_invoke_static_stub+226)\n"
733 " #59 pc 000bf7bb libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800734 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
735 "const*)+882)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800736 " #60 pc 00247833 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800737 "(art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, "
738 "art::ShadowFrame*, unsigned short, art::JValue*)+382)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800739 " #61 pc 0022e935 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800740 "(art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, "
741 "art::ShadowFrame&, art::JValue, bool)+244)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800742 " #62 pc 0022f71d libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800743 "(art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor "
744 "const&, art::ShadowFrame*)+128)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800745 " #63 pc 00442865 libartd.so (artQuickToInterpreterBridge+796)\n"
746 " #64 pc 004666ff libartd.so (art_quick_to_interpreter_bridge+30)\n"
747 " #65 pc 00462175 libartd.so (art_quick_invoke_stub_internal+68)\n"
748 " #66 pc 0046722f libartd.so (art_quick_invoke_static_stub+226)\n"
749 " #67 pc 000bf7bb libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800750 "(art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char "
751 "const*)+882)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800752 " #68 pc 003b292d libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800753 "(art::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, "
754 "art::ArgArray*, art::JValue*, char const*)+52)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800755 " #69 pc 003b26c3 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800756 "(art::InvokeWithVarArgs(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, "
757 "_jmethodID*, std::__va_list)+210)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800758 " #70 pc 00308411 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800759 "(art::JNI::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, std::__va_list)+76)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800760 " #71 pc 000e6a9f libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800761 "(art::CheckJNI::CallMethodV(char const*, _JNIEnv*, _jobject*, _jclass*, _jmethodID*, "
762 "std::__va_list, art::Primitive::Type, art::InvokeType)+1486)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800763 " #72 pc 000e19b9 libartd.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800764 "(art::CheckJNI::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, std::__va_list)+40)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800765 " #73 pc 0000159f dalvikvm32 "
Christopher Ferriseb0772f2018-12-05 15:57:02 -0800766 "(_JNIEnv::CallStaticVoidMethod(_jclass*, _jmethodID*, ...)+30)\n"
Christopher Ferrised37aca2018-01-12 15:53:19 -0800767 " #74 pc 00001349 dalvikvm32 (main+896)\n"
768 " #75 pc 000850c9 libc.so\n",
769 frame_info);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800770 EXPECT_EQ(0xdfe66a5eU, unwinder.frames()[0].pc);
771 EXPECT_EQ(0xff85d180U, unwinder.frames()[0].sp);
772 EXPECT_EQ(0xe044712dU, unwinder.frames()[1].pc);
773 EXPECT_EQ(0xff85d200U, unwinder.frames()[1].sp);
774 EXPECT_EQ(0xe27a7cb1U, unwinder.frames()[2].pc);
775 EXPECT_EQ(0xff85d290U, unwinder.frames()[2].sp);
776 EXPECT_EQ(0xed75c175U, unwinder.frames()[3].pc);
777 EXPECT_EQ(0xff85d2b0U, unwinder.frames()[3].sp);
778 EXPECT_EQ(0xed761129U, unwinder.frames()[4].pc);
779 EXPECT_EQ(0xff85d2e8U, unwinder.frames()[4].sp);
780 EXPECT_EQ(0xed3b97a9U, unwinder.frames()[5].pc);
781 EXPECT_EQ(0xff85d370U, unwinder.frames()[5].sp);
782 EXPECT_EQ(0xed541833U, unwinder.frames()[6].pc);
783 EXPECT_EQ(0xff85d3d8U, unwinder.frames()[6].sp);
784 EXPECT_EQ(0xed528935U, unwinder.frames()[7].pc);
785 EXPECT_EQ(0xff85d428U, unwinder.frames()[7].sp);
786 EXPECT_EQ(0xed52971dU, unwinder.frames()[8].pc);
787 EXPECT_EQ(0xff85d470U, unwinder.frames()[8].sp);
788 EXPECT_EQ(0xed73c865U, unwinder.frames()[9].pc);
789 EXPECT_EQ(0xff85d4b0U, unwinder.frames()[9].sp);
790 EXPECT_EQ(0xed7606ffU, unwinder.frames()[10].pc);
791 EXPECT_EQ(0xff85d5d0U, unwinder.frames()[10].sp);
792 EXPECT_EQ(0xe27a7c31U, unwinder.frames()[11].pc);
793 EXPECT_EQ(0xff85d640U, unwinder.frames()[11].sp);
794 EXPECT_EQ(0xed75c175U, unwinder.frames()[12].pc);
795 EXPECT_EQ(0xff85d660U, unwinder.frames()[12].sp);
796 EXPECT_EQ(0xed761129U, unwinder.frames()[13].pc);
797 EXPECT_EQ(0xff85d698U, unwinder.frames()[13].sp);
798 EXPECT_EQ(0xed3b97a9U, unwinder.frames()[14].pc);
799 EXPECT_EQ(0xff85d720U, unwinder.frames()[14].sp);
800 EXPECT_EQ(0xed541833U, unwinder.frames()[15].pc);
801 EXPECT_EQ(0xff85d788U, unwinder.frames()[15].sp);
802 EXPECT_EQ(0xed528935U, unwinder.frames()[16].pc);
803 EXPECT_EQ(0xff85d7d8U, unwinder.frames()[16].sp);
804 EXPECT_EQ(0xed52971dU, unwinder.frames()[17].pc);
805 EXPECT_EQ(0xff85d820U, unwinder.frames()[17].sp);
806 EXPECT_EQ(0xed73c865U, unwinder.frames()[18].pc);
807 EXPECT_EQ(0xff85d860U, unwinder.frames()[18].sp);
808 EXPECT_EQ(0xed7606ffU, unwinder.frames()[19].pc);
809 EXPECT_EQ(0xff85d970U, unwinder.frames()[19].sp);
810 EXPECT_EQ(0xe27a7b77U, unwinder.frames()[20].pc);
811 EXPECT_EQ(0xff85d9e0U, unwinder.frames()[20].sp);
812 EXPECT_EQ(0xed75c175U, unwinder.frames()[21].pc);
813 EXPECT_EQ(0xff85da10U, unwinder.frames()[21].sp);
814 EXPECT_EQ(0xed761129U, unwinder.frames()[22].pc);
815 EXPECT_EQ(0xff85da48U, unwinder.frames()[22].sp);
816 EXPECT_EQ(0xed3b97a9U, unwinder.frames()[23].pc);
817 EXPECT_EQ(0xff85dad0U, unwinder.frames()[23].sp);
818 EXPECT_EQ(0xed541833U, unwinder.frames()[24].pc);
819 EXPECT_EQ(0xff85db38U, unwinder.frames()[24].sp);
820 EXPECT_EQ(0xed528935U, unwinder.frames()[25].pc);
821 EXPECT_EQ(0xff85db88U, unwinder.frames()[25].sp);
822 EXPECT_EQ(0xed52971dU, unwinder.frames()[26].pc);
823 EXPECT_EQ(0xff85dbd0U, unwinder.frames()[26].sp);
824 EXPECT_EQ(0xed73c865U, unwinder.frames()[27].pc);
825 EXPECT_EQ(0xff85dc10U, unwinder.frames()[27].sp);
826 EXPECT_EQ(0xed7606ffU, unwinder.frames()[28].pc);
827 EXPECT_EQ(0xff85dd20U, unwinder.frames()[28].sp);
828 EXPECT_EQ(0xe27a7a29U, unwinder.frames()[29].pc);
829 EXPECT_EQ(0xff85dd90U, unwinder.frames()[29].sp);
830 EXPECT_EQ(0xed75c175U, unwinder.frames()[30].pc);
831 EXPECT_EQ(0xff85ddc0U, unwinder.frames()[30].sp);
832 EXPECT_EQ(0xed76122fU, unwinder.frames()[31].pc);
833 EXPECT_EQ(0xff85de08U, unwinder.frames()[31].sp);
834 EXPECT_EQ(0xed3b97bbU, unwinder.frames()[32].pc);
835 EXPECT_EQ(0xff85de90U, unwinder.frames()[32].sp);
836 EXPECT_EQ(0xed541833U, unwinder.frames()[33].pc);
837 EXPECT_EQ(0xff85def8U, unwinder.frames()[33].sp);
838 EXPECT_EQ(0xed528935U, unwinder.frames()[34].pc);
839 EXPECT_EQ(0xff85df48U, unwinder.frames()[34].sp);
840 EXPECT_EQ(0xed52971dU, unwinder.frames()[35].pc);
841 EXPECT_EQ(0xff85df90U, unwinder.frames()[35].sp);
842 EXPECT_EQ(0xed73c865U, unwinder.frames()[36].pc);
843 EXPECT_EQ(0xff85dfd0U, unwinder.frames()[36].sp);
844 EXPECT_EQ(0xed7606ffU, unwinder.frames()[37].pc);
845 EXPECT_EQ(0xff85e110U, unwinder.frames()[37].sp);
846 EXPECT_EQ(0xe27a739bU, unwinder.frames()[38].pc);
847 EXPECT_EQ(0xff85e180U, unwinder.frames()[38].sp);
848 EXPECT_EQ(0xed75c175U, unwinder.frames()[39].pc);
849 EXPECT_EQ(0xff85e1b0U, unwinder.frames()[39].sp);
850 EXPECT_EQ(0xed761129U, unwinder.frames()[40].pc);
851 EXPECT_EQ(0xff85e1e0U, unwinder.frames()[40].sp);
852 EXPECT_EQ(0xed3b97a9U, unwinder.frames()[41].pc);
853 EXPECT_EQ(0xff85e268U, unwinder.frames()[41].sp);
854 EXPECT_EQ(0xed541833U, unwinder.frames()[42].pc);
855 EXPECT_EQ(0xff85e2d0U, unwinder.frames()[42].sp);
856 EXPECT_EQ(0xed528935U, unwinder.frames()[43].pc);
857 EXPECT_EQ(0xff85e320U, unwinder.frames()[43].sp);
858 EXPECT_EQ(0xed52971dU, unwinder.frames()[44].pc);
859 EXPECT_EQ(0xff85e368U, unwinder.frames()[44].sp);
860 EXPECT_EQ(0xed73c865U, unwinder.frames()[45].pc);
861 EXPECT_EQ(0xff85e3a8U, unwinder.frames()[45].sp);
862 EXPECT_EQ(0xed7606ffU, unwinder.frames()[46].pc);
863 EXPECT_EQ(0xff85e4c0U, unwinder.frames()[46].sp);
864 EXPECT_EQ(0xe27a6aa7U, unwinder.frames()[47].pc);
865 EXPECT_EQ(0xff85e530U, unwinder.frames()[47].sp);
866 EXPECT_EQ(0xed75c175U, unwinder.frames()[48].pc);
867 EXPECT_EQ(0xff85e5a0U, unwinder.frames()[48].sp);
868 EXPECT_EQ(0xed761129U, unwinder.frames()[49].pc);
869 EXPECT_EQ(0xff85e5d8U, unwinder.frames()[49].sp);
870 EXPECT_EQ(0xed3b97a9U, unwinder.frames()[50].pc);
871 EXPECT_EQ(0xff85e660U, unwinder.frames()[50].sp);
872 EXPECT_EQ(0xed541833U, unwinder.frames()[51].pc);
873 EXPECT_EQ(0xff85e6c8U, unwinder.frames()[51].sp);
874 EXPECT_EQ(0xed528935U, unwinder.frames()[52].pc);
875 EXPECT_EQ(0xff85e718U, unwinder.frames()[52].sp);
876 EXPECT_EQ(0xed52971dU, unwinder.frames()[53].pc);
877 EXPECT_EQ(0xff85e760U, unwinder.frames()[53].sp);
878 EXPECT_EQ(0xed73c865U, unwinder.frames()[54].pc);
879 EXPECT_EQ(0xff85e7a0U, unwinder.frames()[54].sp);
880 EXPECT_EQ(0xed7606ffU, unwinder.frames()[55].pc);
881 EXPECT_EQ(0xff85e8f0U, unwinder.frames()[55].sp);
882 EXPECT_EQ(0xe27a1a99U, unwinder.frames()[56].pc);
883 EXPECT_EQ(0xff85e960U, unwinder.frames()[56].sp);
884 EXPECT_EQ(0xed75c175U, unwinder.frames()[57].pc);
885 EXPECT_EQ(0xff85e990U, unwinder.frames()[57].sp);
886 EXPECT_EQ(0xed76122fU, unwinder.frames()[58].pc);
887 EXPECT_EQ(0xff85e9c8U, unwinder.frames()[58].sp);
888 EXPECT_EQ(0xed3b97bbU, unwinder.frames()[59].pc);
889 EXPECT_EQ(0xff85ea50U, unwinder.frames()[59].sp);
890 EXPECT_EQ(0xed541833U, unwinder.frames()[60].pc);
891 EXPECT_EQ(0xff85eab8U, unwinder.frames()[60].sp);
892 EXPECT_EQ(0xed528935U, unwinder.frames()[61].pc);
893 EXPECT_EQ(0xff85eb08U, unwinder.frames()[61].sp);
894 EXPECT_EQ(0xed52971dU, unwinder.frames()[62].pc);
895 EXPECT_EQ(0xff85eb50U, unwinder.frames()[62].sp);
896 EXPECT_EQ(0xed73c865U, unwinder.frames()[63].pc);
897 EXPECT_EQ(0xff85eb90U, unwinder.frames()[63].sp);
898 EXPECT_EQ(0xed7606ffU, unwinder.frames()[64].pc);
899 EXPECT_EQ(0xff85ec90U, unwinder.frames()[64].sp);
900 EXPECT_EQ(0xed75c175U, unwinder.frames()[65].pc);
901 EXPECT_EQ(0xff85ed00U, unwinder.frames()[65].sp);
902 EXPECT_EQ(0xed76122fU, unwinder.frames()[66].pc);
903 EXPECT_EQ(0xff85ed38U, unwinder.frames()[66].sp);
904 EXPECT_EQ(0xed3b97bbU, unwinder.frames()[67].pc);
905 EXPECT_EQ(0xff85edc0U, unwinder.frames()[67].sp);
906 EXPECT_EQ(0xed6ac92dU, unwinder.frames()[68].pc);
907 EXPECT_EQ(0xff85ee28U, unwinder.frames()[68].sp);
908 EXPECT_EQ(0xed6ac6c3U, unwinder.frames()[69].pc);
909 EXPECT_EQ(0xff85eeb8U, unwinder.frames()[69].sp);
910 EXPECT_EQ(0xed602411U, unwinder.frames()[70].pc);
911 EXPECT_EQ(0xff85ef48U, unwinder.frames()[70].sp);
912 EXPECT_EQ(0xed3e0a9fU, unwinder.frames()[71].pc);
913 EXPECT_EQ(0xff85ef90U, unwinder.frames()[71].sp);
914 EXPECT_EQ(0xed3db9b9U, unwinder.frames()[72].pc);
915 EXPECT_EQ(0xff85f008U, unwinder.frames()[72].sp);
916 EXPECT_EQ(0xab0d459fU, unwinder.frames()[73].pc);
917 EXPECT_EQ(0xff85f038U, unwinder.frames()[73].sp);
918 EXPECT_EQ(0xab0d4349U, unwinder.frames()[74].pc);
919 EXPECT_EQ(0xff85f050U, unwinder.frames()[74].sp);
920 EXPECT_EQ(0xedb0d0c9U, unwinder.frames()[75].pc);
921 EXPECT_EQ(0xff85f0c0U, unwinder.frames()[75].sp);
Christopher Ferrised37aca2018-01-12 15:53:19 -0800922}
923
Christopher Ferrise1f7a632019-01-24 12:22:03 -0800924struct LeakType {
925 LeakType(Maps* maps, Regs* regs, std::shared_ptr<Memory>& process_memory)
926 : maps(maps), regs(regs), process_memory(process_memory) {}
927
928 Maps* maps;
929 Regs* regs;
930 std::shared_ptr<Memory>& process_memory;
931};
932
933static void OfflineUnwind(void* data) {
934 LeakType* leak_data = reinterpret_cast<LeakType*>(data);
935
936 std::unique_ptr<Regs> regs_copy(leak_data->regs->Clone());
David Srbeckyb9cc4fb2019-04-05 18:23:32 +0000937 JitDebug jit_debug(leak_data->process_memory);
Christopher Ferrise1f7a632019-01-24 12:22:03 -0800938 Unwinder unwinder(128, leak_data->maps, regs_copy.get(), leak_data->process_memory);
David Srbeckyb9cc4fb2019-04-05 18:23:32 +0000939 unwinder.SetJitDebug(&jit_debug, regs_copy->Arch());
Christopher Ferrise1f7a632019-01-24 12:22:03 -0800940 unwinder.Unwind();
941 ASSERT_EQ(76U, unwinder.NumFrames());
942}
943
944TEST_F(UnwindOfflineTest, unwind_offline_check_for_leaks) {
945 ASSERT_NO_FATAL_FAILURE(Init("jit_debug_arm/", ARCH_ARM));
946
947 MemoryOfflineParts* memory = new MemoryOfflineParts;
948 AddMemory(dir_ + "descriptor.data", memory);
949 AddMemory(dir_ + "descriptor1.data", memory);
950 AddMemory(dir_ + "stack.data", memory);
951 for (size_t i = 0; i < 7; i++) {
952 AddMemory(dir_ + "entry" + std::to_string(i) + ".data", memory);
953 AddMemory(dir_ + "jit" + std::to_string(i) + ".data", memory);
954 }
955 process_memory_.reset(memory);
956
957 LeakType data(maps_.get(), regs_.get(), process_memory_);
958 TestCheckForLeaks(OfflineUnwind, &data);
959}
960
Christopher Ferris1a141a02018-01-24 08:52:47 -0800961// The eh_frame_hdr data is present but set to zero fdes. This should
962// fallback to iterating over the cies/fdes and ignore the eh_frame_hdr.
963// No .gnu_debugdata section in the elf file, so no symbols.
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800964TEST_F(UnwindOfflineTest, bad_eh_frame_hdr_arm64) {
Christopher Ferris239425b2018-05-17 18:37:38 -0700965 ASSERT_NO_FATAL_FAILURE(Init("bad_eh_frame_hdr_arm64/", ARCH_ARM64));
Christopher Ferris1a141a02018-01-24 08:52:47 -0800966
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800967 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
Christopher Ferris1a141a02018-01-24 08:52:47 -0800968 unwinder.Unwind();
Christopher Ferris1a141a02018-01-24 08:52:47 -0800969
970 std::string frame_info(DumpFrames(unwinder));
971 ASSERT_EQ(5U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
972 EXPECT_EQ(
973 " #00 pc 0000000000000550 waiter64\n"
974 " #01 pc 0000000000000568 waiter64\n"
975 " #02 pc 000000000000057c waiter64\n"
976 " #03 pc 0000000000000590 waiter64\n"
977 " #04 pc 00000000000a8e98 libc.so (__libc_init+88)\n",
978 frame_info);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -0800979 EXPECT_EQ(0x60a9fdf550U, unwinder.frames()[0].pc);
980 EXPECT_EQ(0x7fdd141990U, unwinder.frames()[0].sp);
981 EXPECT_EQ(0x60a9fdf568U, unwinder.frames()[1].pc);
982 EXPECT_EQ(0x7fdd1419a0U, unwinder.frames()[1].sp);
983 EXPECT_EQ(0x60a9fdf57cU, unwinder.frames()[2].pc);
984 EXPECT_EQ(0x7fdd1419b0U, unwinder.frames()[2].sp);
985 EXPECT_EQ(0x60a9fdf590U, unwinder.frames()[3].pc);
986 EXPECT_EQ(0x7fdd1419c0U, unwinder.frames()[3].sp);
987 EXPECT_EQ(0x7542d68e98U, unwinder.frames()[4].pc);
988 EXPECT_EQ(0x7fdd1419d0U, unwinder.frames()[4].sp);
Christopher Ferris1a141a02018-01-24 08:52:47 -0800989}
990
991// The elf has bad eh_frame unwind information for the pcs. If eh_frame
992// is used first, the unwind will not match the expected output.
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800993TEST_F(UnwindOfflineTest, debug_frame_first_x86) {
Christopher Ferris239425b2018-05-17 18:37:38 -0700994 ASSERT_NO_FATAL_FAILURE(Init("debug_frame_first_x86/", ARCH_X86));
Christopher Ferris1a141a02018-01-24 08:52:47 -0800995
Christopher Ferrise37e2d02018-02-09 15:57:39 -0800996 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
Christopher Ferris1a141a02018-01-24 08:52:47 -0800997 unwinder.Unwind();
Christopher Ferris1a141a02018-01-24 08:52:47 -0800998
999 std::string frame_info(DumpFrames(unwinder));
1000 ASSERT_EQ(5U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
1001 EXPECT_EQ(
1002 " #00 pc 00000685 waiter (call_level3+53)\n"
1003 " #01 pc 000006b7 waiter (call_level2+23)\n"
1004 " #02 pc 000006d7 waiter (call_level1+23)\n"
1005 " #03 pc 000006f7 waiter (main+23)\n"
1006 " #04 pc 00018275 libc.so\n",
1007 frame_info);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -08001008 EXPECT_EQ(0x56598685U, unwinder.frames()[0].pc);
1009 EXPECT_EQ(0xffcf9e38U, unwinder.frames()[0].sp);
1010 EXPECT_EQ(0x565986b7U, unwinder.frames()[1].pc);
1011 EXPECT_EQ(0xffcf9e50U, unwinder.frames()[1].sp);
1012 EXPECT_EQ(0x565986d7U, unwinder.frames()[2].pc);
1013 EXPECT_EQ(0xffcf9e60U, unwinder.frames()[2].sp);
1014 EXPECT_EQ(0x565986f7U, unwinder.frames()[3].pc);
1015 EXPECT_EQ(0xffcf9e70U, unwinder.frames()[3].sp);
1016 EXPECT_EQ(0xf744a275U, unwinder.frames()[4].pc);
1017 EXPECT_EQ(0xffcf9e80U, unwinder.frames()[4].sp);
Christopher Ferris1a141a02018-01-24 08:52:47 -08001018}
1019
Christopher Ferrise37e2d02018-02-09 15:57:39 -08001020// Make sure that a pc that is at the beginning of an fde unwinds correctly.
1021TEST_F(UnwindOfflineTest, eh_frame_hdr_begin_x86_64) {
Christopher Ferris239425b2018-05-17 18:37:38 -07001022 ASSERT_NO_FATAL_FAILURE(Init("eh_frame_hdr_begin_x86_64/", ARCH_X86_64));
Christopher Ferrise37e2d02018-02-09 15:57:39 -08001023
1024 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
1025 unwinder.Unwind();
1026
1027 std::string frame_info(DumpFrames(unwinder));
1028 ASSERT_EQ(5U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
1029 EXPECT_EQ(
1030 " #00 pc 0000000000000a80 unwind_test64 (calling3)\n"
1031 " #01 pc 0000000000000dd9 unwind_test64 (calling2+633)\n"
1032 " #02 pc 000000000000121e unwind_test64 (calling1+638)\n"
1033 " #03 pc 00000000000013ed unwind_test64 (main+13)\n"
1034 " #04 pc 00000000000202b0 libc.so\n",
1035 frame_info);
Christopher Ferrisa2ec50b2018-02-21 15:39:07 -08001036 EXPECT_EQ(0x561550b17a80U, unwinder.frames()[0].pc);
1037 EXPECT_EQ(0x7ffcc8596ce8U, unwinder.frames()[0].sp);
1038 EXPECT_EQ(0x561550b17dd9U, unwinder.frames()[1].pc);
1039 EXPECT_EQ(0x7ffcc8596cf0U, unwinder.frames()[1].sp);
1040 EXPECT_EQ(0x561550b1821eU, unwinder.frames()[2].pc);
1041 EXPECT_EQ(0x7ffcc8596f40U, unwinder.frames()[2].sp);
1042 EXPECT_EQ(0x561550b183edU, unwinder.frames()[3].pc);
1043 EXPECT_EQ(0x7ffcc8597190U, unwinder.frames()[3].sp);
1044 EXPECT_EQ(0x7f4de62162b0U, unwinder.frames()[4].pc);
1045 EXPECT_EQ(0x7ffcc85971a0U, unwinder.frames()[4].sp);
Christopher Ferrise37e2d02018-02-09 15:57:39 -08001046}
1047
Yabin Cui11e96fe2018-03-14 18:16:22 -07001048TEST_F(UnwindOfflineTest, art_quick_osr_stub_arm) {
Christopher Ferris239425b2018-05-17 18:37:38 -07001049 ASSERT_NO_FATAL_FAILURE(Init("art_quick_osr_stub_arm/", ARCH_ARM));
Yabin Cui11e96fe2018-03-14 18:16:22 -07001050
1051 MemoryOfflineParts* memory = new MemoryOfflineParts;
1052 AddMemory(dir_ + "descriptor.data", memory);
1053 AddMemory(dir_ + "stack.data", memory);
1054 for (size_t i = 0; i < 2; i++) {
1055 AddMemory(dir_ + "entry" + std::to_string(i) + ".data", memory);
1056 AddMemory(dir_ + "jit" + std::to_string(i) + ".data", memory);
1057 }
1058 process_memory_.reset(memory);
1059
David Srbeckyb9cc4fb2019-04-05 18:23:32 +00001060 JitDebug jit_debug(process_memory_);
Yabin Cui11e96fe2018-03-14 18:16:22 -07001061 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
David Srbeckyb9cc4fb2019-04-05 18:23:32 +00001062 unwinder.SetJitDebug(&jit_debug, regs_->Arch());
Yabin Cui11e96fe2018-03-14 18:16:22 -07001063 unwinder.Unwind();
1064
1065 std::string frame_info(DumpFrames(unwinder));
1066 ASSERT_EQ(25U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
1067 EXPECT_EQ(
1068 " #00 pc 0000c788 <anonymous:d0250000> "
1069 "(com.example.simpleperf.simpleperfexamplewithnative.MixActivity.access$000)\n"
1070 " #01 pc 0000cdd5 <anonymous:d0250000> "
1071 "(com.example.simpleperf.simpleperfexamplewithnative.MixActivity$1.run+60)\n"
1072 " #02 pc 004135bb libart.so (art_quick_osr_stub+42)\n"
1073 " #03 pc 002657a5 libart.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -08001074 "(art::jit::Jit::MaybeDoOnStackReplacement(art::Thread*, art::ArtMethod*, unsigned int, int, "
1075 "art::JValue*)+876)\n"
Yabin Cui11e96fe2018-03-14 18:16:22 -07001076 " #04 pc 004021a7 libart.so (MterpMaybeDoOnStackReplacement+86)\n"
1077 " #05 pc 00412474 libart.so (ExecuteMterpImpl+66164)\n"
1078 " #06 pc cd8365b0 <unknown>\n" // symbol in dex file
1079 " #07 pc 001d7f1b libart.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -08001080 "(art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, "
1081 "art::ShadowFrame&, art::JValue, bool)+374)\n"
Yabin Cui11e96fe2018-03-14 18:16:22 -07001082 " #08 pc 001dc593 libart.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -08001083 "(art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, "
1084 "art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+154)\n"
Yabin Cui11e96fe2018-03-14 18:16:22 -07001085 " #09 pc 001f4d01 libart.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -08001086 "(bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, "
1087 "art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+732)\n"
Yabin Cui11e96fe2018-03-14 18:16:22 -07001088 " #10 pc 003fe427 libart.so (MterpInvokeInterface+1354)\n"
1089 " #11 pc 00405b94 libart.so (ExecuteMterpImpl+14740)\n"
1090 " #12 pc 7004873e <unknown>\n" // symbol in dex file
1091 " #13 pc 001d7f1b libart.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -08001092 "(art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, "
1093 "art::ShadowFrame&, art::JValue, bool)+374)\n"
Yabin Cui11e96fe2018-03-14 18:16:22 -07001094 " #14 pc 001dc4d5 libart.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -08001095 "(art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor "
1096 "const&, art::ShadowFrame*)+92)\n"
Yabin Cui11e96fe2018-03-14 18:16:22 -07001097 " #15 pc 003f25ab libart.so (artQuickToInterpreterBridge+970)\n"
1098 " #16 pc 00417aff libart.so (art_quick_to_interpreter_bridge+30)\n"
1099 " #17 pc 00413575 libart.so (art_quick_invoke_stub_internal+68)\n"
1100 " #18 pc 00418531 libart.so (art_quick_invoke_stub+236)\n"
Christopher Ferriseb0772f2018-12-05 15:57:02 -08001101 " #19 pc 000b468d libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned "
1102 "int, art::JValue*, char const*)+136)\n"
Yabin Cui11e96fe2018-03-14 18:16:22 -07001103 " #20 pc 00362f49 libart.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -08001104 "(art::(anonymous namespace)::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable "
1105 "const&, art::ArtMethod*, art::(anonymous namespace)::ArgArray*, art::JValue*, char "
1106 "const*)+52)\n"
Yabin Cui11e96fe2018-03-14 18:16:22 -07001107 " #21 pc 00363cd9 libart.so "
Christopher Ferriseb0772f2018-12-05 15:57:02 -08001108 "(art::InvokeVirtualOrInterfaceWithJValues(art::ScopedObjectAccessAlreadyRunnable const&, "
1109 "_jobject*, _jmethodID*, jvalue*)+332)\n"
1110 " #22 pc 003851dd libart.so (art::Thread::CreateCallback(void*)+868)\n"
1111 " #23 pc 00062925 libc.so (__pthread_start(void*)+22)\n"
Yabin Cui11e96fe2018-03-14 18:16:22 -07001112 " #24 pc 0001de39 libc.so (__start_thread+24)\n",
1113 frame_info);
1114 EXPECT_EQ(0xd025c788U, unwinder.frames()[0].pc);
1115 EXPECT_EQ(0xcd4ff140U, unwinder.frames()[0].sp);
1116 EXPECT_EQ(0xd025cdd5U, unwinder.frames()[1].pc);
1117 EXPECT_EQ(0xcd4ff140U, unwinder.frames()[1].sp);
1118 EXPECT_EQ(0xe4a755bbU, unwinder.frames()[2].pc);
1119 EXPECT_EQ(0xcd4ff160U, unwinder.frames()[2].sp);
1120 EXPECT_EQ(0xe48c77a5U, unwinder.frames()[3].pc);
1121 EXPECT_EQ(0xcd4ff190U, unwinder.frames()[3].sp);
1122 EXPECT_EQ(0xe4a641a7U, unwinder.frames()[4].pc);
1123 EXPECT_EQ(0xcd4ff298U, unwinder.frames()[4].sp);
1124 EXPECT_EQ(0xe4a74474U, unwinder.frames()[5].pc);
1125 EXPECT_EQ(0xcd4ff2b8U, unwinder.frames()[5].sp);
1126 EXPECT_EQ(0xcd8365b0U, unwinder.frames()[6].pc);
1127 EXPECT_EQ(0xcd4ff2e0U, unwinder.frames()[6].sp);
1128 EXPECT_EQ(0xe4839f1bU, unwinder.frames()[7].pc);
1129 EXPECT_EQ(0xcd4ff2e0U, unwinder.frames()[7].sp);
1130 EXPECT_EQ(0xe483e593U, unwinder.frames()[8].pc);
1131 EXPECT_EQ(0xcd4ff330U, unwinder.frames()[8].sp);
1132 EXPECT_EQ(0xe4856d01U, unwinder.frames()[9].pc);
1133 EXPECT_EQ(0xcd4ff380U, unwinder.frames()[9].sp);
1134 EXPECT_EQ(0xe4a60427U, unwinder.frames()[10].pc);
1135 EXPECT_EQ(0xcd4ff430U, unwinder.frames()[10].sp);
1136 EXPECT_EQ(0xe4a67b94U, unwinder.frames()[11].pc);
1137 EXPECT_EQ(0xcd4ff498U, unwinder.frames()[11].sp);
1138 EXPECT_EQ(0x7004873eU, unwinder.frames()[12].pc);
1139 EXPECT_EQ(0xcd4ff4c0U, unwinder.frames()[12].sp);
1140 EXPECT_EQ(0xe4839f1bU, unwinder.frames()[13].pc);
1141 EXPECT_EQ(0xcd4ff4c0U, unwinder.frames()[13].sp);
1142 EXPECT_EQ(0xe483e4d5U, unwinder.frames()[14].pc);
1143 EXPECT_EQ(0xcd4ff510U, unwinder.frames()[14].sp);
1144 EXPECT_EQ(0xe4a545abU, unwinder.frames()[15].pc);
1145 EXPECT_EQ(0xcd4ff538U, unwinder.frames()[15].sp);
1146 EXPECT_EQ(0xe4a79affU, unwinder.frames()[16].pc);
1147 EXPECT_EQ(0xcd4ff640U, unwinder.frames()[16].sp);
1148 EXPECT_EQ(0xe4a75575U, unwinder.frames()[17].pc);
1149 EXPECT_EQ(0xcd4ff6b0U, unwinder.frames()[17].sp);
1150 EXPECT_EQ(0xe4a7a531U, unwinder.frames()[18].pc);
1151 EXPECT_EQ(0xcd4ff6e8U, unwinder.frames()[18].sp);
1152 EXPECT_EQ(0xe471668dU, unwinder.frames()[19].pc);
1153 EXPECT_EQ(0xcd4ff770U, unwinder.frames()[19].sp);
1154 EXPECT_EQ(0xe49c4f49U, unwinder.frames()[20].pc);
1155 EXPECT_EQ(0xcd4ff7c8U, unwinder.frames()[20].sp);
1156 EXPECT_EQ(0xe49c5cd9U, unwinder.frames()[21].pc);
1157 EXPECT_EQ(0xcd4ff850U, unwinder.frames()[21].sp);
1158 EXPECT_EQ(0xe49e71ddU, unwinder.frames()[22].pc);
1159 EXPECT_EQ(0xcd4ff8e8U, unwinder.frames()[22].sp);
1160 EXPECT_EQ(0xe7df3925U, unwinder.frames()[23].pc);
1161 EXPECT_EQ(0xcd4ff958U, unwinder.frames()[23].sp);
1162 EXPECT_EQ(0xe7daee39U, unwinder.frames()[24].pc);
1163 EXPECT_EQ(0xcd4ff960U, unwinder.frames()[24].sp);
1164}
1165
Yabin Cuid5b22c52018-02-22 17:11:31 -08001166TEST_F(UnwindOfflineTest, jit_map_arm) {
Christopher Ferris239425b2018-05-17 18:37:38 -07001167 ASSERT_NO_FATAL_FAILURE(Init("jit_map_arm/", ARCH_ARM));
Yabin Cuid5b22c52018-02-22 17:11:31 -08001168
1169 maps_->Add(0xd025c788, 0xd025c9f0, 0, PROT_READ | PROT_EXEC | MAPS_FLAGS_JIT_SYMFILE_MAP,
1170 "jit_map0.so", 0);
1171 maps_->Add(0xd025cd98, 0xd025cff4, 0, PROT_READ | PROT_EXEC | MAPS_FLAGS_JIT_SYMFILE_MAP,
1172 "jit_map1.so", 0);
1173 maps_->Sort();
1174
1175 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
1176 unwinder.Unwind();
1177
1178 std::string frame_info(DumpFrames(unwinder));
1179 ASSERT_EQ(6U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
1180 EXPECT_EQ(
1181 " #00 pc 00000000 jit_map0.so "
1182 "(com.example.simpleperf.simpleperfexamplewithnative.MixActivity.access$000)\n"
1183 " #01 pc 0000003d jit_map1.so "
1184 "(com.example.simpleperf.simpleperfexamplewithnative.MixActivity$1.run+60)\n"
1185 " #02 pc 004135bb libart.so (art_quick_osr_stub+42)\n"
1186
Christopher Ferriseb0772f2018-12-05 15:57:02 -08001187 " #03 pc 003851dd libart.so (art::Thread::CreateCallback(void*)+868)\n"
1188 " #04 pc 00062925 libc.so (__pthread_start(void*)+22)\n"
Yabin Cuid5b22c52018-02-22 17:11:31 -08001189 " #05 pc 0001de39 libc.so (__start_thread+24)\n",
1190 frame_info);
1191
1192 EXPECT_EQ(0xd025c788U, unwinder.frames()[0].pc);
1193 EXPECT_EQ(0xcd4ff140U, unwinder.frames()[0].sp);
1194 EXPECT_EQ(0xd025cdd5U, unwinder.frames()[1].pc);
1195 EXPECT_EQ(0xcd4ff140U, unwinder.frames()[1].sp);
1196 EXPECT_EQ(0xe4a755bbU, unwinder.frames()[2].pc);
1197 EXPECT_EQ(0xcd4ff160U, unwinder.frames()[2].sp);
1198 EXPECT_EQ(0xe49e71ddU, unwinder.frames()[3].pc);
1199 EXPECT_EQ(0xcd4ff8e8U, unwinder.frames()[3].sp);
1200 EXPECT_EQ(0xe7df3925U, unwinder.frames()[4].pc);
1201 EXPECT_EQ(0xcd4ff958U, unwinder.frames()[4].sp);
1202 EXPECT_EQ(0xe7daee39U, unwinder.frames()[5].pc);
1203 EXPECT_EQ(0xcd4ff960U, unwinder.frames()[5].sp);
1204}
1205
Christopher Ferris239425b2018-05-17 18:37:38 -07001206TEST_F(UnwindOfflineTest, offset_arm) {
1207 ASSERT_NO_FATAL_FAILURE(Init("offset_arm/", ARCH_ARM));
1208
1209 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
1210 unwinder.Unwind();
1211
1212 std::string frame_info(DumpFrames(unwinder));
1213 ASSERT_EQ(19U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
1214 EXPECT_EQ(
Christopher Ferrisa09c4a62018-12-13 16:08:50 -08001215 " #00 pc 0032bfa0 libunwindstack_test (SignalInnerFunction+40)\n"
1216 " #01 pc 0032bfeb libunwindstack_test (SignalMiddleFunction+2)\n"
1217 " #02 pc 0032bff3 libunwindstack_test (SignalOuterFunction+2)\n"
1218 " #03 pc 0032fed3 libunwindstack_test "
Christopher Ferriseb0772f2018-12-05 15:57:02 -08001219 "(unwindstack::SignalCallerHandler(int, siginfo*, void*)+26)\n"
Christopher Ferrisd11ed862019-04-11 19:45:35 -07001220 " #04 pc 0002652c libc.so (__restore)\n"
Christopher Ferris239425b2018-05-17 18:37:38 -07001221 " #05 pc 00000000 <unknown>\n"
Christopher Ferrisa09c4a62018-12-13 16:08:50 -08001222 " #06 pc 0032c2d9 libunwindstack_test (InnerFunction+736)\n"
1223 " #07 pc 0032cc4f libunwindstack_test (MiddleFunction+42)\n"
1224 " #08 pc 0032cc81 libunwindstack_test (OuterFunction+42)\n"
1225 " #09 pc 0032e547 libunwindstack_test "
Christopher Ferriseb0772f2018-12-05 15:57:02 -08001226 "(unwindstack::RemoteThroughSignal(int, unsigned int)+270)\n"
Christopher Ferrisa09c4a62018-12-13 16:08:50 -08001227 " #10 pc 0032ed99 libunwindstack_test "
Christopher Ferriseb0772f2018-12-05 15:57:02 -08001228 "(unwindstack::UnwindTest_remote_through_signal_with_invalid_func_Test::TestBody()+16)\n"
1229 " #11 pc 00354453 libunwindstack_test (testing::Test::Run()+154)\n"
1230 " #12 pc 00354de7 libunwindstack_test (testing::TestInfo::Run()+194)\n"
1231 " #13 pc 00355105 libunwindstack_test (testing::TestCase::Run()+180)\n"
Christopher Ferrisa09c4a62018-12-13 16:08:50 -08001232 " #14 pc 0035a215 libunwindstack_test "
Christopher Ferriseb0772f2018-12-05 15:57:02 -08001233 "(testing::internal::UnitTestImpl::RunAllTests()+664)\n"
1234 " #15 pc 00359f4f libunwindstack_test (testing::UnitTest::Run()+110)\n"
Christopher Ferrisa09c4a62018-12-13 16:08:50 -08001235 " #16 pc 0034d3db libunwindstack_test (main+38)\n"
1236 " #17 pc 00092c0d libc.so (__libc_init+48)\n"
1237 " #18 pc 0004202f libunwindstack_test (_start_main+38)\n",
Christopher Ferris239425b2018-05-17 18:37:38 -07001238 frame_info);
1239
1240 EXPECT_EQ(0x2e55fa0U, unwinder.frames()[0].pc);
1241 EXPECT_EQ(0xf43d2cccU, unwinder.frames()[0].sp);
1242 EXPECT_EQ(0x2e55febU, unwinder.frames()[1].pc);
1243 EXPECT_EQ(0xf43d2ce0U, unwinder.frames()[1].sp);
1244 EXPECT_EQ(0x2e55ff3U, unwinder.frames()[2].pc);
1245 EXPECT_EQ(0xf43d2ce8U, unwinder.frames()[2].sp);
1246 EXPECT_EQ(0x2e59ed3U, unwinder.frames()[3].pc);
1247 EXPECT_EQ(0xf43d2cf0U, unwinder.frames()[3].sp);
Christopher Ferrisd11ed862019-04-11 19:45:35 -07001248 EXPECT_EQ(0xf413652cU, unwinder.frames()[4].pc);
Christopher Ferris239425b2018-05-17 18:37:38 -07001249 EXPECT_EQ(0xf43d2d10U, unwinder.frames()[4].sp);
1250 EXPECT_EQ(0U, unwinder.frames()[5].pc);
1251 EXPECT_EQ(0xffcc0ee0U, unwinder.frames()[5].sp);
1252 EXPECT_EQ(0x2e562d9U, unwinder.frames()[6].pc);
1253 EXPECT_EQ(0xffcc0ee0U, unwinder.frames()[6].sp);
1254 EXPECT_EQ(0x2e56c4fU, unwinder.frames()[7].pc);
1255 EXPECT_EQ(0xffcc1060U, unwinder.frames()[7].sp);
1256 EXPECT_EQ(0x2e56c81U, unwinder.frames()[8].pc);
1257 EXPECT_EQ(0xffcc1078U, unwinder.frames()[8].sp);
1258 EXPECT_EQ(0x2e58547U, unwinder.frames()[9].pc);
1259 EXPECT_EQ(0xffcc1090U, unwinder.frames()[9].sp);
1260 EXPECT_EQ(0x2e58d99U, unwinder.frames()[10].pc);
1261 EXPECT_EQ(0xffcc1438U, unwinder.frames()[10].sp);
1262 EXPECT_EQ(0x2e7e453U, unwinder.frames()[11].pc);
1263 EXPECT_EQ(0xffcc1448U, unwinder.frames()[11].sp);
1264 EXPECT_EQ(0x2e7ede7U, unwinder.frames()[12].pc);
1265 EXPECT_EQ(0xffcc1458U, unwinder.frames()[12].sp);
1266 EXPECT_EQ(0x2e7f105U, unwinder.frames()[13].pc);
1267 EXPECT_EQ(0xffcc1490U, unwinder.frames()[13].sp);
1268 EXPECT_EQ(0x2e84215U, unwinder.frames()[14].pc);
1269 EXPECT_EQ(0xffcc14c0U, unwinder.frames()[14].sp);
1270 EXPECT_EQ(0x2e83f4fU, unwinder.frames()[15].pc);
1271 EXPECT_EQ(0xffcc1510U, unwinder.frames()[15].sp);
1272 EXPECT_EQ(0x2e773dbU, unwinder.frames()[16].pc);
1273 EXPECT_EQ(0xffcc1528U, unwinder.frames()[16].sp);
1274 EXPECT_EQ(0xf41a2c0dU, unwinder.frames()[17].pc);
1275 EXPECT_EQ(0xffcc1540U, unwinder.frames()[17].sp);
1276 EXPECT_EQ(0x2b6c02fU, unwinder.frames()[18].pc);
1277 EXPECT_EQ(0xffcc1558U, unwinder.frames()[18].sp);
1278}
1279
Christopher Ferris4cc36d22018-06-06 14:47:31 -07001280// Test using a non-zero load bias library that has the fde entries
1281// encoded as 0xb, which is not set as pc relative.
1282TEST_F(UnwindOfflineTest, debug_frame_load_bias_arm) {
1283 ASSERT_NO_FATAL_FAILURE(Init("debug_frame_load_bias_arm/", ARCH_ARM));
1284
1285 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
1286 unwinder.Unwind();
1287
1288 std::string frame_info(DumpFrames(unwinder));
1289 ASSERT_EQ(8U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
1290 EXPECT_EQ(
1291 " #00 pc 0005138c libc.so (__ioctl+8)\n"
1292 " #01 pc 0002140f libc.so (ioctl+30)\n"
Christopher Ferriseb0772f2018-12-05 15:57:02 -08001293 " #02 pc 00039535 libbinder.so (android::IPCThreadState::talkWithDriver(bool)+204)\n"
1294 " #03 pc 00039633 libbinder.so (android::IPCThreadState::getAndExecuteCommand()+10)\n"
1295 " #04 pc 00039b57 libbinder.so (android::IPCThreadState::joinThreadPool(bool)+38)\n"
Christopher Ferris4cc36d22018-06-06 14:47:31 -07001296 " #05 pc 00000c21 mediaserver (main+104)\n"
1297 " #06 pc 00084b89 libc.so (__libc_init+48)\n"
1298 " #07 pc 00000b77 mediaserver (_start_main+38)\n",
1299 frame_info);
1300
1301 EXPECT_EQ(0xf0be238cU, unwinder.frames()[0].pc);
1302 EXPECT_EQ(0xffd4a638U, unwinder.frames()[0].sp);
1303 EXPECT_EQ(0xf0bb240fU, unwinder.frames()[1].pc);
1304 EXPECT_EQ(0xffd4a638U, unwinder.frames()[1].sp);
1305 EXPECT_EQ(0xf1a75535U, unwinder.frames()[2].pc);
1306 EXPECT_EQ(0xffd4a650U, unwinder.frames()[2].sp);
1307 EXPECT_EQ(0xf1a75633U, unwinder.frames()[3].pc);
1308 EXPECT_EQ(0xffd4a6b0U, unwinder.frames()[3].sp);
1309 EXPECT_EQ(0xf1a75b57U, unwinder.frames()[4].pc);
1310 EXPECT_EQ(0xffd4a6d0U, unwinder.frames()[4].sp);
1311 EXPECT_EQ(0x8d1cc21U, unwinder.frames()[5].pc);
1312 EXPECT_EQ(0xffd4a6e8U, unwinder.frames()[5].sp);
1313 EXPECT_EQ(0xf0c15b89U, unwinder.frames()[6].pc);
1314 EXPECT_EQ(0xffd4a700U, unwinder.frames()[6].sp);
1315 EXPECT_EQ(0x8d1cb77U, unwinder.frames()[7].pc);
1316 EXPECT_EQ(0xffd4a718U, unwinder.frames()[7].sp);
1317}
1318
Christopher Ferris01040b12018-12-10 11:13:23 -08001319TEST_F(UnwindOfflineTest, shared_lib_in_apk_arm64) {
1320 ASSERT_NO_FATAL_FAILURE(Init("shared_lib_in_apk_arm64/", ARCH_ARM64));
1321
1322 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
1323 unwinder.Unwind();
1324
1325 std::string frame_info(DumpFrames(unwinder));
1326 ASSERT_EQ(7U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
1327 EXPECT_EQ(
Christopher Ferrisa09c4a62018-12-13 16:08:50 -08001328 " #00 pc 000000000014ccbc linker64 (__dl_syscall+28)\n"
1329 " #01 pc 000000000005426c linker64 "
Christopher Ferris01040b12018-12-10 11:13:23 -08001330 "(__dl__ZL24debuggerd_signal_handleriP7siginfoPv+1128)\n"
Christopher Ferrisd11ed862019-04-11 19:45:35 -07001331 " #02 pc 00000000000008c0 vdso.so (__kernel_rt_sigreturn)\n"
Christopher Ferrisa09c4a62018-12-13 16:08:50 -08001332 " #03 pc 00000000000846f4 libc.so (abort+172)\n"
1333 " #04 pc 0000000000084ad4 libc.so (__assert2+36)\n"
Christopher Ferris02a6c442019-03-11 14:43:33 -07001334 " #05 pc 000000000003d5b4 ANGLEPrebuilt.apk!libfeature_support_angle.so (offset 0x4000) "
1335 "(ANGLEGetUtilityAPI+56)\n"
Christopher Ferrisa09c4a62018-12-13 16:08:50 -08001336 " #06 pc 000000000007fe68 libc.so (__libc_init)\n",
Christopher Ferris01040b12018-12-10 11:13:23 -08001337 frame_info);
1338
1339 EXPECT_EQ(0x7e82c4fcbcULL, unwinder.frames()[0].pc);
1340 EXPECT_EQ(0x7df8ca3bf0ULL, unwinder.frames()[0].sp);
1341 EXPECT_EQ(0x7e82b5726cULL, unwinder.frames()[1].pc);
1342 EXPECT_EQ(0x7df8ca3bf0ULL, unwinder.frames()[1].sp);
Christopher Ferrisd11ed862019-04-11 19:45:35 -07001343 EXPECT_EQ(0x7e82b018c0ULL, unwinder.frames()[2].pc);
Christopher Ferris01040b12018-12-10 11:13:23 -08001344 EXPECT_EQ(0x7df8ca3da0ULL, unwinder.frames()[2].sp);
1345 EXPECT_EQ(0x7e7eecc6f4ULL, unwinder.frames()[3].pc);
1346 EXPECT_EQ(0x7dabf3db60ULL, unwinder.frames()[3].sp);
1347 EXPECT_EQ(0x7e7eeccad4ULL, unwinder.frames()[4].pc);
1348 EXPECT_EQ(0x7dabf3dc40ULL, unwinder.frames()[4].sp);
1349 EXPECT_EQ(0x7dabc405b4ULL, unwinder.frames()[5].pc);
1350 EXPECT_EQ(0x7dabf3dc50ULL, unwinder.frames()[5].sp);
1351 EXPECT_EQ(0x7e7eec7e68ULL, unwinder.frames()[6].pc);
1352 EXPECT_EQ(0x7dabf3dc70ULL, unwinder.frames()[6].sp);
1353 // Ignore top frame since the test code was modified to end in __libc_init.
1354}
1355
1356TEST_F(UnwindOfflineTest, shared_lib_in_apk_memory_only_arm64) {
1357 ASSERT_NO_FATAL_FAILURE(Init("shared_lib_in_apk_memory_only_arm64/", ARCH_ARM64));
1358 // Add the memory that represents the shared library.
1359 MemoryOfflineParts* memory = reinterpret_cast<MemoryOfflineParts*>(process_memory_.get());
1360 AddMemory(dir_ + "lib_mem.data", memory);
1361
1362 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
1363 unwinder.Unwind();
1364
1365 std::string frame_info(DumpFrames(unwinder));
1366 ASSERT_EQ(7U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
1367 EXPECT_EQ(
Christopher Ferrisa09c4a62018-12-13 16:08:50 -08001368 " #00 pc 000000000014ccbc linker64 (__dl_syscall+28)\n"
1369 " #01 pc 000000000005426c linker64 "
Christopher Ferris01040b12018-12-10 11:13:23 -08001370 "(__dl__ZL24debuggerd_signal_handleriP7siginfoPv+1128)\n"
Christopher Ferrisd11ed862019-04-11 19:45:35 -07001371 " #02 pc 00000000000008c0 vdso.so (__kernel_rt_sigreturn)\n"
Christopher Ferrisa09c4a62018-12-13 16:08:50 -08001372 " #03 pc 00000000000846f4 libc.so (abort+172)\n"
1373 " #04 pc 0000000000084ad4 libc.so (__assert2+36)\n"
1374 " #05 pc 000000000003d5b4 ANGLEPrebuilt.apk (offset 0x21d5000)\n"
1375 " #06 pc 000000000007fe68 libc.so (__libc_init)\n",
Christopher Ferris01040b12018-12-10 11:13:23 -08001376 frame_info);
1377
1378 EXPECT_EQ(0x7e82c4fcbcULL, unwinder.frames()[0].pc);
1379 EXPECT_EQ(0x7df8ca3bf0ULL, unwinder.frames()[0].sp);
1380 EXPECT_EQ(0x7e82b5726cULL, unwinder.frames()[1].pc);
1381 EXPECT_EQ(0x7df8ca3bf0ULL, unwinder.frames()[1].sp);
Christopher Ferrisd11ed862019-04-11 19:45:35 -07001382 EXPECT_EQ(0x7e82b018c0ULL, unwinder.frames()[2].pc);
Christopher Ferris01040b12018-12-10 11:13:23 -08001383 EXPECT_EQ(0x7df8ca3da0ULL, unwinder.frames()[2].sp);
1384 EXPECT_EQ(0x7e7eecc6f4ULL, unwinder.frames()[3].pc);
1385 EXPECT_EQ(0x7dabf3db60ULL, unwinder.frames()[3].sp);
1386 EXPECT_EQ(0x7e7eeccad4ULL, unwinder.frames()[4].pc);
1387 EXPECT_EQ(0x7dabf3dc40ULL, unwinder.frames()[4].sp);
1388 EXPECT_EQ(0x7dabc405b4ULL, unwinder.frames()[5].pc);
1389 EXPECT_EQ(0x7dabf3dc50ULL, unwinder.frames()[5].sp);
1390 EXPECT_EQ(0x7e7eec7e68ULL, unwinder.frames()[6].pc);
1391 EXPECT_EQ(0x7dabf3dc70ULL, unwinder.frames()[6].sp);
1392 // Ignore top frame since the test code was modified to end in __libc_init.
1393}
1394
Christopher Ferris86f2d9d2019-03-12 15:17:36 -07001395TEST_F(UnwindOfflineTest, shared_lib_in_apk_single_map_arm64) {
1396 ASSERT_NO_FATAL_FAILURE(Init("shared_lib_in_apk_single_map_arm64/", ARCH_ARM64));
1397
1398 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
1399 unwinder.Unwind();
1400
1401 std::string frame_info(DumpFrames(unwinder));
1402 ASSERT_EQ(13U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
1403 EXPECT_EQ(
1404 " #00 pc 00000000000814bc libc.so (syscall+28)\n"
1405 " #01 pc 00000000008cdf5c test.apk (offset 0x5000)\n"
1406 " #02 pc 00000000008cde9c test.apk (offset 0x5000)\n"
1407 " #03 pc 00000000008cdd70 test.apk (offset 0x5000)\n"
1408 " #04 pc 00000000008ce408 test.apk (offset 0x5000)\n"
1409 " #05 pc 00000000008ce8d8 test.apk (offset 0x5000)\n"
1410 " #06 pc 00000000008ce814 test.apk (offset 0x5000)\n"
1411 " #07 pc 00000000008bcf60 test.apk (offset 0x5000)\n"
1412 " #08 pc 0000000000133024 test.apk (offset 0x5000)\n"
1413 " #09 pc 0000000000134ad0 test.apk (offset 0x5000)\n"
1414 " #10 pc 0000000000134b64 test.apk (offset 0x5000)\n"
1415 " #11 pc 00000000000e406c libc.so (__pthread_start(void*)+36)\n"
1416 " #12 pc 0000000000085e18 libc.so (__start_thread+64)\n",
1417 frame_info);
1418
1419 EXPECT_EQ(0x7cbe0b14bcULL, unwinder.frames()[0].pc);
1420 EXPECT_EQ(0x7be4f077d0ULL, unwinder.frames()[0].sp);
1421 EXPECT_EQ(0x7be6715f5cULL, unwinder.frames()[1].pc);
1422 EXPECT_EQ(0x7be4f077d0ULL, unwinder.frames()[1].sp);
1423 EXPECT_EQ(0x7be6715e9cULL, unwinder.frames()[2].pc);
1424 EXPECT_EQ(0x7be4f07800ULL, unwinder.frames()[2].sp);
1425 EXPECT_EQ(0x7be6715d70ULL, unwinder.frames()[3].pc);
1426 EXPECT_EQ(0x7be4f07840ULL, unwinder.frames()[3].sp);
1427 EXPECT_EQ(0x7be6716408ULL, unwinder.frames()[4].pc);
1428 EXPECT_EQ(0x7be4f07860ULL, unwinder.frames()[4].sp);
1429 EXPECT_EQ(0x7be67168d8ULL, unwinder.frames()[5].pc);
1430 EXPECT_EQ(0x7be4f07880ULL, unwinder.frames()[5].sp);
1431 EXPECT_EQ(0x7be6716814ULL, unwinder.frames()[6].pc);
1432 EXPECT_EQ(0x7be4f078f0ULL, unwinder.frames()[6].sp);
1433 EXPECT_EQ(0x7be6704f60ULL, unwinder.frames()[7].pc);
1434 EXPECT_EQ(0x7be4f07910ULL, unwinder.frames()[7].sp);
1435 EXPECT_EQ(0x7be5f7b024ULL, unwinder.frames()[8].pc);
1436 EXPECT_EQ(0x7be4f07950ULL, unwinder.frames()[8].sp);
1437 EXPECT_EQ(0x7be5f7cad0ULL, unwinder.frames()[9].pc);
1438 EXPECT_EQ(0x7be4f07aa0ULL, unwinder.frames()[9].sp);
1439 EXPECT_EQ(0x7be5f7cb64ULL, unwinder.frames()[10].pc);
1440 EXPECT_EQ(0x7be4f07ce0ULL, unwinder.frames()[10].sp);
1441 EXPECT_EQ(0x7cbe11406cULL, unwinder.frames()[11].pc);
1442 EXPECT_EQ(0x7be4f07d00ULL, unwinder.frames()[11].sp);
1443 EXPECT_EQ(0x7cbe0b5e18ULL, unwinder.frames()[12].pc);
1444 EXPECT_EQ(0x7be4f07d20ULL, unwinder.frames()[12].sp);
1445}
1446
Christopher Ferrisd49499d2019-06-10 18:37:32 -07001447TEST_F(UnwindOfflineTest, invalid_elf_offset_arm) {
1448 ASSERT_NO_FATAL_FAILURE(Init("invalid_elf_offset_arm/", ARCH_ARM, false));
1449
1450 Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
1451 unwinder.Unwind();
1452
1453 std::string frame_info(DumpFrames(unwinder));
1454 ASSERT_EQ(1U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
1455 EXPECT_EQ(" #00 pc 00aa7508 invalid.apk (offset 0x12e4000)\n", frame_info);
1456 EXPECT_EQ(0xc898f508, unwinder.frames()[0].pc);
1457 EXPECT_EQ(0xc2044218, unwinder.frames()[0].sp);
1458}
1459
Christopher Ferrisc3d79f72017-11-28 19:14:54 -08001460} // namespace unwindstack