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

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

Issue 2870743003: supersize: Add symbol.template_name, and strip <>s from symbol.name (Closed)
Patch Set: canned query 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
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 """Methods for converting model objects to human-readable formats.""" 4 """Methods for converting model objects to human-readable formats."""
5 5
6 import datetime 6 import datetime
7 import itertools 7 import itertools
8 import time 8 import time
9 9
10 import models 10 import models
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 address = hex(sym.address) 86 address = hex(sym.address)
87 if self.verbose: 87 if self.verbose:
88 count_part = ' count=%d' % len(sym) if sym.IsGroup() else '' 88 count_part = ' count=%d' % len(sym) if sym.IsGroup() else ''
89 yield '{}@{:<9s} pss={} padding={} size_without_padding={}{}'.format( 89 yield '{}@{:<9s} pss={} padding={} size_without_padding={}{}'.format(
90 sym.section, address, _FormatPss(sym.pss), sym.padding, 90 sym.section, address, _FormatPss(sym.pss), sym.padding,
91 sym.size_without_padding, count_part) 91 sym.size_without_padding, count_part)
92 yield ' source_path={} \tobject_path={}'.format( 92 yield ' source_path={} \tobject_path={}'.format(
93 sym.source_path, sym.object_path) 93 sym.source_path, sym.object_path)
94 if sym.name: 94 if sym.name:
95 yield ' flags={} name={}'.format(sym.FlagsString(), sym.name) 95 yield ' flags={} name={}'.format(sym.FlagsString(), sym.name)
96 if sym.full_name: 96 if sym.full_name is not sym.name:
97 yield ' full_name={}'.format(sym.full_name) 97 yield ' full_name={}'.format(sym.full_name)
98 elif sym.full_name: 98 elif sym.full_name:
99 yield ' flags={} full_name={}'.format( 99 yield ' flags={} full_name={}'.format(
100 sym.FlagsString(), sym.full_name) 100 sym.FlagsString(), sym.full_name)
101 elif single_line: 101 elif single_line:
102 count_part = ' (count=%d)' % len(sym) if sym.IsGroup() else '' 102 count_part = ' (count=%d)' % len(sym) if sym.IsGroup() else ''
103 yield '{}@{:<9s} {:<7} {}{}'.format( 103 yield '{}@{:<9s} {:<7} {}{}'.format(
104 sym.section, address, _FormatPss(sym.pss), sym.name, count_part) 104 sym.section, address, _FormatPss(sym.pss), sym.name, count_part)
105 else: 105 else:
106 yield '{}@{:<9s} {:<7} {}'.format( 106 yield '{}@{:<9s} {:<7} {}'.format(
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 def DescribeSizeInfoCoverage(size_info): 246 def DescribeSizeInfoCoverage(size_info):
247 """Yields lines describing how accurate |size_info| is.""" 247 """Yields lines describing how accurate |size_info| is."""
248 for section in models.SECTION_TO_SECTION_NAME: 248 for section in models.SECTION_TO_SECTION_NAME:
249 if section == 'd': 249 if section == 'd':
250 expected_size = sum(v for k, v in size_info.section_sizes.iteritems() 250 expected_size = sum(v for k, v in size_info.section_sizes.iteritems()
251 if k.startswith('.data')) 251 if k.startswith('.data'))
252 else: 252 else:
253 expected_size = size_info.section_sizes[ 253 expected_size = size_info.section_sizes[
254 models.SECTION_TO_SECTION_NAME[section]] 254 models.SECTION_TO_SECTION_NAME[section]]
255 255
256 256 # Use raw_symbols in case symbols contains groups.
257 in_section = size_info.symbols.WhereInSection(section) 257 in_section = models.SymbolGroup(size_info.raw_symbols).WhereInSection(
258 section)
258 actual_size = in_section.size 259 actual_size = in_section.size
259 size_percent = float(actual_size) / expected_size 260 size_percent = float(actual_size) / expected_size
260 yield ('Section {}: has {:.1%} of {} bytes accounted for from ' 261 yield ('Section {}: has {:.1%} of {} bytes accounted for from '
261 '{} symbols. {} bytes are unaccounted for.').format( 262 '{} symbols. {} bytes are unaccounted for.').format(
262 section, size_percent, actual_size, len(in_section), 263 section, size_percent, actual_size, len(in_section),
263 expected_size - actual_size) 264 expected_size - actual_size)
264 star_syms = in_section.WhereNameMatches(r'^\*') 265 star_syms = in_section.WhereNameMatches(r'^\*')
265 padding = in_section.padding - star_syms.padding 266 padding = in_section.padding - star_syms.padding
266 anonymous_syms = star_syms.Inverted().WhereHasAnyAttribution().Inverted() 267 anonymous_syms = star_syms.Inverted().WhereHasAnyAttribution().Inverted()
267 yield '* Padding accounts for {} bytes ({:.1%})'.format( 268 yield '* Padding accounts for {} bytes ({:.1%})'.format(
268 padding, float(padding) / in_section.size) 269 padding, float(padding) / in_section.size)
269 if len(star_syms): 270 if len(star_syms):
270 yield ('* {} placeholders (symbols that start with **) account for ' 271 yield ('* {} placeholders (symbols that start with **) account for '
271 '{} bytes ({:.1%})').format( 272 '{} bytes ({:.1%})').format(
272 len(star_syms), star_syms.pss, star_syms.pss / in_section.size) 273 len(star_syms), star_syms.size,
274 float(star_syms.size) / in_section.size)
273 if anonymous_syms: 275 if anonymous_syms:
274 yield '* {} anonymous symbols account for {} bytes ({:.1%})'.format( 276 yield '* {} anonymous symbols account for {} bytes ({:.1%})'.format(
275 len(anonymous_syms), int(anonymous_syms.pss), 277 len(anonymous_syms), int(anonymous_syms.pss),
276 star_syms.pss / in_section.size) 278 float(star_syms.size) / in_section.size)
277 279
278 aliased_symbols = in_section.Filter(lambda s: s.aliases) 280 aliased_symbols = in_section.Filter(lambda s: s.aliases)
279 if section == 't': 281 if section == 't':
280 if len(aliased_symbols): 282 if len(aliased_symbols):
281 uniques = sum(1 for s in aliased_symbols.IterUniqueSymbols()) 283 uniques = sum(1 for s in aliased_symbols.IterUniqueSymbols())
282 yield ('* Contains {} aliases, mapped to {} unique addresses ' 284 yield ('* Contains {} aliases, mapped to {} unique addresses '
283 '({} bytes)').format( 285 '({} bytes)').format(
284 len(aliased_symbols), uniques, aliased_symbols.size) 286 len(aliased_symbols), uniques, aliased_symbols.size)
285 else: 287 else:
286 yield '* Contains 0 aliases' 288 yield '* Contains 0 aliases'
(...skipping 29 matching lines...) Expand all
316 318
317 def GenerateLines(obj, verbose=False, recursive=False): 319 def GenerateLines(obj, verbose=False, recursive=False):
318 """Returns an iterable of lines (without \n) that describes |obj|.""" 320 """Returns an iterable of lines (without \n) that describes |obj|."""
319 return Describer(verbose=verbose, recursive=recursive).GenerateLines(obj) 321 return Describer(verbose=verbose, recursive=recursive).GenerateLines(obj)
320 322
321 323
322 def WriteLines(lines, func): 324 def WriteLines(lines, func):
323 for l in lines: 325 for l in lines:
324 func(l) 326 func(l)
325 func('\n') 327 func('\n')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698