OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 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 """Generate a spatial analysis against an arbitrary library. | 6 """Generate a spatial analysis against an arbitrary library. |
7 | 7 |
8 To use, build the 'binary_size_tool' target. Then run this tool, passing | 8 To use, build the 'binary_size_tool' target. Then run this tool, passing |
9 in the location of the library to be analyzed along with any other options | 9 in the location of the library to be analyzed along with any other options |
10 you desire. | 10 you desire. |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 speed = 0 | 533 speed = 0 |
534 progress_percent = (100.0 * (progress.count + progress.skip_count) / | 534 progress_percent = (100.0 * (progress.count + progress.skip_count) / |
535 nm_output_lines_len) | 535 nm_output_lines_len) |
536 disambiguation_percent = 0 | 536 disambiguation_percent = 0 |
537 if progress.disambiguations != 0: | 537 if progress.disambiguations != 0: |
538 disambiguation_percent = (100.0 * progress.disambiguations / | 538 disambiguation_percent = (100.0 * progress.disambiguations / |
539 progress.was_ambiguous) | 539 progress.was_ambiguous) |
540 | 540 |
541 sys.stdout.write('\r%.1f%%: Looked up %d symbols (%d collisions, ' | 541 sys.stdout.write('\r%.1f%%: Looked up %d symbols (%d collisions, ' |
542 '%d disambiguations where %.1f%% succeeded)' | 542 '%d disambiguations where %.1f%% succeeded)' |
543 '- %.1f lookups/s.' % | 543 ' - %.1f lookups/s.' % |
544 (progress_percent, progress.count, progress.collisions, | 544 (progress_percent, progress.count, progress.collisions, |
545 progress.disambiguations, disambiguation_percent, speed)) | 545 progress.disambiguations, disambiguation_percent, speed)) |
546 | 546 |
547 # In case disambiguation was disabled, we remove the source path (which upon | 547 # In case disambiguation was disabled, we remove the source path (which upon |
548 # being set signals the symbolizer to enable disambiguation) | 548 # being set signals the symbolizer to enable disambiguation) |
549 if not disambiguate: | 549 if not disambiguate: |
550 src_path = None | 550 src_path = None |
551 symbolizer = elf_symbolizer.ELFSymbolizer(library, addr2line_binary, | 551 symbolizer = elf_symbolizer.ELFSymbolizer(library, addr2line_binary, |
552 map_address_symbol, | 552 map_address_symbol, |
553 max_concurrent_jobs=jobs, | 553 max_concurrent_jobs=jobs, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 line_number = symbol.source_line | 610 line_number = symbol.source_line |
611 out.write('%s\t%s:%d\n' % (line, path, line_number)) | 611 out.write('%s\t%s:%d\n' % (line, path, line_number)) |
612 continue | 612 continue |
613 | 613 |
614 out.write('%s\n' % line) | 614 out.write('%s\n' % line) |
615 | 615 |
616 print('%d symbols in the results.' % len(address_symbol)) | 616 print('%d symbols in the results.' % len(address_symbol)) |
617 | 617 |
618 | 618 |
619 def RunNm(binary, nm_binary): | 619 def RunNm(binary, nm_binary): |
620 print('Starting nm') | |
621 cmd = [nm_binary, '-C', '--print-size', '--size-sort', '--reverse-sort', | 620 cmd = [nm_binary, '-C', '--print-size', '--size-sort', '--reverse-sort', |
622 binary] | 621 binary] |
623 nm_process = subprocess.Popen(cmd, | 622 nm_process = subprocess.Popen(cmd, |
624 stdout=subprocess.PIPE, | 623 stdout=subprocess.PIPE, |
625 stderr=subprocess.PIPE) | 624 stderr=subprocess.PIPE) |
626 (process_output, err_output) = nm_process.communicate() | 625 (process_output, err_output) = nm_process.communicate() |
627 | 626 |
628 if nm_process.returncode != 0: | 627 if nm_process.returncode != 0: |
629 if err_output: | 628 if err_output: |
630 raise Exception, err_output | 629 raise Exception, err_output |
631 else: | 630 else: |
632 raise Exception, process_output | 631 raise Exception, process_output |
633 | 632 |
634 print('Finished nm') | |
635 return process_output | 633 return process_output |
636 | 634 |
637 | 635 |
638 def GetNmSymbols(nm_infile, outfile, library, jobs, verbose, | 636 def GetNmSymbols(nm_infile, outfile, library, jobs, verbose, |
639 addr2line_binary, nm_binary, disambiguate, src_path): | 637 addr2line_binary, nm_binary, disambiguate, src_path): |
640 if nm_infile is None: | 638 if nm_infile is None: |
641 if outfile is None: | 639 if outfile is None: |
642 outfile = tempfile.NamedTemporaryFile(delete=False).name | 640 outfile = tempfile.NamedTemporaryFile(delete=False).name |
643 | 641 |
644 if verbose: | 642 if verbose: |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 shutil.copy(os.path.join(d3_src, 'LICENSE'), d3_out) | 845 shutil.copy(os.path.join(d3_src, 'LICENSE'), d3_out) |
848 shutil.copy(os.path.join(d3_src, 'd3.js'), d3_out) | 846 shutil.copy(os.path.join(d3_src, 'd3.js'), d3_out) |
849 shutil.copy(os.path.join(template_src, 'index.html'), opts.destdir) | 847 shutil.copy(os.path.join(template_src, 'index.html'), opts.destdir) |
850 shutil.copy(os.path.join(template_src, 'D3SymbolTreeMap.js'), opts.destdir) | 848 shutil.copy(os.path.join(template_src, 'D3SymbolTreeMap.js'), opts.destdir) |
851 | 849 |
852 print 'Report saved to ' + opts.destdir + '/index.html' | 850 print 'Report saved to ' + opts.destdir + '/index.html' |
853 | 851 |
854 | 852 |
855 if __name__ == '__main__': | 853 if __name__ == '__main__': |
856 sys.exit(main()) | 854 sys.exit(main()) |
OLD | NEW |