Index: build/scripts/slave/chromium/sizes.py |
=================================================================== |
--- build/scripts/slave/chromium/sizes.py (revision 120366) |
+++ build/scripts/slave/chromium/sizes.py (working copy) |
@@ -125,7 +125,7 @@ |
return 66 |
-def check_linux_binary(target_dir, binary_name): |
+def check_linux_binary(target_dir, binary_name, options): |
"""Collect appropriate size information about the built Linux binary given. |
Returns a tuple (result, sizes). result is the first non-zero exit |
@@ -165,30 +165,22 @@ |
(binary_name + '-bss', 'bss', '', bss, 'bytes'), |
] |
- # Find the number of files with at least one static initializer. |
- # First determine if we're 32 or 64 bit |
- result, stdout = run_process(result, ['readelf', '-h', binary_file]) |
- elf_class_line = re.search('Class:.*$', stdout, re.MULTILINE).group(0) |
- elf_class = re.split('\W+', elf_class_line)[1] |
- if elf_class == 'ELF32': |
- word_size = 4 |
- else: |
- word_size = 8 |
+ # For Release builds only, use dump-static-initializers.py to get the number |
+ # of static initializers. |
+ if options.target == 'Release': |
+ dump_static_initializers = os.path.join(os.path.dirname(target_dir), |
Lei Zhang
2012/02/04 03:10:00
So how about os.path.join(options.build_dir, 'tool
|
+ '..', '..', 'tools', 'linux', |
+ 'dump-static-initializers.py') |
+ result, stdout = run_process(result, [dump_static_initializers, |
+ '-d', binary_file]) |
+ count = re.search('Found (\d+) static initializers', |
+ stdout).group(1) |
+ if count is not '0': |
+ print '\nStatic initializers in %s:' % binary_file |
+ print stdout |
+ sizes.append( |
+ (binary_name + '-si', 'initializers', '', count, 'initializers')) |
- # Then find the size of the .ctors section. |
- result, stdout = run_process(result, ['readelf', '-SW', binary_file]) |
- size_match = re.search('.ctors.*$', stdout, re.MULTILINE) |
- if size_match is None: |
- count = 0 |
- else: |
- size_line = re.search('.ctors.*$', stdout, re.MULTILINE).group(0) |
- size = re.split('\W+', size_line)[5] |
- size = int(size, 16) |
- # The first entry is always 0 and the last is -1 as guards. |
- # So subtract 2 from the count. |
- count = (size / word_size) - 2 |
- sizes.append((binary_name + '-si', 'initializers', '', count, 'files')) |
- |
# Determine if the binary has the DT_TEXTREL marker. |
result, stdout = run_process(result, ['readelf', '-Wd', binary_file]) |
if re.search(r'\bTEXTREL\b', stdout) is None: |
@@ -227,7 +219,7 @@ |
totals = {} |
for binary in binaries: |
- this_result, this_sizes = check_linux_binary(target_dir, binary) |
+ this_result, this_sizes = check_linux_binary(target_dir, binary, options) |
if result == 0: |
result = this_result |
for name, identifier, totals_id, value, units in this_sizes: |