blob: 438194a9fb14ecaf3d9447a11fb97dea0c1fcf61 [file] [log] [blame]
Christopher Ferris150db122017-12-20 18:49:01 -08001/*
2 * Copyright (C) 2018 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 <elf.h>
18#include <string.h>
19
20#include <memory>
21#include <vector>
22
23#include <gtest/gtest.h>
24
25#include <unwindstack/Elf.h>
26#include <unwindstack/JitDebug.h>
27#include <unwindstack/MapInfo.h>
28#include <unwindstack/Maps.h>
29#include <unwindstack/Memory.h>
30
31#include "ElfFake.h"
32#include "MemoryFake.h"
33
34namespace unwindstack {
35
36class JitDebugTest : public ::testing::Test {
37 protected:
Christopher Ferris4568f4b2018-10-23 17:42:41 -070038 void CreateFakeElf(MapInfo* map_info) {
39 MemoryFake* memory = new MemoryFake;
40 ElfFake* elf = new ElfFake(memory);
41 elf->FakeSetValid(true);
42 ElfInterfaceFake* interface = new ElfInterfaceFake(memory);
43 elf->FakeSetInterface(interface);
44 interface->FakeSetGlobalVariable("__jit_debug_descriptor", 0x800);
45 map_info->elf.reset(elf);
46 }
Christopher Ferris150db122017-12-20 18:49:01 -080047
Christopher Ferris4568f4b2018-10-23 17:42:41 -070048 void Init(ArchEnum arch) {
David Srbecky85b5fec2018-02-23 18:06:13 +000049 jit_debug_ = JitDebug<Elf>::Create(arch, process_memory_);
Christopher Ferris150db122017-12-20 18:49:01 -080050
51 maps_.reset(
Christopher Ferris56d0e072018-10-17 10:57:53 -070052 new BufferMaps("1000-4000 ---s 00000000 00:00 0 /fake/elf1\n"
53 "4000-6000 r--s 00000000 00:00 0 /fake/elf1\n"
54 "6000-8000 -wxs 00000000 00:00 0 /fake/elf1\n"
55 "a000-c000 --xp 00000000 00:00 0 /fake/elf2\n"
56 "c000-f000 rw-p 00001000 00:00 0 /fake/elf2\n"
57 "f000-11000 r--p 00000000 00:00 0 /fake/elf3\n"
58 "11000-12000 rw-p 00001000 00:00 0 /fake/elf3\n"
59 "12000-14000 r--p 00000000 00:00 0 /fake/elf4\n"
60 "100000-110000 rw-p 0001000 00:00 0 /fake/elf4\n"
61 "200000-210000 rw-p 0002000 00:00 0 /fake/elf4\n"));
Christopher Ferris150db122017-12-20 18:49:01 -080062 ASSERT_TRUE(maps_->Parse());
63
David Srbecky85b5fec2018-02-23 18:06:13 +000064 // Ensure all memory of the ELF file is initialized,
65 // otherwise reads within it may fail.
66 for (uint64_t addr = 0x4000; addr < 0x6000; addr += 8) {
67 memory_->SetData64(addr, 0);
68 }
69
Christopher Ferris150db122017-12-20 18:49:01 -080070 MapInfo* map_info = maps_->Get(3);
71 ASSERT_TRUE(map_info != nullptr);
Christopher Ferris4568f4b2018-10-23 17:42:41 -070072 CreateFakeElf(map_info);
Christopher Ferris150db122017-12-20 18:49:01 -080073
74 map_info = maps_->Get(5);
75 ASSERT_TRUE(map_info != nullptr);
Christopher Ferris4568f4b2018-10-23 17:42:41 -070076 CreateFakeElf(map_info);
Christopher Ferrised37aca2018-01-12 15:53:19 -080077
Christopher Ferris56d0e072018-10-17 10:57:53 -070078 map_info = maps_->Get(7);
Christopher Ferrised37aca2018-01-12 15:53:19 -080079 ASSERT_TRUE(map_info != nullptr);
Christopher Ferris4568f4b2018-10-23 17:42:41 -070080 CreateFakeElf(map_info);
81 }
82
83 void SetUp() override {
84 memory_ = new MemoryFake;
85 process_memory_.reset(memory_);
86
87 Init(ARCH_ARM);
Christopher Ferris150db122017-12-20 18:49:01 -080088 }
89
90 template <typename EhdrType, typename ShdrType>
91 void CreateElf(uint64_t offset, uint8_t class_type, uint8_t machine_type, uint32_t pc,
92 uint32_t size) {
93 EhdrType ehdr;
94 memset(&ehdr, 0, sizeof(ehdr));
95 uint64_t sh_offset = sizeof(ehdr);
96 memcpy(ehdr.e_ident, ELFMAG, SELFMAG);
97 ehdr.e_ident[EI_CLASS] = class_type;
98 ehdr.e_machine = machine_type;
99 ehdr.e_shstrndx = 1;
100 ehdr.e_shoff = sh_offset;
101 ehdr.e_shentsize = sizeof(ShdrType);
David Srbecky85b5fec2018-02-23 18:06:13 +0000102 ehdr.e_shnum = 4;
Christopher Ferris150db122017-12-20 18:49:01 -0800103 memory_->SetMemory(offset, &ehdr, sizeof(ehdr));
104
105 ShdrType shdr;
106 memset(&shdr, 0, sizeof(shdr));
107 shdr.sh_type = SHT_NULL;
108 memory_->SetMemory(offset + sh_offset, &shdr, sizeof(shdr));
109
110 sh_offset += sizeof(shdr);
111 memset(&shdr, 0, sizeof(shdr));
112 shdr.sh_type = SHT_STRTAB;
113 shdr.sh_name = 1;
114 shdr.sh_offset = 0x500;
115 shdr.sh_size = 0x100;
116 memory_->SetMemory(offset + sh_offset, &shdr, sizeof(shdr));
117 memory_->SetMemory(offset + 0x500, ".debug_frame");
David Srbecky85b5fec2018-02-23 18:06:13 +0000118 memory_->SetMemory(offset + 0x550, ".text");
Christopher Ferris150db122017-12-20 18:49:01 -0800119
120 sh_offset += sizeof(shdr);
121 memset(&shdr, 0, sizeof(shdr));
122 shdr.sh_type = SHT_PROGBITS;
123 shdr.sh_name = 0;
124 shdr.sh_addr = 0x600;
125 shdr.sh_offset = 0x600;
126 shdr.sh_size = 0x200;
127 memory_->SetMemory(offset + sh_offset, &shdr, sizeof(shdr));
128
David Srbecky85b5fec2018-02-23 18:06:13 +0000129 sh_offset += sizeof(shdr);
130 memset(&shdr, 0, sizeof(shdr));
131 shdr.sh_type = SHT_NOBITS;
132 shdr.sh_name = 0x50;
133 shdr.sh_addr = pc;
134 shdr.sh_offset = 0;
135 shdr.sh_size = size;
136 memory_->SetMemory(offset + sh_offset, &shdr, sizeof(shdr));
137
Christopher Ferris150db122017-12-20 18:49:01 -0800138 // Now add a single cie/fde.
139 uint64_t dwarf_offset = offset + 0x600;
140 if (class_type == ELFCLASS32) {
141 // CIE 32 information.
142 memory_->SetData32(dwarf_offset, 0xfc);
143 memory_->SetData32(dwarf_offset + 0x4, 0xffffffff);
144 memory_->SetData8(dwarf_offset + 0x8, 1);
145 memory_->SetData8(dwarf_offset + 0x9, '\0');
146 memory_->SetData8(dwarf_offset + 0xa, 0x4);
147 memory_->SetData8(dwarf_offset + 0xb, 0x4);
148 memory_->SetData8(dwarf_offset + 0xc, 0x1);
149
150 // FDE 32 information.
151 memory_->SetData32(dwarf_offset + 0x100, 0xfc);
152 memory_->SetData32(dwarf_offset + 0x104, 0);
153 memory_->SetData32(dwarf_offset + 0x108, pc);
154 memory_->SetData32(dwarf_offset + 0x10c, size);
155 } else {
156 // CIE 64 information.
157 memory_->SetData32(dwarf_offset, 0xffffffff);
158 memory_->SetData64(dwarf_offset + 4, 0xf4);
159 memory_->SetData64(dwarf_offset + 0xc, 0xffffffffffffffffULL);
160 memory_->SetData8(dwarf_offset + 0x14, 1);
161 memory_->SetData8(dwarf_offset + 0x15, '\0');
162 memory_->SetData8(dwarf_offset + 0x16, 0x4);
163 memory_->SetData8(dwarf_offset + 0x17, 0x4);
164 memory_->SetData8(dwarf_offset + 0x18, 0x1);
165
166 // FDE 64 information.
167 memory_->SetData32(dwarf_offset + 0x100, 0xffffffff);
168 memory_->SetData64(dwarf_offset + 0x104, 0xf4);
169 memory_->SetData64(dwarf_offset + 0x10c, 0);
170 memory_->SetData64(dwarf_offset + 0x114, pc);
171 memory_->SetData64(dwarf_offset + 0x11c, size);
172 }
173 }
174
175 void WriteDescriptor32(uint64_t addr, uint32_t entry);
176 void WriteDescriptor64(uint64_t addr, uint64_t entry);
177 void WriteEntry32Pack(uint64_t addr, uint32_t prev, uint32_t next, uint32_t elf_addr,
178 uint64_t elf_size);
179 void WriteEntry32Pad(uint64_t addr, uint32_t prev, uint32_t next, uint32_t elf_addr,
180 uint64_t elf_size);
181 void WriteEntry64(uint64_t addr, uint64_t prev, uint64_t next, uint64_t elf_addr,
182 uint64_t elf_size);
183
184 std::shared_ptr<Memory> process_memory_;
185 MemoryFake* memory_;
David Srbecky85b5fec2018-02-23 18:06:13 +0000186 std::unique_ptr<JitDebug<Elf>> jit_debug_;
Christopher Ferris150db122017-12-20 18:49:01 -0800187 std::unique_ptr<BufferMaps> maps_;
188};
189
190void JitDebugTest::WriteDescriptor32(uint64_t addr, uint32_t entry) {
191 // Format of the 32 bit JITDescriptor structure:
192 // uint32_t version
193 memory_->SetData32(addr, 1);
194 // uint32_t action_flag
195 memory_->SetData32(addr + 4, 0);
196 // uint32_t relevant_entry
197 memory_->SetData32(addr + 8, 0);
198 // uint32_t first_entry
199 memory_->SetData32(addr + 12, entry);
200}
201
202void JitDebugTest::WriteDescriptor64(uint64_t addr, uint64_t entry) {
203 // Format of the 64 bit JITDescriptor structure:
204 // uint32_t version
205 memory_->SetData32(addr, 1);
206 // uint32_t action_flag
207 memory_->SetData32(addr + 4, 0);
208 // uint64_t relevant_entry
209 memory_->SetData64(addr + 8, 0);
210 // uint64_t first_entry
211 memory_->SetData64(addr + 16, entry);
212}
213
214void JitDebugTest::WriteEntry32Pack(uint64_t addr, uint32_t prev, uint32_t next, uint32_t elf_addr,
215 uint64_t elf_size) {
216 // Format of the 32 bit JITCodeEntry structure:
217 // uint32_t next
218 memory_->SetData32(addr, next);
219 // uint32_t prev
220 memory_->SetData32(addr + 4, prev);
221 // uint32_t symfile_addr
222 memory_->SetData32(addr + 8, elf_addr);
223 // uint64_t symfile_size
224 memory_->SetData64(addr + 12, elf_size);
225}
226
227void JitDebugTest::WriteEntry32Pad(uint64_t addr, uint32_t prev, uint32_t next, uint32_t elf_addr,
228 uint64_t elf_size) {
229 // Format of the 32 bit JITCodeEntry structure:
230 // uint32_t next
231 memory_->SetData32(addr, next);
232 // uint32_t prev
233 memory_->SetData32(addr + 4, prev);
234 // uint32_t symfile_addr
235 memory_->SetData32(addr + 8, elf_addr);
236 // uint32_t pad
237 memory_->SetData32(addr + 12, 0);
238 // uint64_t symfile_size
239 memory_->SetData64(addr + 16, elf_size);
240}
241
242void JitDebugTest::WriteEntry64(uint64_t addr, uint64_t prev, uint64_t next, uint64_t elf_addr,
243 uint64_t elf_size) {
244 // Format of the 64 bit JITCodeEntry structure:
245 // uint64_t next
246 memory_->SetData64(addr, next);
247 // uint64_t prev
248 memory_->SetData64(addr + 8, prev);
249 // uint64_t symfile_addr
250 memory_->SetData64(addr + 16, elf_addr);
251 // uint64_t symfile_size
252 memory_->SetData64(addr + 24, elf_size);
253}
254
255TEST_F(JitDebugTest, get_elf_invalid) {
David Srbecky85b5fec2018-02-23 18:06:13 +0000256 Elf* elf = jit_debug_->Get(maps_.get(), 0x1500);
Christopher Ferris150db122017-12-20 18:49:01 -0800257 ASSERT_TRUE(elf == nullptr);
258}
259
260TEST_F(JitDebugTest, get_elf_no_global_variable) {
261 maps_.reset(new BufferMaps(""));
David Srbecky85b5fec2018-02-23 18:06:13 +0000262 Elf* elf = jit_debug_->Get(maps_.get(), 0x1500);
Christopher Ferris150db122017-12-20 18:49:01 -0800263 ASSERT_TRUE(elf == nullptr);
264}
265
266TEST_F(JitDebugTest, get_elf_no_valid_descriptor_in_memory) {
267 CreateElf<Elf32_Ehdr, Elf32_Shdr>(0x4000, ELFCLASS32, EM_ARM, 0x1500, 0x200);
268
David Srbecky85b5fec2018-02-23 18:06:13 +0000269 Elf* elf = jit_debug_->Get(maps_.get(), 0x1500);
Christopher Ferris150db122017-12-20 18:49:01 -0800270 ASSERT_TRUE(elf == nullptr);
271}
272
273TEST_F(JitDebugTest, get_elf_no_valid_code_entry) {
274 CreateElf<Elf32_Ehdr, Elf32_Shdr>(0x4000, ELFCLASS32, EM_ARM, 0x1500, 0x200);
275
276 WriteDescriptor32(0xf800, 0x200000);
277
David Srbecky85b5fec2018-02-23 18:06:13 +0000278 Elf* elf = jit_debug_->Get(maps_.get(), 0x1500);
Christopher Ferris150db122017-12-20 18:49:01 -0800279 ASSERT_TRUE(elf == nullptr);
280}
281
282TEST_F(JitDebugTest, get_elf_invalid_descriptor_first_entry) {
283 CreateElf<Elf32_Ehdr, Elf32_Shdr>(0x4000, ELFCLASS32, EM_ARM, 0x1500, 0x200);
284
285 WriteDescriptor32(0xf800, 0);
286
David Srbecky85b5fec2018-02-23 18:06:13 +0000287 Elf* elf = jit_debug_->Get(maps_.get(), 0x1500);
Christopher Ferris150db122017-12-20 18:49:01 -0800288 ASSERT_TRUE(elf == nullptr);
289}
290
291TEST_F(JitDebugTest, get_elf_invalid_descriptor_version) {
292 CreateElf<Elf32_Ehdr, Elf32_Shdr>(0x4000, ELFCLASS32, EM_ARM, 0x1500, 0x200);
293
294 WriteDescriptor32(0xf800, 0x20000);
295 // Set the version to an invalid value.
296 memory_->SetData32(0xf800, 2);
297
David Srbecky85b5fec2018-02-23 18:06:13 +0000298 Elf* elf = jit_debug_->Get(maps_.get(), 0x1500);
Christopher Ferris150db122017-12-20 18:49:01 -0800299 ASSERT_TRUE(elf == nullptr);
300}
301
302TEST_F(JitDebugTest, get_elf_32) {
303 CreateElf<Elf32_Ehdr, Elf32_Shdr>(0x4000, ELFCLASS32, EM_ARM, 0x1500, 0x200);
304
305 WriteDescriptor32(0xf800, 0x200000);
306 WriteEntry32Pad(0x200000, 0, 0, 0x4000, 0x1000);
307
David Srbecky85b5fec2018-02-23 18:06:13 +0000308 Elf* elf = jit_debug_->Get(maps_.get(), 0x1500);
Christopher Ferris150db122017-12-20 18:49:01 -0800309 ASSERT_TRUE(elf != nullptr);
David Srbecky85b5fec2018-02-23 18:06:13 +0000310 uint64_t text_addr;
311 uint64_t text_size;
312 ASSERT_TRUE(elf->GetTextRange(&text_addr, &text_size));
313 ASSERT_EQ(text_addr, 0x1500u);
314 ASSERT_EQ(text_size, 0x200u);
Christopher Ferris150db122017-12-20 18:49:01 -0800315
316 // Clear the memory and verify all of the data is cached.
317 memory_->Clear();
David Srbecky85b5fec2018-02-23 18:06:13 +0000318 WriteDescriptor32(0xf800, 0x200000);
319 Elf* elf2 = jit_debug_->Get(maps_.get(), 0x1500);
Christopher Ferris150db122017-12-20 18:49:01 -0800320 ASSERT_TRUE(elf2 != nullptr);
321 EXPECT_EQ(elf, elf2);
322}
323
Christopher Ferrised37aca2018-01-12 15:53:19 -0800324TEST_F(JitDebugTest, get_multiple_jit_debug_descriptors_valid) {
325 CreateElf<Elf32_Ehdr, Elf32_Shdr>(0x4000, ELFCLASS32, EM_ARM, 0x1500, 0x200);
326 CreateElf<Elf32_Ehdr, Elf32_Shdr>(0x5000, ELFCLASS32, EM_ARM, 0x2000, 0x300);
327
328 WriteDescriptor32(0xf800, 0x200000);
329 WriteEntry32Pad(0x200000, 0, 0, 0x4000, 0x1000);
330 WriteDescriptor32(0x12800, 0x201000);
331 WriteEntry32Pad(0x201000, 0, 0, 0x5000, 0x1000);
332
David Srbecky85b5fec2018-02-23 18:06:13 +0000333 ASSERT_TRUE(jit_debug_->Get(maps_.get(), 0x1500) != nullptr);
334 ASSERT_TRUE(jit_debug_->Get(maps_.get(), 0x2000) == nullptr);
Christopher Ferrised37aca2018-01-12 15:53:19 -0800335
336 // Now clear the descriptor entry for the first one.
337 WriteDescriptor32(0xf800, 0);
David Srbecky85b5fec2018-02-23 18:06:13 +0000338 jit_debug_ = JitDebug<Elf>::Create(ARCH_ARM, process_memory_);
Christopher Ferrised37aca2018-01-12 15:53:19 -0800339
David Srbecky85b5fec2018-02-23 18:06:13 +0000340 ASSERT_TRUE(jit_debug_->Get(maps_.get(), 0x1500) == nullptr);
341 ASSERT_TRUE(jit_debug_->Get(maps_.get(), 0x2000) != nullptr);
Christopher Ferrised37aca2018-01-12 15:53:19 -0800342}
343
Christopher Ferris150db122017-12-20 18:49:01 -0800344TEST_F(JitDebugTest, get_elf_x86) {
Christopher Ferris4568f4b2018-10-23 17:42:41 -0700345 Init(ARCH_X86);
346
Christopher Ferris150db122017-12-20 18:49:01 -0800347 CreateElf<Elf32_Ehdr, Elf32_Shdr>(0x4000, ELFCLASS32, EM_ARM, 0x1500, 0x200);
348
349 WriteDescriptor32(0xf800, 0x200000);
350 WriteEntry32Pack(0x200000, 0, 0, 0x4000, 0x1000);
351
David Srbecky85b5fec2018-02-23 18:06:13 +0000352 jit_debug_ = JitDebug<Elf>::Create(ARCH_X86, process_memory_);
353 Elf* elf = jit_debug_->Get(maps_.get(), 0x1500);
Christopher Ferris150db122017-12-20 18:49:01 -0800354 ASSERT_TRUE(elf != nullptr);
355
356 // Clear the memory and verify all of the data is cached.
357 memory_->Clear();
David Srbecky85b5fec2018-02-23 18:06:13 +0000358 WriteDescriptor32(0xf800, 0x200000);
359 Elf* elf2 = jit_debug_->Get(maps_.get(), 0x1500);
Christopher Ferris150db122017-12-20 18:49:01 -0800360 ASSERT_TRUE(elf2 != nullptr);
361 EXPECT_EQ(elf, elf2);
362}
363
364TEST_F(JitDebugTest, get_elf_64) {
Christopher Ferris4568f4b2018-10-23 17:42:41 -0700365 Init(ARCH_ARM64);
366
Christopher Ferris150db122017-12-20 18:49:01 -0800367 CreateElf<Elf64_Ehdr, Elf64_Shdr>(0x4000, ELFCLASS64, EM_AARCH64, 0x1500, 0x200);
368
369 WriteDescriptor64(0xf800, 0x200000);
370 WriteEntry64(0x200000, 0, 0, 0x4000, 0x1000);
371
David Srbecky85b5fec2018-02-23 18:06:13 +0000372 Elf* elf = jit_debug_->Get(maps_.get(), 0x1500);
Christopher Ferris150db122017-12-20 18:49:01 -0800373 ASSERT_TRUE(elf != nullptr);
374
375 // Clear the memory and verify all of the data is cached.
376 memory_->Clear();
David Srbecky85b5fec2018-02-23 18:06:13 +0000377 WriteDescriptor64(0xf800, 0x200000);
378 Elf* elf2 = jit_debug_->Get(maps_.get(), 0x1500);
Christopher Ferris150db122017-12-20 18:49:01 -0800379 ASSERT_TRUE(elf2 != nullptr);
380 EXPECT_EQ(elf, elf2);
381}
382
383TEST_F(JitDebugTest, get_elf_multiple_entries) {
384 CreateElf<Elf32_Ehdr, Elf32_Shdr>(0x4000, ELFCLASS32, EM_ARM, 0x1500, 0x200);
385 CreateElf<Elf32_Ehdr, Elf32_Shdr>(0x5000, ELFCLASS32, EM_ARM, 0x2300, 0x400);
386
387 WriteDescriptor32(0xf800, 0x200000);
388 WriteEntry32Pad(0x200000, 0, 0x200100, 0x4000, 0x1000);
389 WriteEntry32Pad(0x200100, 0x200100, 0, 0x5000, 0x1000);
390
David Srbecky85b5fec2018-02-23 18:06:13 +0000391 Elf* elf_2 = jit_debug_->Get(maps_.get(), 0x2400);
Christopher Ferris150db122017-12-20 18:49:01 -0800392 ASSERT_TRUE(elf_2 != nullptr);
393
David Srbecky85b5fec2018-02-23 18:06:13 +0000394 Elf* elf_1 = jit_debug_->Get(maps_.get(), 0x1600);
Christopher Ferris150db122017-12-20 18:49:01 -0800395 ASSERT_TRUE(elf_1 != nullptr);
396
397 // Clear the memory and verify all of the data is cached.
398 memory_->Clear();
David Srbecky85b5fec2018-02-23 18:06:13 +0000399 WriteDescriptor32(0xf800, 0x200000);
400 EXPECT_EQ(elf_1, jit_debug_->Get(maps_.get(), 0x1500));
401 EXPECT_EQ(elf_1, jit_debug_->Get(maps_.get(), 0x16ff));
402 EXPECT_EQ(elf_2, jit_debug_->Get(maps_.get(), 0x2300));
403 EXPECT_EQ(elf_2, jit_debug_->Get(maps_.get(), 0x26ff));
404 EXPECT_EQ(nullptr, jit_debug_->Get(maps_.get(), 0x1700));
405 EXPECT_EQ(nullptr, jit_debug_->Get(maps_.get(), 0x2700));
Christopher Ferris150db122017-12-20 18:49:01 -0800406}
407
408TEST_F(JitDebugTest, get_elf_search_libs) {
409 CreateElf<Elf32_Ehdr, Elf32_Shdr>(0x4000, ELFCLASS32, EM_ARM, 0x1500, 0x200);
410
411 WriteDescriptor32(0xf800, 0x200000);
412 WriteEntry32Pad(0x200000, 0, 0, 0x4000, 0x1000);
413
414 // Only search a given named list of libs.
415 std::vector<std::string> libs{"libart.so"};
David Srbecky85b5fec2018-02-23 18:06:13 +0000416 jit_debug_ = JitDebug<Elf>::Create(ARCH_ARM, process_memory_, libs);
417 EXPECT_TRUE(jit_debug_->Get(maps_.get(), 0x1500) == nullptr);
Christopher Ferris150db122017-12-20 18:49:01 -0800418
419 // Change the name of the map that includes the value and verify this works.
420 MapInfo* map_info = maps_->Get(5);
421 map_info->name = "/system/lib/libart.so";
Christopher Ferris56d0e072018-10-17 10:57:53 -0700422 map_info = maps_->Get(6);
423 map_info->name = "/system/lib/libart.so";
David Srbecky85b5fec2018-02-23 18:06:13 +0000424 jit_debug_ = JitDebug<Elf>::Create(ARCH_ARM, process_memory_);
Christopher Ferris150db122017-12-20 18:49:01 -0800425 // Make sure that clearing our copy of the libs doesn't affect the
426 // JitDebug object.
427 libs.clear();
David Srbecky85b5fec2018-02-23 18:06:13 +0000428 EXPECT_TRUE(jit_debug_->Get(maps_.get(), 0x1500) != nullptr);
Christopher Ferris150db122017-12-20 18:49:01 -0800429}
430
431} // namespace unwindstack