def assert_register_matches(self, abi, example_crash, stupid_pattern): tc = TraceConverter() lines = example_crash.split('\n') symbol.SetAbi(lines) tc.UpdateAbiRegexes() for line in lines: tc.ProcessLine(line) is_register = (re.search(stupid_pattern, line) is not None) matched = (tc.register_line.search(line) is not None) self.assertEquals(matched, is_register, line) tc.PrintOutput(tc.trace_lines, tc.value_lines)
def ConvertTrace(self, lines): lines = map(self.CleanLine, lines) try: if not symbol.ARCH: symbol.SetAbi(lines) self.UpdateAbiRegexes() for line in lines: self.ProcessLine(line) self.PrintOutput(self.trace_lines, self.value_lines) finally: # Delete any temporary files created while processing the lines. self.DeleteApkTmpFiles()
def test_long_asan_crash(self): tc = TraceConverter() lines = example_crashes.long_asan_crash.splitlines() symbol.SetAbi(lines) tc.UpdateAbiRegexes() # Test by making sure trace_line_count is monotonically non-decreasing. If the stack trace # is split, a separator is printed and trace_lines is flushed. trace_line_count = 0 for line in lines: tc.ProcessLine(line) self.assertLessEqual(trace_line_count, len(tc.trace_lines)) trace_line_count = len(tc.trace_lines) # The split happened at transition of frame #9 -> #10. Make sure we have parsed (and stored) # more than ten frames. self.assertGreater(trace_line_count, 10) tc.PrintOutput(tc.trace_lines, tc.value_lines)
def test_libmemunreachable(self): tc = TraceConverter() lines = example_crashes.libmemunreachable.split('\n') symbol.SetAbi(lines) self.assertEquals(symbol.ARCH, "arm") tc.UpdateAbiRegexes() header_lines = 0 trace_lines = 0 for line in lines: tc.ProcessLine(line) if re.search(tc.unreachable_line, line) is not None: header_lines += 1 if tc.MatchTraceLine(line) is not None: trace_lines += 1 self.assertEquals(header_lines, 3) self.assertEquals(trace_lines, 2) tc.PrintOutput(tc.trace_lines, tc.value_lines)
def test_value_line_skipped(self): tc = TraceConverter() symbol.SetAbi(["ABI: 'arm'"]) tc.UpdateAbiRegexes() tc.ProcessLine(" 12345678 00001000 .") self.assertEqual([], tc.value_lines)
# aprotoc -I=external/perf_data_converter/src/quipper -I=system/extras/perfprofd \ # --python_out=system/extras/perfprofd/scripts \ # system/extras/perfprofd/perfprofd_record.proto import perfprofd_record_pb2 import perf_data_pb2 # Make sure that symbol is on the PYTHONPATH, e.g., run as # PYTHONPATH=$PYTHONPATH:$ANDROID_BUILD_TOP/development/scripts python ... import symbol from symbol import SymbolInformation logging.basicConfig(format='%(message)s') # This is wrong. But then the symbol module is a bad quagmire. # TODO: Check build IDs. symbol.SetAbi(["ABI: 'arm64'"]) class MmapState(object): def __init__(self): self._list = SortedCollection((), lambda x: x[0]) def add_map(self, start, length, pgoff, name): map_tuple = (start, length, pgoff, name) self._list.insert(map_tuple) def find(self, addr): try: map_tuple = self._list.find_le(addr) if addr < map_tuple[0] + map_tuple[1]: return map_tuple