From b9de87f7edefd7a2473134b267716c5fd750e89f Mon Sep 17 00:00:00 2001 From: Christopher Ferris Date: Wed, 20 Sep 2017 13:37:24 -0700 Subject: Add a new unwind method on error. If a function crashes by jumping into unexecutable code, the old method could not unwind through that. Add a fallback method to set the pc from the default return address location. In addition, add a new finished check for steps. This will provide a method to indicate that this step is the last step. This prevents cases where the fallback method might be triggered incorrectly. Update the libbacktrace code to unwind using the new methodology. Update the unwind tool to use the new unwind methodology. Add a new option to crasher that calls through a null function. Create a new object, Unwinder, that encapsulates the a basic unwind. For now, libbacktrace will still use the custom code. Added new unit tests to cover the new cases. Also add a test that crashes calling a nullptr as a function, and then has call frames in the signal stack. Bug: 65842173 Test: Pass all unit tests, verify crasher dumps properly. Change-Id: Ia18430ab107e9f7bdf0e14a9b74710b1280bd7f4 --- libunwindstack/tests/DwarfSectionTest.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'libunwindstack/tests/DwarfSectionTest.cpp') diff --git a/libunwindstack/tests/DwarfSectionTest.cpp b/libunwindstack/tests/DwarfSectionTest.cpp index fc67063c5..3fcd2b61f 100644 --- a/libunwindstack/tests/DwarfSectionTest.cpp +++ b/libunwindstack/tests/DwarfSectionTest.cpp @@ -32,7 +32,7 @@ class MockDwarfSection : public DwarfSection { MOCK_METHOD4(Log, bool(uint8_t, uint64_t, uint64_t, const DwarfFde*)); - MOCK_METHOD4(Eval, bool(const DwarfCie*, Memory*, const dwarf_loc_regs_t&, Regs*)); + MOCK_METHOD5(Eval, bool(const DwarfCie*, Memory*, const dwarf_loc_regs_t&, Regs*, bool*)); MOCK_METHOD3(GetCfaLocationInfo, bool(uint64_t, const DwarfFde*, dwarf_loc_regs_t*)); @@ -104,7 +104,8 @@ TEST_F(DwarfSectionTest, Step_fail_fde) { EXPECT_CALL(mock_section, GetFdeOffsetFromPc(0x1000, ::testing::_)) .WillOnce(::testing::Return(false)); - ASSERT_FALSE(mock_section.Step(0x1000, nullptr, nullptr)); + bool finished; + ASSERT_FALSE(mock_section.Step(0x1000, nullptr, nullptr, &finished)); } TEST_F(DwarfSectionTest, Step_fail_cie_null) { @@ -118,7 +119,8 @@ TEST_F(DwarfSectionTest, Step_fail_cie_null) { .WillOnce(::testing::Return(true)); EXPECT_CALL(mock_section, GetFdeFromOffset(::testing::_)).WillOnce(::testing::Return(&fde)); - ASSERT_FALSE(mock_section.Step(0x1000, nullptr, nullptr)); + bool finished; + ASSERT_FALSE(mock_section.Step(0x1000, nullptr, nullptr, &finished)); } TEST_F(DwarfSectionTest, Step_fail_cfa_location) { @@ -136,7 +138,8 @@ TEST_F(DwarfSectionTest, Step_fail_cfa_location) { EXPECT_CALL(mock_section, GetCfaLocationInfo(0x1000, &fde, ::testing::_)) .WillOnce(::testing::Return(false)); - ASSERT_FALSE(mock_section.Step(0x1000, nullptr, nullptr)); + bool finished; + ASSERT_FALSE(mock_section.Step(0x1000, nullptr, nullptr, &finished)); } TEST_F(DwarfSectionTest, Step_pass) { @@ -155,10 +158,11 @@ TEST_F(DwarfSectionTest, Step_pass) { .WillOnce(::testing::Return(true)); MemoryFake process; - EXPECT_CALL(mock_section, Eval(&cie, &process, ::testing::_, nullptr)) + EXPECT_CALL(mock_section, Eval(&cie, &process, ::testing::_, nullptr, ::testing::_)) .WillOnce(::testing::Return(true)); - ASSERT_TRUE(mock_section.Step(0x1000, nullptr, &process)); + bool finished; + ASSERT_TRUE(mock_section.Step(0x1000, nullptr, &process, &finished)); } } // namespace unwindstack -- cgit v1.2.3