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

Side by Side Diff: tools/cygprofile/patch_orderfile.py

Issue 891713002: Script checking that the observed function order matches an orderfile. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Spacing, naming, unused imports. Created 5 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
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 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 """Patch an orderfile. 6 """Patch an orderfile.
7 7
8 Starting with a list of symbols in a binary and an orderfile (ordered list of 8 Starting with a list of symbols in a binary and an orderfile (ordered list of
9 symbols), matches the symbols in the orderfile and augments each symbol with the 9 symbols), matches the symbols in the orderfile and augments each symbol with the
10 symbols residing at the same address (due to having identical code). 10 symbols residing at the same address (due to having identical code).
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 line = _StripPrefix(line) 115 line = _StripPrefix(line)
116 name = _RemoveClone(line) 116 name = _RemoveClone(line)
117 if name == '' or name == '*' or name == '.text': 117 if name == '' or name == '*' or name == '.text':
118 continue 118 continue
119 if not line in unique_symbols: 119 if not line in unique_symbols:
120 symbols.append(line) 120 symbols.append(line)
121 unique_symbols.add(line) 121 unique_symbols.add(line)
122 return symbols 122 return symbols
123 123
124 124
125 def _GetSymbolsFromOrderfile(filename): 125 def GetSymbolsFromOrderfile(filename):
126 """Return the symbols from an orderfile. 126 """Return the symbols from an orderfile.
127 127
128 Args: 128 Args:
129 filename: The name of the orderfile. 129 filename: The name of the orderfile.
130 130
131 Returns: 131 Returns:
132 A list of symbol names. 132 A list of symbol names.
133 """ 133 """
134 with open(filename, 'r') as f: 134 with open(filename, 'r') as f:
135 return _GetSymbolsFromStream(f.xreadlines()) 135 return _GetSymbolsFromStream(f.xreadlines())
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 204
205 205
206 def main(argv): 206 def main(argv):
207 if len(argv) != 3: 207 if len(argv) != 3:
208 print 'Usage: %s <unpatched_orderfile> <libchrome.so>' % argv[0] 208 print 'Usage: %s <unpatched_orderfile> <libchrome.so>' % argv[0]
209 return 1 209 return 1
210 orderfile_filename = argv[1] 210 orderfile_filename = argv[1]
211 binary_filename = argv[2] 211 binary_filename = argv[2]
212 (offset_to_symbol_infos, name_to_symbol_infos) = _GroupSymbolInfosFromBinary( 212 (offset_to_symbol_infos, name_to_symbol_infos) = _GroupSymbolInfosFromBinary(
213 binary_filename) 213 binary_filename)
214 profiled_symbols = _GetSymbolsFromOrderfile(orderfile_filename) 214 profiled_symbols = GetSymbolsFromOrderfile(orderfile_filename)
215 expanded_symbols = _ExpandSymbols( 215 expanded_symbols = _ExpandSymbols(
216 profiled_symbols, name_to_symbol_infos, offset_to_symbol_infos) 216 profiled_symbols, name_to_symbol_infos, offset_to_symbol_infos)
217 _PrintSymbolsWithPrefixes(expanded_symbols, sys.stdout) 217 _PrintSymbolsWithPrefixes(expanded_symbols, sys.stdout)
218 # The following is needed otherwise Gold only applies a partial sort. 218 # The following is needed otherwise Gold only applies a partial sort.
219 print '.text' # gets methods not in a section, such as assembly 219 print '.text' # gets methods not in a section, such as assembly
220 print '.text.*' # gets everything else 220 print '.text.*' # gets everything else
221 return 0 221 return 0
222 222
223 223
224 if __name__ == '__main__': 224 if __name__ == '__main__':
225 logging.basicConfig(level=logging.INFO) 225 logging.basicConfig(level=logging.INFO)
226 sys.exit(main(sys.argv)) 226 sys.exit(main(sys.argv))
OLDNEW
« tools/cygprofile/check_orderfile_unittest.py ('K') | « tools/cygprofile/check_orderfile_unittest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698