Chromium Code Reviews| Index: tools/binary_size/run_binary_size_analysis.py |
| diff --git a/tools/binary_size/run_binary_size_analysis.py b/tools/binary_size/run_binary_size_analysis.py |
| index f06884f8dafe1f7ba54c8586d18882c0e0ec5227..2a93681cf7c66c37525e0d78711755e64eb4f059 100755 |
| --- a/tools/binary_size/run_binary_size_analysis.py |
| +++ b/tools/binary_size/run_binary_size_analysis.py |
| @@ -482,9 +482,12 @@ class Progress(): |
| self.collisions = 0 |
| self.time_last_output = time.time() |
| self.count_last_output = 0 |
| + self.disambiguations = 0 |
| + self.was_ambiguous = 0 |
| -def RunElfSymbolizer(outfile, library, addr2line_binary, nm_binary, jobs): |
| +def RunElfSymbolizer(outfile, library, addr2line_binary, nm_binary, jobs, |
| + disambiguate, src_path): |
| nm_output = RunNm(library, nm_binary) |
| nm_output_lines = nm_output.splitlines() |
| nm_output_lines_len = len(nm_output_lines) |
| @@ -497,6 +500,11 @@ def RunElfSymbolizer(outfile, library, addr2line_binary, nm_binary, jobs): |
| # str(address_symbol[addr].name)) |
| progress.collisions += 1 |
| else: |
| + if symbol.disambiguated: |
| + progress.disambiguations += 1 |
| + if symbol.was_ambiguous: |
| + progress.was_ambiguous += 1 |
| + |
| address_symbol[addr] = symbol |
| progress_chunk = 100 |
| @@ -514,12 +522,25 @@ def RunElfSymbolizer(outfile, library, addr2line_binary, nm_binary, jobs): |
| speed = 0 |
| progress_percent = (100.0 * (progress.count + progress.skip_count) / |
| nm_output_lines_len) |
| - print('%.1f%%: Looked up %d symbols (%d collisions) - %.1f lookups/s.' % |
| - (progress_percent, progress.count, progress.collisions, speed)) |
| - |
| + disambiguation_percent = 0 |
| + if progress.disambiguations != 0: |
| + disambiguation_percent = (100.0 * progress.disambiguations / |
| + progress.was_ambiguous) |
| + |
| + sys.stdout.write('\r%.1f%%: Looked up %d symbols (%d collisions, ' |
| + '%d disambiguations where %.1f%% succeeded)' |
| + '- %.1f lookups/s.' % |
| + (progress_percent, progress.count, progress.collisions, |
| + progress.disambiguations, disambiguation_percent, speed)) |
| + |
| + # In case disambiguation was disabled, we remove the source path (which upon |
| + # being set signals the symbolizer to enable disambiguation) |
| + if not disambiguate: |
| + src_path = None |
| symbolizer = elf_symbolizer.ELFSymbolizer(library, addr2line_binary, |
| map_address_symbol, |
| - max_concurrent_jobs=jobs) |
| + max_concurrent_jobs=jobs, |
| + source_root_path=src_path) |
| user_interrupted = False |
| try: |
| for line in nm_output_lines: |
| @@ -552,6 +573,8 @@ def RunElfSymbolizer(outfile, library, addr2line_binary, nm_binary, jobs): |
| user_interrupted = True |
| print('Patience you must have my young padawan.') |
| + print '' |
| + |
| if user_interrupted: |
| print('Skipping the rest of the file mapping. ' |
| 'Output will not be fully classified.') |
| @@ -599,14 +622,15 @@ def RunNm(binary, nm_binary): |
| def GetNmSymbols(nm_infile, outfile, library, jobs, verbose, |
| - addr2line_binary, nm_binary): |
| + addr2line_binary, nm_binary, disambiguate, src_path): |
| if nm_infile is None: |
| if outfile is None: |
| outfile = tempfile.NamedTemporaryFile(delete=False).name |
| if verbose: |
| print 'Running parallel addr2line, dumping symbols to ' + outfile |
| - RunElfSymbolizer(outfile, library, addr2line_binary, nm_binary, jobs) |
| + RunElfSymbolizer(outfile, library, addr2line_binary, nm_binary, jobs, |
| + disambiguate, src_path) |
| nm_infile = outfile |
| @@ -716,6 +740,15 @@ def main(): |
| 'This argument is only valid when using --library.') |
| parser.add_option('--legacy', action='store_true', |
| help='emit legacy binary size report instead of modern') |
| + parser.add_option('--disable-disambiguation', action='store_true', |
| + help='disables the disambiguation process altogether,' |
| + ' NOTE: this will produce output with some symbols at the' |
|
Andrew Hayden (chromium.org)
2014/06/26 09:00:11
"will" -> "may, depending upon your toolchain,"
|
| + ' top layer due to the fact that addr2line could not get' |
|
Andrew Hayden (chromium.org)
2014/06/26 09:00:11
"due to the fact that" -> "if"
|
| + ' the entire source path.') |
| + parser.add_option('--source-path', default='./', |
| + help='the path to the source code of the output binary, ' |
| + 'default set to current directory. Used in the' |
| + ' disambiguation process.') |
| opts, _args = parser.parse_args() |
| if ((not opts.library) and (not opts.nm_in)) or (opts.library and opts.nm_in): |
| @@ -756,7 +789,9 @@ def main(): |
| symbols = GetNmSymbols(opts.nm_in, opts.nm_out, opts.library, |
| opts.jobs, opts.verbose is True, |
| - addr2line_binary, nm_binary) |
| + addr2line_binary, nm_binary, |
| + opts.disable_disambiguation is None, |
| + opts.source_path) |
| if not os.path.exists(opts.destdir): |
| os.makedirs(opts.destdir, 0755) |