예제 #1
0
    def testCfaChange(self):
        parser = PushOrSubSpParser()
        match = parser.GetBreakpadInstructionsRegex().search('.cfa: sp 4 +')
        self.assertIsNotNone(match)

        address_unwind, new_cfa_sp_offset = parser.ParseFromMatch(
            address_offset=20, cfa_sp_offset=0, match=match)

        self.assertEqual(4, new_cfa_sp_offset)
        self.assertEqual(
            AddressUnwind(
                address_offset=20,
                unwind_type=UnwindType.UPDATE_SP_AND_OR_POP_REGISTERS,
                sp_offset=4,
                registers=()), address_unwind)
예제 #2
0
    def testRegistersOrdering(self):
        parser = PushOrSubSpParser()
        match = parser.GetBreakpadInstructionsRegex().search(
            'r10: .cfa -8 + ^ r7: .cfa -4 + ^')
        self.assertIsNotNone(match)

        address_unwind, new_cfa_sp_offset = parser.ParseFromMatch(
            address_offset=20, cfa_sp_offset=0, match=match)

        self.assertEqual(0, new_cfa_sp_offset)
        self.assertEqual(
            AddressUnwind(
                address_offset=20,
                unwind_type=UnwindType.UPDATE_SP_AND_OR_POP_REGISTERS,
                sp_offset=0,
                registers=(7, 10)), address_unwind)
예제 #3
0
    def testCfaAndRaAndRegistersChangePopAndSpUpdate(self):
        parser = PushOrSubSpParser()
        match = parser.GetBreakpadInstructionsRegex().search(
            '.cfa: sp 16 + .ra: .cfa -4 + ^ r4: .cfa -12 + ^ r7: .cfa -8 + ^')
        self.assertIsNotNone(match)

        address_unwind, new_cfa_sp_offset = parser.ParseFromMatch(
            address_offset=20, cfa_sp_offset=0, match=match)

        self.assertEqual(16, new_cfa_sp_offset)
        self.assertEqual(
            AddressUnwind(
                address_offset=20,
                unwind_type=UnwindType.UPDATE_SP_AND_OR_POP_REGISTERS,
                sp_offset=4,
                registers=(4, 7, 14)), address_unwind)
예제 #4
0
    def testPoppingCallerSaveRegisters(self):
        """Regression test for pop unwinds that encode caller-save registers.

    Callee-save registers: r0 ~ r3.
    """
        parser = PushOrSubSpParser()
        match = parser.GetBreakpadInstructionsRegex().search(
            '.cfa: sp 16 + .ra: .cfa -4 + ^ '
            'r3: .cfa -16 + ^ r4: .cfa -12 + ^ r5: .cfa -8 + ^')

        self.assertIsNotNone(match)

        address_unwind, new_cfa_sp_offset = parser.ParseFromMatch(
            address_offset=20, cfa_sp_offset=0, match=match)

        self.assertEqual(16, new_cfa_sp_offset)
        self.assertEqual(
            AddressUnwind(
                address_offset=20,
                unwind_type=UnwindType.UPDATE_SP_AND_OR_POP_REGISTERS,
                sp_offset=4,
                registers=(4, 5, 14)), address_unwind)