diff options
author | Christopher Ferris <cferris@google.com> | 2019-05-03 11:13:17 -0700 |
---|---|---|
committer | Christopher Ferris <cferris@google.com> | 2019-05-03 15:46:24 -0700 |
commit | 52d5b982e24c21954b95275d4292dc8668083f24 (patch) | |
tree | 8f43b4b0eea63ec7fa2b609985c8c4874efcc000 | |
parent | baeacbe4dad6a3dbbbfda306adeb403835edf160 (diff) | |
download | unwinding-52d5b982e24c21954b95275d4292dc8668083f24.tar.gz |
Ignore memory from elf on /memfd:android10-tests-releaseandroid10-tests-devandroid10-qpr3-s1-releaseandroid10-qpr3-releaseandroid10-qpr2-s4-releaseandroid10-qpr2-s3-releaseandroid10-qpr2-s2-releaseandroid10-qpr2-s1-releaseandroid10-qpr2-releaseandroid10-qpr1-releaseandroid10-qpr1-mainline-releaseandroid10-qpr1-d-releaseandroid10-qpr1-c-s1-releaseandroid10-qpr1-c-releaseandroid10-qpr1-b-s1-releaseandroid10-qpr1-b-releaseandroid10-mainline-media-releaseandroid10-devandroid10-d4-s1-releaseandroid10-d4-releaseandroid10-c2f2-s2-releaseandroid10-c2f2-s1-releaseandroid10-c2f2-release
In ART, some of the maps are /memfd:/jit-cache and it triggers the warning
about unreadable elf files. Do not set the elf from memory not file
flag in this case.
Bug: 131909548
Test: New unit tests pass.
Test: No warnings dumping stacks with this change done.
Change-Id: Ifba5e65da609525ded75430da173c614f6e4801e
(cherry picked from commit 98aaf4cf086e2492796b11116e69e0ff01093663)
-rw-r--r-- | libunwindstack/Unwinder.cpp | 3 | ||||
-rw-r--r-- | libunwindstack/tests/UnwinderTest.cpp | 36 |
2 files changed, 38 insertions, 1 deletions
diff --git a/libunwindstack/Unwinder.cpp b/libunwindstack/Unwinder.cpp index 26626b5..37323dc 100644 --- a/libunwindstack/Unwinder.cpp +++ b/libunwindstack/Unwinder.cpp @@ -25,6 +25,7 @@ #include <algorithm> #include <android-base/stringprintf.h> +#include <android-base/strings.h> #include <demangle.h> @@ -168,7 +169,7 @@ void Unwinder::Unwind(const std::vector<std::string>* initial_map_names_to_skip, // If this elf is memory backed, and there is a valid file, then set // an indicator that we couldn't open the file. if (!elf_from_memory_not_file_ && map_info->memory_backed_elf && !map_info->name.empty() && - map_info->name[0] != '[') { + map_info->name[0] != '[' && !android::base::StartsWith(map_info->name, "/memfd:")) { elf_from_memory_not_file_ = true; } step_pc = regs_->pc(); diff --git a/libunwindstack/tests/UnwinderTest.cpp b/libunwindstack/tests/UnwinderTest.cpp index f635021..30e57a1 100644 --- a/libunwindstack/tests/UnwinderTest.cpp +++ b/libunwindstack/tests/UnwinderTest.cpp @@ -126,6 +126,12 @@ class UnwinderTest : public ::testing::Test { const auto& info5 = *--maps_->end(); info5->memory_backed_elf = true; + elf = new ElfFake(new MemoryFake); + elf->FakeSetInterface(new ElfInterfaceFake(nullptr)); + AddMapInfo(0xc3000, 0xc4000, 0, PROT_READ | PROT_WRITE | PROT_EXEC, "/memfd:/jit-cache", elf); + const auto& info6 = *--maps_->end(); + info6->memory_backed_elf = true; + process_memory_.reset(new MemoryFake); } @@ -1234,6 +1240,36 @@ TEST_F(UnwinderTest, elf_from_memory_but_empty_filename) { EXPECT_EQ(PROT_READ | PROT_WRITE | PROT_EXEC, frame->map_flags); } +TEST_F(UnwinderTest, elf_from_memory_but_from_memfd) { + ElfInterfaceFake::FakePushFunctionData(FunctionData("Frame0", 0)); + + regs_.set_pc(0xc3050); + regs_.set_sp(0x10000); + ElfInterfaceFake::FakePushStepData(StepData(0, 0, true)); + + Unwinder unwinder(64, maps_.get(), ®s_, process_memory_); + unwinder.Unwind(); + EXPECT_EQ(ERROR_NONE, unwinder.LastErrorCode()); + EXPECT_FALSE(unwinder.elf_from_memory_not_file()); + + ASSERT_EQ(1U, unwinder.NumFrames()); + + auto* frame = &unwinder.frames()[0]; + EXPECT_EQ(0U, frame->num); + EXPECT_EQ(0x50U, frame->rel_pc); + EXPECT_EQ(0xc3050U, frame->pc); + EXPECT_EQ(0x10000U, frame->sp); + EXPECT_EQ("Frame0", frame->function_name); + EXPECT_EQ(0U, frame->function_offset); + EXPECT_EQ("/memfd:/jit-cache", frame->map_name); + EXPECT_EQ(0U, frame->map_elf_start_offset); + EXPECT_EQ(0U, frame->map_exact_offset); + EXPECT_EQ(0xc3000U, frame->map_start); + EXPECT_EQ(0xc4000U, frame->map_end); + EXPECT_EQ(0U, frame->map_load_bias); + EXPECT_EQ(PROT_READ | PROT_WRITE | PROT_EXEC, frame->map_flags); +} + // Verify format frame code. TEST_F(UnwinderTest, format_frame) { RegsFake regs_arm(10); |