diff options
author | bratell@opera.com <bratell@opera.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-05 09:37:18 +0000 |
---|---|---|
committer | bratell@opera.com <bratell@opera.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-05 09:37:18 +0000 |
commit | c6ebb7b35c6a8ea0cefe19741eddf1a68ef4cba6 (patch) | |
tree | 66593497d604e9d72c950f8d0d738e329e828f8e /tools/binary_size | |
parent | 06aa5abcbd80db49136437ae46cb356cea5547ef (diff) | |
download | chromium_src-c6ebb7b35c6a8ea0cefe19741eddf1a68ef4cba6.zip chromium_src-c6ebb7b35c6a8ea0cefe19741eddf1a68ef4cba6.tar.gz chromium_src-c6ebb7b35c6a8ea0cefe19741eddf1a68ef4cba6.tar.bz2 |
Emit partial results if binary_size is interrupted.
Instead of just throwing away everything if the user presses
Ctrl-c, write down whatever data we have to the disk. By asking for
the largest symbols first, it's sometimes possible to get a quite
good picture after only 10-15% of the total runtime.
BUG=377466
Review URL: https://codereview.chromium.org/305503002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275053 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/binary_size')
-rwxr-xr-x | tools/binary_size/run_binary_size_analysis.py | 77 |
1 files changed, 46 insertions, 31 deletions
diff --git a/tools/binary_size/run_binary_size_analysis.py b/tools/binary_size/run_binary_size_analysis.py index aa46f6f..4168874 100755 --- a/tools/binary_size/run_binary_size_analysis.py +++ b/tools/binary_size/run_binary_size_analysis.py @@ -455,26 +455,41 @@ def RunElfSymbolizer(outfile, library, addr2line_binary, nm_binary, jobs): symbolizer = elf_symbolizer.ELFSymbolizer(library, addr2line_binary, map_address_symbol, max_concurrent_jobs=jobs) - for line in nm_output_lines: - match = sNmPattern.match(line) - if match: - location = match.group(5) - if not location: - addr = int(match.group(1), 16) - size = int(match.group(2), 16) - if addr in address_symbol: # Already looked up, shortcut ELFSymbolizer. - map_address_symbol(address_symbol[addr], addr) - continue - elif size == 0: - # Save time by not looking up empty symbols (do they even exist?) - print('Empty symbol: ' + line) - else: - symbolizer.SymbolizeAsync(addr, addr) - continue + user_interrupted = False + try: + for line in nm_output_lines: + match = sNmPattern.match(line) + if match: + location = match.group(5) + if not location: + addr = int(match.group(1), 16) + size = int(match.group(2), 16) + if addr in address_symbol: # Already looked up, shortcut + # ELFSymbolizer. + map_address_symbol(address_symbol[addr], addr) + continue + elif size == 0: + # Save time by not looking up empty symbols (do they even exist?) + print('Empty symbol: ' + line) + else: + symbolizer.SymbolizeAsync(addr, addr) + continue + + progress.skip_count += 1 + except KeyboardInterrupt: + user_interrupted = True + print('Interrupting - killing subprocesses. Please wait.') - progress.skip_count += 1 + try: + symbolizer.Join() + except KeyboardInterrupt: + # Don't want to abort here since we will be finished in a few seconds. + user_interrupted = True + print('Patience you must have my young padawan.') - symbolizer.Join() + if user_interrupted: + print('Skipping the rest of the file mapping. ' + 'Output will not be fully classified.') with open(outfile, 'w') as out: for line in nm_output_lines: @@ -483,15 +498,16 @@ def RunElfSymbolizer(outfile, library, addr2line_binary, nm_binary, jobs): location = match.group(5) if not location: addr = int(match.group(1), 16) - symbol = address_symbol[addr] - path = '??' - if symbol.source_path is not None: - path = symbol.source_path - line_number = 0 - if symbol.source_line is not None: - line_number = symbol.source_line - out.write('%s\t%s:%d\n' % (line, path, line_number)) - continue + symbol = address_symbol.get(addr) + if symbol is not None: + path = '??' + if symbol.source_path is not None: + path = symbol.source_path + line_number = 0 + if symbol.source_line is not None: + line_number = symbol.source_line + out.write('%s\t%s:%d\n' % (line, path, line_number)) + continue out.write('%s\n' % line) @@ -500,7 +516,8 @@ def RunElfSymbolizer(outfile, library, addr2line_binary, nm_binary, jobs): def RunNm(binary, nm_binary): print('Starting nm') - cmd = [nm_binary, '-C', '--print-size', binary] + cmd = [nm_binary, '-C', '--print-size', '--size-sort', '--reverse-sort', + binary] nm_process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -678,12 +695,10 @@ def main(): 'template') shutil.copy(os.path.join(d3_src, 'LICENSE'), d3_out) shutil.copy(os.path.join(d3_src, 'd3.js'), d3_out) - print('Copying index.html') shutil.copy(os.path.join(template_src, 'index.html'), opts.destdir) shutil.copy(os.path.join(template_src, 'D3SymbolTreeMap.js'), opts.destdir) - if opts.verbose: - print 'Report saved to ' + opts.destdir + '/index.html' + print 'Report saved to ' + opts.destdir + '/index.html' if __name__ == '__main__': |