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

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

Issue 2361763002: orderfile: Don't report failure when a few symbol pairs are misordered. (Closed)
Patch Set: Created 4 years, 3 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
« 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/python 1 #!/usr/bin/python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 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 """Check that symbols are ordered into a binary as they appear in the orderfile. 6 """Check that symbols are ordered into a binary as they appear in the orderfile.
7 """ 7 """
8 8
9 import logging 9 import logging
10 import optparse 10 import optparse
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 previous_symbol_info = symbol_info 67 previous_symbol_info = symbol_info
68 return (misordered_count, len(matched_symbol_infos), missing_count) 68 return (misordered_count, len(matched_symbol_infos), missing_count)
69 69
70 70
71 def main(): 71 def main():
72 parser = optparse.OptionParser(usage= 72 parser = optparse.OptionParser(usage=
73 'usage: %prog [options] <binary> <orderfile>') 73 'usage: %prog [options] <binary> <orderfile>')
74 parser.add_option('--target-arch', action='store', dest='arch', 74 parser.add_option('--target-arch', action='store', dest='arch',
75 choices=['arm', 'arm64', 'x86', 'x86_64', 'x64', 'mips'], 75 choices=['arm', 'arm64', 'x86', 'x86_64', 'x64', 'mips'],
76 help='The target architecture for the binary.') 76 help='The target architecture for the binary.')
77 parser.add_option('--threshold', action='store', dest='threshold', default=1, 77 parser.add_option('--threshold', action='store', dest='threshold', default=10,
78 help='The maximum allowed number of out-of-order symbols.') 78 help='The maximum allowed number of out-of-order symbols.')
79 options, argv = parser.parse_args(sys.argv) 79 options, argv = parser.parse_args(sys.argv)
80 if not options.arch: 80 if not options.arch:
81 options.arch = cygprofile_utils.DetectArchitecture() 81 options.arch = cygprofile_utils.DetectArchitecture()
82 if len(argv) != 3: 82 if len(argv) != 3:
83 parser.print_help() 83 parser.print_help()
84 return 1 84 return 1
85 (binary_filename, orderfile_filename) = argv[1:] 85 (binary_filename, orderfile_filename) = argv[1:]
86 86
87 symbol_extractor.SetArchitecture(options.arch) 87 symbol_extractor.SetArchitecture(options.arch)
88 obj_dir = cygprofile_utils.GetObjDir(binary_filename) 88 obj_dir = cygprofile_utils.GetObjDir(binary_filename)
89 symbol_to_sections_map = \ 89 symbol_to_sections_map = \
90 cyglog_to_orderfile.GetSymbolToSectionsMapFromObjectFiles(obj_dir) 90 cyglog_to_orderfile.GetSymbolToSectionsMapFromObjectFiles(obj_dir)
91 section_to_symbols_map = cygprofile_utils.InvertMapping( 91 section_to_symbols_map = cygprofile_utils.InvertMapping(
92 symbol_to_sections_map) 92 symbol_to_sections_map)
93 symbols = patch_orderfile.GetSymbolsFromOrderfile(orderfile_filename, 93 symbols = patch_orderfile.GetSymbolsFromOrderfile(orderfile_filename,
94 section_to_symbols_map) 94 section_to_symbols_map)
95 symbol_infos = symbol_extractor.SymbolInfosFromBinary(binary_filename) 95 symbol_infos = symbol_extractor.SymbolInfosFromBinary(binary_filename)
96 # Missing symbols is not an error since some of them can be eliminated through 96 # Missing symbols is not an error since some of them can be eliminated through
97 # inlining. 97 # inlining.
98 (misordered_pairs_count, matched_symbols, _) = _CountMisorderedSymbols( 98 (misordered_pairs_count, matched_symbols, _) = _CountMisorderedSymbols(
99 symbols, symbol_infos) 99 symbols, symbol_infos)
100 return (misordered_pairs_count > options.threshold) or (matched_symbols == 0) 100 return (misordered_pairs_count > options.threshold) or (matched_symbols == 0)
101 101
102 102
103 if __name__ == '__main__': 103 if __name__ == '__main__':
104 logging.basicConfig(level=logging.INFO) 104 logging.basicConfig(level=logging.INFO)
105 sys.exit(main()) 105 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