| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2016 The Chromium Authors. All rights reserved. | 2 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import argparse | 6 import argparse |
| 7 import bisect | 7 import bisect |
| 8 import collections | 8 import collections |
| 9 import gzip | 9 import gzip |
| 10 import json | 10 import json |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 # Encapsulates platform-specific symbolization logic. | 58 # Encapsulates platform-specific symbolization logic. |
| 59 def __init__(self): | 59 def __init__(self): |
| 60 self.is_mac = sys.platform == 'darwin' | 60 self.is_mac = sys.platform == 'darwin' |
| 61 if self.is_mac: | 61 if self.is_mac: |
| 62 self.binary = 'atos' | 62 self.binary = 'atos' |
| 63 self._matcher = symbolize_trace_atos_regex.AtosRegexMatcher() | 63 self._matcher = symbolize_trace_atos_regex.AtosRegexMatcher() |
| 64 else: | 64 else: |
| 65 self.binary = 'addr2line' | 65 self.binary = 'addr2line' |
| 66 self.symbolizer_path = FindInSystemPath(self.binary) | 66 self.symbolizer_path = FindInSystemPath(self.binary) |
| 67 | 67 |
| 68 def _SymbolizeLinuxAndAndroid(self, symfile): | 68 def _SymbolizeLinuxAndAndroid(self, symfile, unsymbolized_name): |
| 69 def _SymbolizerCallback(sym_info, frames): | 69 def _SymbolizerCallback(sym_info, frames): |
| 70 # Unwind inline chain to the top. | 70 # Unwind inline chain to the top. |
| 71 while sym_info.inlined_by: | 71 while sym_info.inlined_by: |
| 72 sym_info = sym_info.inlined_by | 72 sym_info = sym_info.inlined_by |
| 73 | 73 |
| 74 symbolized_name = sym_info.name if sym_info.name else unsymbolized_name | 74 symbolized_name = sym_info.name if sym_info.name else unsymbolized_name |
| 75 for frame in frames: | 75 for frame in frames: |
| 76 frame.name = symbolized_name | 76 frame.name = symbolized_name |
| 77 | 77 |
| 78 symbolizer = elf_symbolizer.ELFSymbolizer(symfile.symbolizable_path, | 78 symbolizer = elf_symbolizer.ELFSymbolizer(symfile.symbolizable_path, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 111 |
| 112 cmd = list(cmd_base) | 112 cmd = list(cmd_base) |
| 113 cmd.extend([hex(int(x)) for x in keys_to_process]) | 113 cmd.extend([hex(int(x)) for x in keys_to_process]) |
| 114 output_array = subprocess.check_output(cmd).split('\n') | 114 output_array = subprocess.check_output(cmd).split('\n') |
| 115 for i in range(len(keys_to_process)): | 115 for i in range(len(keys_to_process)): |
| 116 for frame in symfile.frames_by_address.values()[i + processed_keys_count
]: | 116 for frame in symfile.frames_by_address.values()[i + processed_keys_count
]: |
| 117 frame.name = self._matcher.Match(output_array[i]) | 117 frame.name = self._matcher.Match(output_array[i]) |
| 118 processed_keys_count += len(keys_to_process) | 118 processed_keys_count += len(keys_to_process) |
| 119 all_keys = all_keys[input_count:] | 119 all_keys = all_keys[input_count:] |
| 120 | 120 |
| 121 def Symbolize(self, symfile): | 121 def Symbolize(self, symfile, unsymbolized_name): |
| 122 if self.is_mac: | 122 if self.is_mac: |
| 123 self._SymbolizeMac(symfile) | 123 self._SymbolizeMac(symfile) |
| 124 else: | 124 else: |
| 125 self._SymbolizeLinuxAndAndroid(symfile) | 125 self._SymbolizeLinuxAndAndroid(symfile, unsymbolized_name) |
| 126 | 126 |
| 127 | 127 |
| 128 def IsSymbolizableFile(file_path): | 128 def IsSymbolizableFile(file_path): |
| 129 result = subprocess.check_output(['file', '-0', file_path]) | 129 result = subprocess.check_output(['file', '-0', file_path]) |
| 130 type_string = result[result.find('\0') + 1:] | 130 type_string = result[result.find('\0') + 1:] |
| 131 return bool(re.match(r'.*(ELF|Mach-O) (32|64)-bit\b.*', | 131 return bool(re.match(r'.*(ELF|Mach-O) (32|64)-bit\b.*', |
| 132 type_string, re.DOTALL)) | 132 type_string, re.DOTALL)) |
| 133 | 133 |
| 134 | 134 |
| 135 class ProcessMemoryMaps(object): | 135 class ProcessMemoryMaps(object): |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 problem) | 372 problem) |
| 373 for frames in symfile.frames_by_address.itervalues(): | 373 for frames in symfile.frames_by_address.itervalues(): |
| 374 for frame in frames: | 374 for frame in frames: |
| 375 frame.name = unsymbolized_name | 375 frame.name = unsymbolized_name |
| 376 continue | 376 continue |
| 377 | 377 |
| 378 _SubPrintf('Symbolizing {} PCs from {}...', | 378 _SubPrintf('Symbolizing {} PCs from {}...', |
| 379 len(symfile.frames_by_address), | 379 len(symfile.frames_by_address), |
| 380 symfile.path) | 380 symfile.path) |
| 381 | 381 |
| 382 symbolizer.Symbolize(symfile) | 382 symbolizer.Symbolize(symfile, unsymbolized_name) |
| 383 symbolized = True | 383 symbolized = True |
| 384 | 384 |
| 385 return symbolized | 385 return symbolized |
| 386 | 386 |
| 387 | 387 |
| 388 def HaveFilesFromAndroid(symfiles): | 388 def HaveFilesFromAndroid(symfiles): |
| 389 return any(ANDROID_PATH_MATCHER.match(f.path) for f in symfiles) | 389 return any(ANDROID_PATH_MATCHER.match(f.path) for f in symfiles) |
| 390 | 390 |
| 391 | 391 |
| 392 def RemapAndroidFiles(symfiles, output_path): | 392 def RemapAndroidFiles(symfiles, output_path): |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 | 453 |
| 454 print 'Updating trace file...' | 454 print 'Updating trace file...' |
| 455 with _OpenTraceFile('w') as trace_file: | 455 with _OpenTraceFile('w') as trace_file: |
| 456 json.dump(trace, trace_file) | 456 json.dump(trace, trace_file) |
| 457 else: | 457 else: |
| 458 print 'No PCs symbolized - not updating trace file.' | 458 print 'No PCs symbolized - not updating trace file.' |
| 459 | 459 |
| 460 | 460 |
| 461 if __name__ == '__main__': | 461 if __name__ == '__main__': |
| 462 main() | 462 main() |
| OLD | NEW |