OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 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 """Symbolizes a log file produced by cyprofile instrumentation. | 6 """Symbolizes a log file produced by cyprofile instrumentation. |
7 | 7 |
8 Given a log file and the binary being profiled, creates an orderfile. | 8 Given a log file and the binary being profiled, creates an orderfile. |
9 """ | 9 """ |
10 | 10 |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 except SymbolNotFoundException: | 213 except SymbolNotFoundException: |
214 symbol_not_found_warnings.Write( | 214 symbol_not_found_warnings.Write( |
215 'Did not find function in binary. offset: ' + hex(offset)) | 215 'Did not find function in binary. offset: ' + hex(offset)) |
216 success = False | 216 success = False |
217 unknown_symbol_warnings.WriteEnd('no known section for symbol.') | 217 unknown_symbol_warnings.WriteEnd('no known section for symbol.') |
218 symbol_not_found_warnings.WriteEnd('symbol not found in the binary.') | 218 symbol_not_found_warnings.WriteEnd('symbol not found in the binary.') |
219 return success | 219 return success |
220 | 220 |
221 | 221 |
222 def main(): | 222 def main(): |
223 if len(sys.argv) != 4: | 223 parser = optparse.OptionParser(usage= |
224 logging.error('Usage: cyglog_to_orderfile.py <merged_cyglog> ' | 224 'usage: %prog [options] <merged_cyglog> <library> <output_filename>') |
225 '<library> <output_filename>') | 225 parser.add_option('--target-arch', action='store', dest='arch', |
| 226 default='arm', |
| 227 choices=['arm', 'arm64', 'x86', 'x86_64', 'x64', 'mips'], |
| 228 help='The target architecture for libchrome.so') |
| 229 options, argv = parser.parse_args(sys.argv) |
| 230 if len(argv) != 4: |
| 231 parser.print_help() |
226 return 1 | 232 return 1 |
227 (log_filename, lib_filename, output_filename) = sys.argv[1:] | 233 (log_filename, lib_filename, output_filename) = argv[1:] |
| 234 symbol_extractor.SetArchitecture(options.arch) |
228 | 235 |
229 obj_dir = os.path.abspath(os.path.join( | 236 obj_dir = os.path.abspath(os.path.join( |
230 os.path.dirname(lib_filename), '../obj')) | 237 os.path.dirname(lib_filename), '../obj')) |
231 | 238 |
232 log_file_lines = map(string.rstrip, open(log_filename).readlines()) | 239 log_file_lines = map(string.rstrip, open(log_filename).readlines()) |
233 offsets = _ParseLogLines(log_file_lines) | 240 offsets = _ParseLogLines(log_file_lines) |
234 _WarnAboutDuplicates(offsets) | 241 _WarnAboutDuplicates(offsets) |
235 | 242 |
236 offset_to_symbol_infos = _GroupLibrarySymbolInfosByOffset(lib_filename) | 243 offset_to_symbol_infos = _GroupLibrarySymbolInfosByOffset(lib_filename) |
237 symbol_to_section_map = _GetSymbolToSectionMapFromObjectFiles(obj_dir) | 244 symbol_to_section_map = _GetSymbolToSectionMapFromObjectFiles(obj_dir) |
(...skipping 15 matching lines...) Expand all Loading... |
253 output_file.close() | 260 output_file.close() |
254 if temp_filename: | 261 if temp_filename: |
255 os.remove(temp_filename) | 262 os.remove(temp_filename) |
256 | 263 |
257 return 0 if success else 1 | 264 return 0 if success else 1 |
258 | 265 |
259 | 266 |
260 if __name__ == '__main__': | 267 if __name__ == '__main__': |
261 logging.basicConfig(level=logging.INFO) | 268 logging.basicConfig(level=logging.INFO) |
262 sys.exit(main()) | 269 sys.exit(main()) |
OLD | NEW |