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

Side by Side Diff: tools/linux/dump-static-initializers.py

Issue 9347013: Adds '#'s to the beginning of each output line when running with -d (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
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 """Dump functions called by static intializers in a Linux Release binary. 6 """Dump functions called by static intializers in a Linux Release binary.
7 7
8 Usage example: 8 Usage example:
9 tools/linux/dump-static-intializers.py out/Release/chrome 9 tools/linux/dump-static-intializers.py out/Release/chrome
10 10
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 continue 140 continue
141 refs.add(ref) 141 refs.add(ref)
142 142
143 return sorted(refs) 143 return sorted(refs)
144 144
145 def main(): 145 def main():
146 parser = optparse.OptionParser(usage='%prog [option] filename') 146 parser = optparse.OptionParser(usage='%prog [option] filename')
147 parser.add_option('-d', '--diffable', dest='diffable', 147 parser.add_option('-d', '--diffable', dest='diffable',
148 action='store_true', default=False, 148 action='store_true', default=False,
149 help='Prints the filename on each line, for more easily ' 149 help='Prints the filename on each line, for more easily '
150 'diff-able output.') 150 'diff-able output. (Used by sizes.py)')
151 opts, args = parser.parse_args() 151 opts, args = parser.parse_args()
152 if len(args) != 1: 152 if len(args) != 1:
153 parser.error('missing filename argument') 153 parser.error('missing filename argument')
154 return 1 154 return 1
155 binary = args[0] 155 binary = args[0]
156 156
157 demangler = Demangler() 157 demangler = Demangler()
158 file_count = 0 158 file_count = 0
159 initializer_count = 0 159 initializer_count = 0
160 160
(...skipping 15 matching lines...) Expand all
176 176
177 ref = demangler.Demangle(ref) 177 ref = demangler.Demangle(ref)
178 if qualified_filename == filename: 178 if qualified_filename == filename:
179 qualified_filename = QualifyFilename(filename, ref) 179 qualified_filename = QualifyFilename(filename, ref)
180 if ref in NOTES: 180 if ref in NOTES:
181 ref_output.append(' %s [%s]' % (ref, NOTES[ref])) 181 ref_output.append(' %s [%s]' % (ref, NOTES[ref]))
182 else: 182 else:
183 ref_output.append(' ' + ref) 183 ref_output.append(' ' + ref)
184 184
185 if opts.diffable: 185 if opts.diffable:
186 print '\n'.join(qualified_filename + r for r in ref_output) 186 print '\n'.join('# ' + qualified_filename + r for r in ref_output)
187 else: 187 else:
188 print '%s (initializer offset 0x%x size 0x%x)' % (qualified_filename, 188 print '%s (initializer offset 0x%x size 0x%x)' % (qualified_filename,
189 addr, size) 189 addr, size)
190 print '\n'.join(ref_output) + '\n' 190 print '\n'.join(ref_output) + '\n'
191 191
Nico 2012/02/07 05:53:19 Just if opts.diffable: print '#', print '
192 print 'Found %d static initializers in %d files.' % (initializer_count, 192 last_line = 'Found %d static initializers in %d files.' % (initializer_count,
193 file_count) 193 file_count)
194 if opts.diffable:
195 print '# ' + last_line
196 else:
197 print last_line
194 198
195 return 0 199 return 0
196 200
197 if '__main__' == __name__: 201 if '__main__' == __name__:
198 sys.exit(main()) 202 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