diff options
author | Christopher Ferris <cferris@google.com> | 2020-01-22 12:17:06 -0800 |
---|---|---|
committer | Christopher Ferris <cferris@google.com> | 2020-01-22 18:30:12 -0800 |
commit | 0f40a0530976bc7fe2213944d69851821eb402c7 (patch) | |
tree | 515b7c5168a6b3e58e5c73ebea9f0a7db38922e5 /libunwindstack/tests/ElfCacheTest.cpp | |
parent | 929c9e8b40fe6adb23a140a8584d69edb2cab636 (diff) |
Properly handle empty map after read-only map.
Recently, the maps for an elf in memory might show up looking like:
f0000-f1000 0 r-- /system/lib/libc.so
f1000-f2000 0 ---
f2000-f3000 1000 r-x /system/lib/libc.so
f3000-f4000 2000 rw- /system/lib/libc.so
The problem is that there is logic in the code that assumed that the
map before the execute map must be the read-only map. In the case
above, this is not true. Add a new prev_real_map that will point
to the previous map that is not one of these empty maps.
This will fix the backtraces that look like this:
#00 pc 0000000000050d58 /apex/com.android.runtime/lib64/bionic/libc.so!libc.so (offset 0x50000) (syscall+24) (BuildId: 5252408bf30e395d49ee270b54c77ca4)
To get rid of the !libc.so and the offset value, which is not correct.
Added new unit tests to verify this.
Added new offline test which an empty map between read-only and execute
map. Before this change, the backtraces had lines like
libc.so!libc.so (offset XXX) would be present.
Bug: 148075852
Test: Ran unit tests.
Change-Id: Ie04bfc96b8f91ed885cb1e655cf1e346efe48a45
Diffstat (limited to 'libunwindstack/tests/ElfCacheTest.cpp')
-rw-r--r-- | libunwindstack/tests/ElfCacheTest.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/libunwindstack/tests/ElfCacheTest.cpp b/libunwindstack/tests/ElfCacheTest.cpp index 573585837..5f135467d 100644 --- a/libunwindstack/tests/ElfCacheTest.cpp +++ b/libunwindstack/tests/ElfCacheTest.cpp @@ -78,8 +78,8 @@ void ElfCacheTest::VerifySameMap(bool cache_enabled) { uint64_t start = 0x1000; uint64_t end = 0x20000; - MapInfo info1(nullptr, start, end, 0, 0x5, tf.path); - MapInfo info2(nullptr, start, end, 0, 0x5, tf.path); + MapInfo info1(nullptr, nullptr, start, end, 0, 0x5, tf.path); + MapInfo info2(nullptr, nullptr, start, end, 0, 0x5, tf.path); Elf* elf1 = info1.GetElf(memory_, ARCH_ARM); ASSERT_TRUE(elf1->valid()); @@ -119,17 +119,17 @@ void ElfCacheTest::VerifyWithinSameMap(bool cache_enabled) { uint64_t start = 0x1000; uint64_t end = 0x20000; // Will have an elf at offset 0 in file. - MapInfo info0_1(nullptr, start, end, 0, 0x5, tf.path); - MapInfo info0_2(nullptr, start, end, 0, 0x5, tf.path); + MapInfo info0_1(nullptr, nullptr, start, end, 0, 0x5, tf.path); + MapInfo info0_2(nullptr, nullptr, start, end, 0, 0x5, tf.path); // Will have an elf at offset 0x100 in file. - MapInfo info100_1(nullptr, start, end, 0x100, 0x5, tf.path); - MapInfo info100_2(nullptr, start, end, 0x100, 0x5, tf.path); + MapInfo info100_1(nullptr, nullptr, start, end, 0x100, 0x5, tf.path); + MapInfo info100_2(nullptr, nullptr, start, end, 0x100, 0x5, tf.path); // Will have an elf at offset 0x200 in file. - MapInfo info200_1(nullptr, start, end, 0x200, 0x5, tf.path); - MapInfo info200_2(nullptr, start, end, 0x200, 0x5, tf.path); + MapInfo info200_1(nullptr, nullptr, start, end, 0x200, 0x5, tf.path); + MapInfo info200_2(nullptr, nullptr, start, end, 0x200, 0x5, tf.path); // Will have an elf at offset 0 in file. - MapInfo info300_1(nullptr, start, end, 0x300, 0x5, tf.path); - MapInfo info300_2(nullptr, start, end, 0x300, 0x5, tf.path); + MapInfo info300_1(nullptr, nullptr, start, end, 0x300, 0x5, tf.path); + MapInfo info300_2(nullptr, nullptr, start, end, 0x300, 0x5, tf.path); Elf* elf0_1 = info0_1.GetElf(memory_, ARCH_ARM); ASSERT_TRUE(elf0_1->valid()); @@ -216,10 +216,10 @@ void ElfCacheTest::VerifyWithinSameMapNeverReadAtZero(bool cache_enabled) { uint64_t start = 0x1000; uint64_t end = 0x20000; // Multiple info sections at different offsets will have non-zero elf offsets. - MapInfo info300_1(nullptr, start, end, 0x300, 0x5, tf.path); - MapInfo info300_2(nullptr, start, end, 0x300, 0x5, tf.path); - MapInfo info400_1(nullptr, start, end, 0x400, 0x5, tf.path); - MapInfo info400_2(nullptr, start, end, 0x400, 0x5, tf.path); + MapInfo info300_1(nullptr, nullptr, start, end, 0x300, 0x5, tf.path); + MapInfo info300_2(nullptr, nullptr, start, end, 0x300, 0x5, tf.path); + MapInfo info400_1(nullptr, nullptr, start, end, 0x400, 0x5, tf.path); + MapInfo info400_2(nullptr, nullptr, start, end, 0x400, 0x5, tf.path); Elf* elf300_1 = info300_1.GetElf(memory_, ARCH_ARM); ASSERT_TRUE(elf300_1->valid()); |