diff options
| author | Christopher Ferris <cferris@google.com> | 2018-10-12 16:33:42 -0700 |
|---|---|---|
| committer | Christopher Ferris <cferris@google.com> | 2018-10-12 16:36:35 -0700 |
| commit | 9d0ad238cab5ebb5f780bcdb7a1d9b712e4d9c91 (patch) | |
| tree | 3d46d25d62d65fe8fd5a4da5648875b93fab1565 /libunwindstack/tests | |
| parent | b3bc8427505c55a4134eac438f118a9b1acb4e2f (diff) | |
| download | system_core-9d0ad238cab5ebb5f780bcdb7a1d9b712e4d9c91.tar.gz system_core-9d0ad238cab5ebb5f780bcdb7a1d9b712e4d9c91.tar.bz2 system_core-9d0ad238cab5ebb5f780bcdb7a1d9b712e4d9c91.zip | |
Fix problem adding too many frames.
When adding a frame with a dex pc, two frames will be added total. However,
if there is only enough room for a single frame, two get added any way.
Only add a single frame in this case, and add a unit test for this case.
Test: Passes unit tests.
Change-Id: If320584b126967a042c623d8fdf3f51dbc1c2251
Diffstat (limited to 'libunwindstack/tests')
| -rw-r--r-- | libunwindstack/tests/UnwinderTest.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/libunwindstack/tests/UnwinderTest.cpp b/libunwindstack/tests/UnwinderTest.cpp index 436903022..831d3b5b5 100644 --- a/libunwindstack/tests/UnwinderTest.cpp +++ b/libunwindstack/tests/UnwinderTest.cpp @@ -946,6 +946,33 @@ TEST_F(UnwinderTest, dex_pc_multiple_frames) { EXPECT_EQ(PROT_READ | PROT_WRITE, frame->map_flags); } +TEST_F(UnwinderTest, dex_pc_max_frames) { + ElfInterfaceFake::FakePushFunctionData(FunctionData("Frame0", 0)); + regs_.set_pc(0x1000); + regs_.set_sp(0x10000); + regs_.FakeSetDexPc(0xa3400); + + Unwinder unwinder(1, &maps_, ®s_, process_memory_); + unwinder.Unwind(); + EXPECT_EQ(ERROR_MAX_FRAMES_EXCEEDED, unwinder.LastErrorCode()); + + ASSERT_EQ(1U, unwinder.NumFrames()); + + auto* frame = &unwinder.frames()[0]; + EXPECT_EQ(0U, frame->num); + EXPECT_EQ(0x400U, frame->rel_pc); + EXPECT_EQ(0xa3400U, frame->pc); + EXPECT_EQ(0x10000U, frame->sp); + EXPECT_EQ("", frame->function_name); + EXPECT_EQ(0U, frame->function_offset); + EXPECT_EQ("/fake/fake.vdex", frame->map_name); + EXPECT_EQ(0U, frame->map_offset); + EXPECT_EQ(0xa3000U, frame->map_start); + EXPECT_EQ(0xa4000U, 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_static) { FrameData frame; |
