Merge "Fix missing offset for apk." am: 9a00f596d3
am: fb3535ea56
Change-Id: I41350b9fa79b6ef2df701344459133adf1507059
This commit is contained in:
commit
7255c42dda
9 changed files with 94 additions and 3 deletions
|
|
@ -248,6 +248,7 @@ cc_test {
|
||||||
"tests/files/offline/offset_arm/*",
|
"tests/files/offline/offset_arm/*",
|
||||||
"tests/files/offline/shared_lib_in_apk_arm64/*",
|
"tests/files/offline/shared_lib_in_apk_arm64/*",
|
||||||
"tests/files/offline/shared_lib_in_apk_memory_only_arm64/*",
|
"tests/files/offline/shared_lib_in_apk_memory_only_arm64/*",
|
||||||
|
"tests/files/offline/shared_lib_in_apk_single_map_arm64/*",
|
||||||
"tests/files/offline/straddle_arm/*",
|
"tests/files/offline/straddle_arm/*",
|
||||||
"tests/files/offline/straddle_arm64/*",
|
"tests/files/offline/straddle_arm64/*",
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,7 @@ Memory* MapInfo::GetFileMemory() {
|
||||||
// Check if the start of this map is an embedded elf.
|
// Check if the start of this map is an embedded elf.
|
||||||
uint64_t max_size = 0;
|
uint64_t max_size = 0;
|
||||||
if (Elf::GetInfo(memory.get(), &max_size)) {
|
if (Elf::GetInfo(memory.get(), &max_size)) {
|
||||||
|
elf_start_offset = offset;
|
||||||
if (max_size > map_size) {
|
if (max_size > map_size) {
|
||||||
if (memory->Init(name, offset, max_size)) {
|
if (memory->Init(name, offset, max_size)) {
|
||||||
return memory.release();
|
return memory.release();
|
||||||
|
|
@ -96,6 +97,7 @@ Memory* MapInfo::GetFileMemory() {
|
||||||
if (memory->Init(name, offset, map_size)) {
|
if (memory->Init(name, offset, map_size)) {
|
||||||
return memory.release();
|
return memory.release();
|
||||||
}
|
}
|
||||||
|
elf_start_offset = 0;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return memory.release();
|
return memory.release();
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,7 @@ TEST_F(MapInfoCreateMemoryTest, file_backed_non_zero_offset_partial_file) {
|
||||||
std::unique_ptr<Memory> memory(info.CreateMemory(process_memory_));
|
std::unique_ptr<Memory> memory(info.CreateMemory(process_memory_));
|
||||||
ASSERT_TRUE(memory.get() != nullptr);
|
ASSERT_TRUE(memory.get() != nullptr);
|
||||||
ASSERT_EQ(0U, info.elf_offset);
|
ASSERT_EQ(0U, info.elf_offset);
|
||||||
EXPECT_EQ(0U, info.elf_start_offset);
|
EXPECT_EQ(0x1000U, info.elf_start_offset);
|
||||||
|
|
||||||
// Read the valid part of the file.
|
// Read the valid part of the file.
|
||||||
std::vector<uint8_t> buffer(0x100);
|
std::vector<uint8_t> buffer(0x100);
|
||||||
|
|
@ -202,7 +202,7 @@ TEST_F(MapInfoCreateMemoryTest, file_backed_non_zero_offset_partial_file_whole_e
|
||||||
std::unique_ptr<Memory> memory(info.CreateMemory(process_memory_));
|
std::unique_ptr<Memory> memory(info.CreateMemory(process_memory_));
|
||||||
ASSERT_TRUE(memory.get() != nullptr);
|
ASSERT_TRUE(memory.get() != nullptr);
|
||||||
ASSERT_EQ(0U, info.elf_offset);
|
ASSERT_EQ(0U, info.elf_offset);
|
||||||
EXPECT_EQ(0U, info.elf_start_offset);
|
EXPECT_EQ(0x1000U, info.elf_start_offset);
|
||||||
|
|
||||||
// Verify the memory is a valid elf.
|
// Verify the memory is a valid elf.
|
||||||
uint8_t e_ident[SELFMAG + 1];
|
uint8_t e_ident[SELFMAG + 1];
|
||||||
|
|
@ -219,7 +219,7 @@ TEST_F(MapInfoCreateMemoryTest, file_backed_non_zero_offset_partial_file_whole_e
|
||||||
std::unique_ptr<Memory> memory(info.CreateMemory(process_memory_));
|
std::unique_ptr<Memory> memory(info.CreateMemory(process_memory_));
|
||||||
ASSERT_TRUE(memory.get() != nullptr);
|
ASSERT_TRUE(memory.get() != nullptr);
|
||||||
ASSERT_EQ(0U, info.elf_offset);
|
ASSERT_EQ(0U, info.elf_offset);
|
||||||
EXPECT_EQ(0U, info.elf_start_offset);
|
EXPECT_EQ(0x2000U, info.elf_start_offset);
|
||||||
|
|
||||||
// Verify the memory is a valid elf.
|
// Verify the memory is a valid elf.
|
||||||
uint8_t e_ident[SELFMAG + 1];
|
uint8_t e_ident[SELFMAG + 1];
|
||||||
|
|
|
||||||
|
|
@ -1372,4 +1372,56 @@ TEST_F(UnwindOfflineTest, shared_lib_in_apk_memory_only_arm64) {
|
||||||
// Ignore top frame since the test code was modified to end in __libc_init.
|
// Ignore top frame since the test code was modified to end in __libc_init.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(UnwindOfflineTest, shared_lib_in_apk_single_map_arm64) {
|
||||||
|
ASSERT_NO_FATAL_FAILURE(Init("shared_lib_in_apk_single_map_arm64/", ARCH_ARM64));
|
||||||
|
|
||||||
|
Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
|
||||||
|
unwinder.Unwind();
|
||||||
|
|
||||||
|
std::string frame_info(DumpFrames(unwinder));
|
||||||
|
ASSERT_EQ(13U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
|
||||||
|
EXPECT_EQ(
|
||||||
|
" #00 pc 00000000000814bc libc.so (syscall+28)\n"
|
||||||
|
" #01 pc 00000000008cdf5c test.apk (offset 0x5000)\n"
|
||||||
|
" #02 pc 00000000008cde9c test.apk (offset 0x5000)\n"
|
||||||
|
" #03 pc 00000000008cdd70 test.apk (offset 0x5000)\n"
|
||||||
|
" #04 pc 00000000008ce408 test.apk (offset 0x5000)\n"
|
||||||
|
" #05 pc 00000000008ce8d8 test.apk (offset 0x5000)\n"
|
||||||
|
" #06 pc 00000000008ce814 test.apk (offset 0x5000)\n"
|
||||||
|
" #07 pc 00000000008bcf60 test.apk (offset 0x5000)\n"
|
||||||
|
" #08 pc 0000000000133024 test.apk (offset 0x5000)\n"
|
||||||
|
" #09 pc 0000000000134ad0 test.apk (offset 0x5000)\n"
|
||||||
|
" #10 pc 0000000000134b64 test.apk (offset 0x5000)\n"
|
||||||
|
" #11 pc 00000000000e406c libc.so (__pthread_start(void*)+36)\n"
|
||||||
|
" #12 pc 0000000000085e18 libc.so (__start_thread+64)\n",
|
||||||
|
frame_info);
|
||||||
|
|
||||||
|
EXPECT_EQ(0x7cbe0b14bcULL, unwinder.frames()[0].pc);
|
||||||
|
EXPECT_EQ(0x7be4f077d0ULL, unwinder.frames()[0].sp);
|
||||||
|
EXPECT_EQ(0x7be6715f5cULL, unwinder.frames()[1].pc);
|
||||||
|
EXPECT_EQ(0x7be4f077d0ULL, unwinder.frames()[1].sp);
|
||||||
|
EXPECT_EQ(0x7be6715e9cULL, unwinder.frames()[2].pc);
|
||||||
|
EXPECT_EQ(0x7be4f07800ULL, unwinder.frames()[2].sp);
|
||||||
|
EXPECT_EQ(0x7be6715d70ULL, unwinder.frames()[3].pc);
|
||||||
|
EXPECT_EQ(0x7be4f07840ULL, unwinder.frames()[3].sp);
|
||||||
|
EXPECT_EQ(0x7be6716408ULL, unwinder.frames()[4].pc);
|
||||||
|
EXPECT_EQ(0x7be4f07860ULL, unwinder.frames()[4].sp);
|
||||||
|
EXPECT_EQ(0x7be67168d8ULL, unwinder.frames()[5].pc);
|
||||||
|
EXPECT_EQ(0x7be4f07880ULL, unwinder.frames()[5].sp);
|
||||||
|
EXPECT_EQ(0x7be6716814ULL, unwinder.frames()[6].pc);
|
||||||
|
EXPECT_EQ(0x7be4f078f0ULL, unwinder.frames()[6].sp);
|
||||||
|
EXPECT_EQ(0x7be6704f60ULL, unwinder.frames()[7].pc);
|
||||||
|
EXPECT_EQ(0x7be4f07910ULL, unwinder.frames()[7].sp);
|
||||||
|
EXPECT_EQ(0x7be5f7b024ULL, unwinder.frames()[8].pc);
|
||||||
|
EXPECT_EQ(0x7be4f07950ULL, unwinder.frames()[8].sp);
|
||||||
|
EXPECT_EQ(0x7be5f7cad0ULL, unwinder.frames()[9].pc);
|
||||||
|
EXPECT_EQ(0x7be4f07aa0ULL, unwinder.frames()[9].sp);
|
||||||
|
EXPECT_EQ(0x7be5f7cb64ULL, unwinder.frames()[10].pc);
|
||||||
|
EXPECT_EQ(0x7be4f07ce0ULL, unwinder.frames()[10].sp);
|
||||||
|
EXPECT_EQ(0x7cbe11406cULL, unwinder.frames()[11].pc);
|
||||||
|
EXPECT_EQ(0x7be4f07d00ULL, unwinder.frames()[11].sp);
|
||||||
|
EXPECT_EQ(0x7cbe0b5e18ULL, unwinder.frames()[12].pc);
|
||||||
|
EXPECT_EQ(0x7be4f07d20ULL, unwinder.frames()[12].sp);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace unwindstack
|
} // namespace unwindstack
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -0,0 +1,3 @@
|
||||||
|
7be5e48000-7be6b2b000 r-xp 5000 00:00 0 test.apk
|
||||||
|
7cbe030000-7cbe070000 r--p 0 00:00 0 libc.so
|
||||||
|
7cbe070000-7cbe11a000 r-xp 40000 00:00 0 libc.so
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
x0: 7c326f6568
|
||||||
|
x1: 80
|
||||||
|
x2: 0
|
||||||
|
x3: 0
|
||||||
|
x4: 0
|
||||||
|
x5: 0
|
||||||
|
x6: 0
|
||||||
|
x7: 7f7f7f7f7f7f7f7f
|
||||||
|
x8: 62
|
||||||
|
x9: 1
|
||||||
|
x10: 1
|
||||||
|
x11: 0
|
||||||
|
x12: ffffffffc4653600
|
||||||
|
x13: 17645696f
|
||||||
|
x14: 2742ed97ca77a3
|
||||||
|
x15: 3ab49084
|
||||||
|
x16: 7be6b6bdb8
|
||||||
|
x17: 7cbe0b14a0
|
||||||
|
x18: 7c2b02a000
|
||||||
|
x19: 0
|
||||||
|
x20: 7c326f6568
|
||||||
|
x21: 7be69c827c
|
||||||
|
x22: 7be69c8272
|
||||||
|
x23: 1
|
||||||
|
x24: 7be74f7100
|
||||||
|
x25: 881
|
||||||
|
x26: 7be4f07a00
|
||||||
|
x27: c479c000
|
||||||
|
x28: 7be4f07998
|
||||||
|
x29: 7be4f079b4
|
||||||
|
sp: 7be4f077d0
|
||||||
|
lr: 7be6715f60
|
||||||
|
pc: 7cbe0b14bc
|
||||||
Binary file not shown.
Binary file not shown.
Loading…
Add table
Reference in a new issue