Loading libunwindstack/Unwinder.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ #include <algorithm> #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <demangle.h> Loading Loading @@ -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(); Loading libunwindstack/tests/UnwinderTest.cpp +36 −0 Original line number Diff line number Diff line Loading @@ -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); } Loading Loading @@ -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); Loading Loading
libunwindstack/Unwinder.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ #include <algorithm> #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <demangle.h> Loading Loading @@ -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(); Loading
libunwindstack/tests/UnwinderTest.cpp +36 −0 Original line number Diff line number Diff line Loading @@ -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); } Loading Loading @@ -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); Loading