summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandrewhayden <andrewhayden@chromium.org>2015-05-28 04:40:35 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-28 11:41:03 +0000
commit221a2af62da867eff6e696c46f88e616b0a94507 (patch)
treeb8cb40f24600aed675384ffa0cb76e36165e38fc
parentbbebd6a43deab3e4e99f6ab559f0e37345d9619a (diff)
downloadchromium_src-221a2af62da867eff6e696c46f88e616b0a94507.zip
chromium_src-221a2af62da867eff6e696c46f88e616b0a94507.tar.gz
chromium_src-221a2af62da867eff6e696c46f88e616b0a94507.tar.bz2
Make the Binary Size Tool output nm.out by default and check output directories.
BUG=466604,491163 NOTRY=true Review URL: https://codereview.chromium.org/1003893002 Cr-Commit-Position: refs/heads/master@{#331765}
-rw-r--r--tools/binary_size/README.txt7
-rwxr-xr-xtools/binary_size/run_binary_size_analysis.py62
2 files changed, 40 insertions, 29 deletions
diff --git a/tools/binary_size/README.txt b/tools/binary_size/README.txt
index f2866b7..8886f698 100644
--- a/tools/binary_size/README.txt
+++ b/tools/binary_size/README.txt
@@ -75,11 +75,10 @@ pretend that you are building the Content Shell APK for Android.
This command will run the analysis on the Content Shell native library for
Android, producing an HTML report in /tmp/report and saving the NM output
(useful for re-running the tool or analyzing deltas between two builds)
- under /tmp/nm.out:
+ under /tmp/report/nm.out:
tools/binary_size/run_binary_size_analysis.py \
--library out/Release/lib/libcontent_shell_content_view.so \
- --destdir /tmp/report \
- --nm-out /tmp/nm.out
+ --destdir /tmp/report
Of course, there are additional options that you can see by running the tool
with "--help".
@@ -105,7 +104,7 @@ report may be saved and viewed offline with no problems.
--------------------------------------------------------------------------------
How to Run: explain_binary_size_delta.py
--------------------------------------------------------------------------------
-Continuing the example, assume that explain_binary_size_delta.py has been run
+Continuing the example, assume that run_binary_size_analysis.py has been run
both before and after a code change and that the "nm.out" files have been saved
to "nm.out.before" and "nm.out.after". To generate an explanation of the symbol
differences between the two runs:
diff --git a/tools/binary_size/run_binary_size_analysis.py b/tools/binary_size/run_binary_size_analysis.py
index f9000d3..6bd111b 100755
--- a/tools/binary_size/run_binary_size_analysis.py
+++ b/tools/binary_size/run_binary_size_analysis.py
@@ -566,15 +566,18 @@ def main():
'and ramp this number up until your machine begins to '
'struggle with RAM. '
'This argument is only valid when using --library.')
- parser.add_option('-v', dest='verbose', action='store_true',
+ parser.add_option('-v', '--verbose', dest='verbose', action='store_true',
help='be verbose, printing lots of status information.')
parser.add_option('--nm-out', metavar='PATH',
- help='keep the nm output file, and store it at the '
- 'specified path. This is useful if you want to see the '
- 'fully processed nm output after the symbols have been '
- 'mapped to source locations. By default, a tempfile is '
- 'used and is deleted when the program terminates.'
- 'This argument is only valid when using --library.')
+ help='(deprecated) No-op. nm.out is stored in --destdir.')
+ parser.add_option('--no-nm-out', action='store_true',
+ help='do not keep the nm output file. This file is useful '
+ 'if you want to see the fully processed nm output after '
+ 'the symbols have been mapped to source locations, or if '
+ 'you plan to run explain_binary_size_delta.py. By default '
+ 'the file \'nm.out\' is placed alongside the generated '
+ 'report. The nm.out file is only created when using '
+ '--library.')
parser.add_option('--disable-disambiguation', action='store_true',
help='disables the disambiguation process altogether,'
' NOTE: this may, depending on your toolchain, produce'
@@ -588,12 +591,14 @@ def main():
if ((not opts.library) and (not opts.nm_in)) or (opts.library and opts.nm_in):
parser.error('exactly one of --library or --nm-in is required')
+ if opts.nm_out:
+ print >> sys.stderr, ('WARNING: --nm-out is deprecated and has no effect.')
if (opts.nm_in):
if opts.jobs:
print >> sys.stderr, ('WARNING: --jobs has no effect '
'when used with --nm-in')
if not opts.destdir:
- parser.error('--destdir is required argument')
+ parser.error('--destdir is a required argument')
if not opts.jobs:
# Use the number of processors but cap between 2 and 4 since raw
# CPU power isn't the limiting factor. It's I/O limited, memory
@@ -626,26 +631,17 @@ def main():
if opts.library:
CheckDebugFormatSupport(opts.library, addr2line_binary)
- symbols = GetNmSymbols(opts.nm_in, opts.nm_out, opts.library,
- opts.jobs, opts.verbose is True,
- addr2line_binary, nm_binary,
- opts.disable_disambiguation is None,
- opts.source_path)
-
- if opts.pak:
- AddPakData(symbols, opts.pak)
-
+ # Prepare output directory and report guts
if not os.path.exists(opts.destdir):
os.makedirs(opts.destdir, 0755)
+ nm_out = os.path.join(opts.destdir, 'nm.out')
+ if opts.no_nm_out:
+ nm_out = None
-
- if opts.library:
- symbol_path_origin_dir = os.path.dirname(os.path.abspath(opts.library))
- else:
- # Just a guess. Hopefully all paths in the input file are absolute.
- symbol_path_origin_dir = os.path.abspath(os.getcwd())
+ # Copy report boilerplate into output directory. This also proves that the
+ # output directory is safe for writing, so there should be no problems writing
+ # the nm.out file later.
data_js_file_name = os.path.join(opts.destdir, 'data.js')
- DumpCompactTree(symbols, symbol_path_origin_dir, data_js_file_name)
d3_out = os.path.join(opts.destdir, 'd3')
if not os.path.exists(d3_out):
os.makedirs(d3_out, 0755)
@@ -660,8 +656,24 @@ def main():
shutil.copy(os.path.join(template_src, 'index.html'), opts.destdir)
shutil.copy(os.path.join(template_src, 'D3SymbolTreeMap.js'), opts.destdir)
- print 'Report saved to ' + opts.destdir + '/index.html'
+ # Run nm and/or addr2line to gather the data
+ symbols = GetNmSymbols(opts.nm_in, nm_out, opts.library,
+ opts.jobs, opts.verbose is True,
+ addr2line_binary, nm_binary,
+ opts.disable_disambiguation is None,
+ opts.source_path)
+ # Post-processing
+ if opts.pak:
+ AddPakData(symbols, opts.pak)
+ if opts.library:
+ symbol_path_origin_dir = os.path.dirname(os.path.abspath(opts.library))
+ else:
+ # Just a guess. Hopefully all paths in the input file are absolute.
+ symbol_path_origin_dir = os.path.abspath(os.getcwd())
+ # Dump JSON for the HTML report.
+ DumpCompactTree(symbols, symbol_path_origin_dir, data_js_file_name)
+ print 'Report saved to ' + opts.destdir + '/index.html'
if __name__ == '__main__':
sys.exit(main())