Exemple #1
0
    def testReadFunctionCfiTombstoneFiltered(self):
        input_lines = [
            'STACK CFI INIT 0 50 .cfa: sp 0 + .ra: lr',  # Tombstone function.
            'STACK CFI 2 .cfa: sp 24 + .ra: .cfa - 4 + ^ r4: .cfa - 16 + ^ '
            'r5: .cfa - 12 + ^ r7: .cfa - 8 + ^',
            'STACK CFI INIT 15b6490 4 .cfa: sp 0 + .ra: lr',
        ]

        f = io.StringIO(''.join(line + '\n' for line in input_lines))

        self.assertEqual([
            FunctionCfi(4, (AddressCfi(0x15b6490, '.cfa: sp 0 + .ra: lr'), ))
        ], list(ReadFunctionCfi(f)))
Exemple #2
0
    def testReadFunctionCfiMultipleFunctions(self):
        input_lines = [
            'STACK CFI INIT 15b6490 4 .cfa: sp 0 + .ra: lr',
            'STACK CFI 2 .cfa: sp 24 + .ra: .cfa - 4 + ^ r4: .cfa - 16 + ^ '
            'r5: .cfa - 12 + ^ r7: .cfa - 8 + ^',
            'STACK CFI INIT 15b655a 26 .cfa: sp 0 + .ra: lr',
            'STACK CFI 15b655c .cfa: sp 8 + .ra: .cfa - 4 + ^ r4: .cfa - 8 + ^',
        ]

        f = io.StringIO(''.join(line + '\n' for line in input_lines))

        self.assertEqual([
            FunctionCfi(0x4, (
                AddressCfi(0x15b6490, '.cfa: sp 0 + .ra: lr'),
                AddressCfi(
                    0x2, '.cfa: sp 24 + .ra: .cfa - 4 + ^ r4: .cfa - 16 + ^ '
                    'r5: .cfa - 12 + ^ r7: .cfa - 8 + ^'),
            )),
            FunctionCfi(0x26, (
                AddressCfi(0x15b655a, '.cfa: sp 0 + .ra: lr'),
                AddressCfi(0x15b655c,
                           '.cfa: sp 8 + .ra: .cfa - 4 + ^ r4: .cfa - 8 + ^'),
            )),
        ], list(ReadFunctionCfi(f)))