def test_parse_stack_frame(self):
        """Check that stackframes are correctly parsed."""
        spec = stack_parser.StackFrameSpec(
            address=1,
            filename=[4, 8],
            fileline=[5, 9],
        )
        stack_frame_regex = re.compile(
            r'([xXa-fA-F0-9]*) '
            # optional parts: filename:line:char or filename:line
            r'(((\w+):(\d+):(\d+))|((\w+):(\d+)))')
        stack_frame_lines = [
            '0xa1c0 a_file:1234:56',
            '0xa1c0 a_file:1234',
        ]
        stack_frames = []
        for stack_frame_line in stack_frame_lines:
            m = stack_frame_regex.match(stack_frame_line)
            stack_frames.append(spec.parse_stack_frame(m))

        for stack_frame in stack_frames:
            self.assertEqual(stack_frame.address, 41408)
            self.assertEqual(stack_frame.filename, 'a_file')
            self.assertEqual(stack_frame.fileline, '1234')
Example #2
0
]

# Additional regexes for cleaning up format.
STRIP_STRUCTURE_REGEXES = [
    re.compile(r'^in (.*)'),  # sanitizers have prefix for function if present
    re.compile(r'^\((.*)\)$'),  # sanitizers wrap module if no function
]

# Other constants.
LINE_LENGTH_CAP = 80
MAX_CRASH_STATE_FRAMES = 3
MAX_CYCLE_LENGTH = 10
REPEATED_CYCLE_COUNT = 3

# Stackframe format specifications.
CHROME_STACK_FRAME_SPEC = stack_parser.StackFrameSpec(address=3,
                                                      function_name=4)
CHROME_WIN_STACK_FRAME_SPEC = stack_parser.StackFrameSpec(function_name=1,
                                                          function_base=2,
                                                          function_offset=3,
                                                          filename=5,
                                                          fileline=6,
                                                          base=10)
CHROME_MAC_STACK_FRAME_SPEC = stack_parser.StackFrameSpec(address=5,
                                                          function_name=6,
                                                          function_offset=7,
                                                          module_name=2,
                                                          base=10)
SAN_STACK_FRAME_SPEC = stack_parser.StackFrameSpec(address=2,
                                                   function_name=[7, 5, 23],
                                                   function_offset=8,
                                                   filename=[12, 16],