Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(467)

Side by Side Diff: tools/binary_size/libsupersize/archive.py

Issue 2866103003: supersize: Fix --tool-prefix autodetection (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/binary_size/libsupersize/console.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2017 The Chromium Authors. All rights reserved. 1 # Copyright 2017 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Main Python API for analyzing binary size.""" 5 """Main Python API for analyzing binary size."""
6 6
7 import argparse 7 import argparse
8 import calendar 8 import calendar
9 import collections 9 import collections
10 import datetime 10 import datetime
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 if s.size_without_padding == 0: 316 if s.size_without_padding == 0:
317 continue 317 continue
318 name_list = aliases_by_address.get(s.address) 318 name_list = aliases_by_address.get(s.address)
319 if name_list: 319 if name_list:
320 if s.name not in name_list: 320 if s.name not in name_list:
321 logging.warning('Name missing from aliases: %s %s', s.name, name_list) 321 logging.warning('Name missing from aliases: %s %s', s.name, name_list)
322 continue 322 continue
323 replacements.append((i, name_list)) 323 replacements.append((i, name_list))
324 num_new_symbols += len(name_list) - 1 324 num_new_symbols += len(name_list) - 1
325 325
326 if float(num_new_symbols) / len(raw_symbols) < .1:
327 logging.warning('Number of aliases is oddly low (%.0f%%). It should '
328 'usually be around 25%%. Ensure --tool-prefix is correct.',
329 float(num_new_symbols) / len(raw_symbols) * 100)
330
326 # Step 2: Create new symbols as siblings to each existing one. 331 # Step 2: Create new symbols as siblings to each existing one.
327 logging.debug('Creating %d aliases', num_new_symbols) 332 logging.debug('Creating %d aliases', num_new_symbols)
328 src_cursor_end = len(raw_symbols) 333 src_cursor_end = len(raw_symbols)
329 raw_symbols += [None] * num_new_symbols 334 raw_symbols += [None] * num_new_symbols
330 dst_cursor_end = len(raw_symbols) 335 dst_cursor_end = len(raw_symbols)
331 for src_index, name_list in reversed(replacements): 336 for src_index, name_list in reversed(replacements):
332 # Copy over symbols that come after the current one. 337 # Copy over symbols that come after the current one.
333 chunk_size = src_cursor_end - src_index - 1 338 chunk_size = src_cursor_end - src_index - 1
334 dst_cursor_end -= chunk_size 339 dst_cursor_end -= chunk_size
335 src_cursor_end -= chunk_size 340 src_cursor_end -= chunk_size
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 parser.add_argument('--elf-file', 599 parser.add_argument('--elf-file',
595 help='Path to input ELF file. Currently used for ' 600 help='Path to input ELF file. Currently used for '
596 'capturing metadata.') 601 'capturing metadata.')
597 parser.add_argument('--map-file', 602 parser.add_argument('--map-file',
598 help='Path to input .map(.gz) file. Defaults to ' 603 help='Path to input .map(.gz) file. Defaults to '
599 '{{elf_file}}.map(.gz)?. If given without ' 604 '{{elf_file}}.map(.gz)?. If given without '
600 '--elf-file, no size metadata will be recorded.') 605 '--elf-file, no size metadata will be recorded.')
601 parser.add_argument('--no-source-paths', action='store_true', 606 parser.add_argument('--no-source-paths', action='store_true',
602 help='Do not use .ninja files to map ' 607 help='Do not use .ninja files to map '
603 'object_path -> source_path') 608 'object_path -> source_path')
604 parser.add_argument('--tool-prefix', default='', 609 parser.add_argument('--tool-prefix',
605 help='Path prefix for c++filt.') 610 help='Path prefix for c++filt, nm, readelf.')
606 parser.add_argument('--output-directory', 611 parser.add_argument('--output-directory',
607 help='Path to the root build directory.') 612 help='Path to the root build directory.')
608 613
609 614
610 def Run(args, parser): 615 def Run(args, parser):
611 if not args.size_file.endswith('.size'): 616 if not args.size_file.endswith('.size'):
612 parser.error('size_file must end with .size') 617 parser.error('size_file must end with .size')
613 618
614 elf_path = args.elf_file 619 elf_path = args.elf_file
615 map_path = args.map_file 620 map_path = args.map_file
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 logging.warning('Packed section not present: %s', packed_section_name) 690 logging.warning('Packed section not present: %s', packed_section_name)
686 else: 691 else:
687 size_info.section_sizes['%s (unpacked)' % packed_section_name] = ( 692 size_info.section_sizes['%s (unpacked)' % packed_section_name] = (
688 unstripped_section_sizes.get(packed_section_name)) 693 unstripped_section_sizes.get(packed_section_name))
689 694
690 logging.info('Recording metadata: \n %s', 695 logging.info('Recording metadata: \n %s',
691 '\n '.join(describe.DescribeMetadata(size_info.metadata))) 696 '\n '.join(describe.DescribeMetadata(size_info.metadata)))
692 logging.info('Saving result to %s', args.size_file) 697 logging.info('Saving result to %s', args.size_file)
693 file_format.SaveSizeInfo(size_info, args.size_file) 698 file_format.SaveSizeInfo(size_info, args.size_file)
694 logging.info('Done') 699 logging.info('Done')
OLDNEW
« no previous file with comments | « no previous file | tools/binary_size/libsupersize/console.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698