| 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..404bf75aa2bfc4eded6810d039d70abc580d29ef 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.failed_disambiguations = 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.failed_disambiguation:
|
| + progress.failed_disambiguations += 1
|
| +
|
| address_symbol[addr] = symbol
|
|
|
| progress_chunk = 100
|
| @@ -514,12 +522,21 @@ 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.disambiguations + progress.failed_disambiguations))
|
| + 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))
|
|
|
| symbolizer = elf_symbolizer.ELFSymbolizer(library, addr2line_binary,
|
| map_address_symbol,
|
| - max_concurrent_jobs=jobs)
|
| + max_concurrent_jobs=jobs,
|
| + disambiguate=disambiguate,
|
| + disambiguation_source_path=src_path)
|
| user_interrupted = False
|
| try:
|
| for line in nm_output_lines:
|
| @@ -552,6 +569,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 +618,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 +736,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'
|
| + ' top layer due to the fact that addr2line could not get'
|
| + ' 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 +785,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,
|
| + not opts.disable_disambiguation,
|
| + opts.source_path)
|
| if not os.path.exists(opts.destdir):
|
| os.makedirs(opts.destdir, 0755)
|
|
|
|
|