Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: build/scripts/slave/chromium/sizes.py

Issue 9323047: Update sizes.py to print a list of all static initializers (Closed) Base URL: http://src.chromium.org/svn/trunk/tools/
Patch Set: '' Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """A tool to extract size information for chrome, executed by buildbot. 6 """A tool to extract size information for chrome, executed by buildbot.
7 7
8 When this is run, the current directory (cwd) should be the outer build 8 When this is run, the current directory (cwd) should be the outer build
9 directory (e.g., chrome-release/build/). 9 directory (e.g., chrome-release/build/).
10 10
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 get_size(binary_file), 'bytes')) 158 get_size(binary_file), 'bytes'))
159 159
160 result, stdout = run_process(result, ['size', binary_file]) 160 result, stdout = run_process(result, ['size', binary_file])
161 text, data, bss = re.search('(\d+)\s+(\d+)\s+(\d+)', stdout).groups() 161 text, data, bss = re.search('(\d+)\s+(\d+)\s+(\d+)', stdout).groups()
162 sizes += [ 162 sizes += [
163 (binary_name + '-text', 'text', '', text, 'bytes'), 163 (binary_name + '-text', 'text', '', text, 'bytes'),
164 (binary_name + '-data', 'data', '', data, 'bytes'), 164 (binary_name + '-data', 'data', '', data, 'bytes'),
165 (binary_name + '-bss', 'bss', '', bss, 'bytes'), 165 (binary_name + '-bss', 'bss', '', bss, 'bytes'),
166 ] 166 ]
167 167
168 # Find the number of files with at least one static initializer. 168 # For Release builds only, use dump-static-initializers.py to get the number
169 # First determine if we're 32 or 64 bit 169 # of static initializers.
170 result, stdout = run_process(result, ['readelf', '-h', binary_file]) 170 if 'Release' in target_dir:
Lei Zhang 2012/02/03 22:54:57 Otherwise, maybe os.path.basename(target_dir) is m
Tyler Breisacher (Chromium) 2012/02/04 03:03:19 You're right, that's probably cleaner.
171 elf_class_line = re.search('Class:.*$', stdout, re.MULTILINE).group(0) 171 dump_static_initializers = os.path.join(os.path.dirname(target_dir),
Lei Zhang 2012/02/03 22:54:57 If |target_dir| is /path/to/src/out/Release, don't
Tyler Breisacher (Chromium) 2012/02/04 03:03:19 I think you're right.
172 elf_class = re.split('\W+', elf_class_line)[1] 172 '..', 'tools', 'linux',
173 if elf_class == 'ELF32': 173 'dump-static-initializers.py')
174 word_size = 4 174 result, stdout = run_process(result, [dump_static_initializers,
175 else: 175 '-d', binary_file])
176 word_size = 8 176 count = re.search('Found (\d+) static initializers',
177 177 stdout).group(1)
178 # Then find the size of the .ctors section. 178 if count is not '0':
179 result, stdout = run_process(result, ['readelf', '-SW', binary_file]) 179 print '\nStatic initializers in %s:' % binary_file
180 size_match = re.search('.ctors.*$', stdout, re.MULTILINE) 180 print stdout
181 if size_match is None: 181 sizes.append(
182 count = 0 182 (binary_name + '-si', 'initializers', '', count, 'initializers'))
183 else:
184 size_line = re.search('.ctors.*$', stdout, re.MULTILINE).group(0)
185 size = re.split('\W+', size_line)[5]
186 size = int(size, 16)
187 # The first entry is always 0 and the last is -1 as guards.
188 # So subtract 2 from the count.
189 count = (size / word_size) - 2
190 sizes.append((binary_name + '-si', 'initializers', '', count, 'files'))
191 183
192 # Determine if the binary has the DT_TEXTREL marker. 184 # Determine if the binary has the DT_TEXTREL marker.
193 result, stdout = run_process(result, ['readelf', '-Wd', binary_file]) 185 result, stdout = run_process(result, ['readelf', '-Wd', binary_file])
194 if re.search(r'\bTEXTREL\b', stdout) is None: 186 if re.search(r'\bTEXTREL\b', stdout) is None:
195 # Nope, so the count is zero. 187 # Nope, so the count is zero.
196 count = 0 188 count = 0
197 else: 189 else:
198 # There are some, so count them. 190 # There are some, so count them.
199 result, stdout = run_process(result, ['eu-findtextrel', binary_file]) 191 result, stdout = run_process(result, ['eu-findtextrel', binary_file])
200 count = stdout.count('\n') 192 count = stdout.count('\n')
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 else: 320 else:
329 sys.stderr.write('Unknown platform %s.\n' % repr(options.platform)) 321 sys.stderr.write('Unknown platform %s.\n' % repr(options.platform))
330 msg = 'Use the --platform= option to specify a supported platform:\n' 322 msg = 'Use the --platform= option to specify a supported platform:\n'
331 sys.stderr.write(msg + ' ' + ' '.join(platforms) + '\n') 323 sys.stderr.write(msg + ' ' + ' '.join(platforms) + '\n')
332 return 2 324 return 2
333 return real_main(options, args) 325 return real_main(options, args)
334 326
335 327
336 if '__main__' == __name__: 328 if '__main__' == __name__:
337 sys.exit(main()) 329 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698