Merge "Fix setting of map_offset in frame data."

am: 8158d708c3

Change-Id: I14c4f2cd4273c5434226ea9765ca74a30bf69630
This commit is contained in:
Christopher Ferris 2017-10-18 18:07:29 +00:00 committed by android-build-merger
commit 57638bf967
2 changed files with 38 additions and 1 deletions

View File

@ -52,7 +52,7 @@ void Unwinder::FillInFrame(MapInfo* map_info, Elf* elf, uint64_t rel_pc, bool ad
}
frame->map_name = map_info->name;
frame->map_offset = map_info->elf_offset;
frame->map_offset = map_info->offset;
frame->map_start = map_info->start;
frame->map_end = map_info->end;
frame->map_flags = map_info->flags;

View File

@ -95,6 +95,16 @@ class UnwinderTest : public ::testing::Test {
info.elf = elf;
elf->FakeSetInterface(new ElfInterfaceFake(nullptr));
maps_.FakeAddMapInfo(info);
info.name = "/fake/fake.apk";
info.start = 0x43000;
info.end = 0x44000;
info.offset = 0x1d000;
info.flags = PROT_READ | PROT_WRITE;
elf = new ElfFake(nullptr);
info.elf = elf;
elf->FakeSetInterface(new ElfInterfaceFake(nullptr));
maps_.FakeAddMapInfo(info);
}
void SetUp() override {
@ -170,6 +180,33 @@ TEST_F(UnwinderTest, multiple_frames) {
EXPECT_EQ(PROT_READ | PROT_WRITE, frame->map_flags);
}
TEST_F(UnwinderTest, non_zero_map_offset) {
ElfInterfaceFake::FakePushFunctionData(FunctionData("Frame0", 0));
regs_.FakeSetPc(0x43000);
regs_.FakeSetSp(0x10000);
ElfInterfaceFake::FakePushStepData(StepData(0, 0, true));
Unwinder unwinder(64, &maps_, &regs_, process_memory_);
unwinder.Unwind();
ASSERT_EQ(1U, unwinder.NumFrames());
auto* frame = &unwinder.frames()[0];
EXPECT_EQ(0U, frame->num);
EXPECT_EQ(0U, frame->rel_pc);
EXPECT_EQ(0x43000U, frame->pc);
EXPECT_EQ(0x10000U, frame->sp);
EXPECT_EQ("Frame0", frame->function_name);
EXPECT_EQ(0U, frame->function_offset);
EXPECT_EQ("/fake/fake.apk", frame->map_name);
EXPECT_EQ(0x1d000U, frame->map_offset);
EXPECT_EQ(0x43000U, frame->map_start);
EXPECT_EQ(0x44000U, frame->map_end);
EXPECT_EQ(0U, frame->map_load_bias);
EXPECT_EQ(PROT_READ | PROT_WRITE, frame->map_flags);
}
// Verify that no attempt to continue after the step indicates it is done.
TEST_F(UnwinderTest, no_frames_after_finished) {
ElfInterfaceFake::FakePushFunctionData(FunctionData("Frame0", 0));