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

Side by Side Diff: chrome/tools/build/win/syzygy/instrument.py

Issue 773253004: Move Syzygy build related things to their own directory with an OWNERS file, and add an allocation … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Small fix. Created 6 years 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 | « chrome/tools/build/win/syzygy/OWNERS ('k') | chrome/tools/build/win/syzygy/reorder.py » ('j') | 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 utility script to help building Syzygy-instrumented Chrome binaries.""" 6 """A utility script to help building Syzygy-instrumented Chrome binaries."""
7 7
8 import glob 8 import glob
9 import logging 9 import logging
10 import optparse 10 import optparse
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 '--overwrite', 51 '--overwrite',
52 os.path.abspath(filter_file)] 52 os.path.abspath(filter_file)]
53 53
54 _Shell(*cmd) 54 _Shell(*cmd)
55 if not os.path.exists(output_filter_file): 55 if not os.path.exists(output_filter_file):
56 raise RuntimeError('Compiled filter file missing: %s' % output_filter_file) 56 raise RuntimeError('Compiled filter file missing: %s' % output_filter_file)
57 return 57 return
58 58
59 59
60 def _InstrumentBinary(syzygy_dir, mode, executable, symbol, dst_dir, 60 def _InstrumentBinary(syzygy_dir, mode, executable, symbol, dst_dir,
61 filter_file): 61 filter_file, allocation_filter_file):
62 """Instruments the executable found in input_dir, and writes the resultant 62 """Instruments the executable found in input_dir, and writes the resultant
63 instrumented executable and symbol files to dst_dir. 63 instrumented executable and symbol files to dst_dir.
64 """ 64 """
65 cmd = [os.path.abspath(os.path.join(syzygy_dir, _INSTRUMENT_EXE)), 65 cmd = [os.path.abspath(os.path.join(syzygy_dir, _INSTRUMENT_EXE)),
66 '--overwrite', 66 '--overwrite',
67 '--mode=%s' % mode, 67 '--mode=%s' % mode,
68 '--debug-friendly', 68 '--debug-friendly',
69 '--input-image=%s' % executable, 69 '--input-image=%s' % executable,
70 '--input-pdb=%s' % symbol, 70 '--input-pdb=%s' % symbol,
71 '--output-image=%s' % os.path.abspath( 71 '--output-image=%s' % os.path.abspath(
72 os.path.join(dst_dir, os.path.basename(executable))), 72 os.path.join(dst_dir, os.path.basename(executable))),
73 '--output-pdb=%s' % os.path.abspath( 73 '--output-pdb=%s' % os.path.abspath(
74 os.path.join(dst_dir, os.path.basename(symbol)))] 74 os.path.join(dst_dir, os.path.basename(symbol)))]
75 75
76 if mode == "asan": 76 if mode == "asan":
77 cmd.append('--no-augment-pdb') 77 cmd.append('--no-augment-pdb')
78 78
79 # If a filter was specified then pass it on to the instrumenter. 79 # If any filters were specified then pass them on to the instrumenter.
80 if filter_file: 80 if filter_file:
81 cmd.append('--filter=%s' % os.path.abspath(filter_file)) 81 cmd.append('--filter=%s' % os.path.abspath(filter_file))
82 if allocation_filter_file:
83 cmd.append('--allocation-filter-config-file=%s' %
84 os.path.abspath(allocation_filter_file))
82 85
83 return _Shell(*cmd) 86 return _Shell(*cmd)
84 87
85 88
86 def main(options): 89 def main(options):
87 # Make sure the destination directory exists. 90 # Make sure the destination directory exists.
88 if not os.path.isdir(options.destination_dir): 91 if not os.path.isdir(options.destination_dir):
89 _LOGGER.info('Creating destination directory "%s".', 92 _LOGGER.info('Creating destination directory "%s".',
90 options.destination_dir) 93 options.destination_dir)
91 os.makedirs(options.destination_dir) 94 os.makedirs(options.destination_dir)
92 95
93 # Compile the filter if one was provided. 96 # Compile the filter if one was provided.
94 if options.filter: 97 if options.filter:
95 _CompileFilter(options.syzygy_dir, 98 _CompileFilter(options.syzygy_dir,
96 options.input_executable, 99 options.input_executable,
97 options.input_symbol, 100 options.input_symbol,
98 options.filter, 101 options.filter,
99 options.output_filter_file) 102 options.output_filter_file)
100 103
101 # Instruments the binaries into the destination directory. 104 # Instruments the binaries into the destination directory.
102 _InstrumentBinary(options.syzygy_dir, 105 _InstrumentBinary(options.syzygy_dir,
103 options.mode, 106 options.mode,
104 options.input_executable, 107 options.input_executable,
105 options.input_symbol, 108 options.input_symbol,
106 options.destination_dir, 109 options.destination_dir,
107 options.output_filter_file) 110 options.output_filter_file,
111 options.allocation_filter_file)
108 112
109 113
110 def _ParseOptions(): 114 def _ParseOptions():
111 option_parser = optparse.OptionParser() 115 option_parser = optparse.OptionParser()
112 option_parser.add_option('--input_executable', 116 option_parser.add_option('--input_executable',
113 help='The path to the input executable.') 117 help='The path to the input executable.')
114 option_parser.add_option('--input_symbol', 118 option_parser.add_option('--input_symbol',
115 help='The path to the input symbol file.') 119 help='The path to the input symbol file.')
116 option_parser.add_option('--mode', 120 option_parser.add_option('--mode',
117 help='Specifies which instrumentation mode is to be used.') 121 help='Specifies which instrumentation mode is to be used.')
118 option_parser.add_option('--syzygy-dir', default=_DEFAULT_SYZYGY_DIR, 122 option_parser.add_option('--syzygy-dir', default=_DEFAULT_SYZYGY_DIR,
119 help='Instrumenter executable to use, defaults to "%default".') 123 help='Instrumenter executable to use, defaults to "%default".')
120 option_parser.add_option('-d', '--destination_dir', 124 option_parser.add_option('-d', '--destination_dir',
121 help='Destination directory for instrumented files.') 125 help='Destination directory for instrumented files.')
122 option_parser.add_option('--filter', 126 option_parser.add_option('--filter',
123 help='An optional filter. This will be compiled and passed to the ' 127 help='An optional filter. This will be compiled and passed to the '
124 'instrumentation executable.') 128 'instrumentation executable.')
125 option_parser.add_option('--output-filter-file', 129 option_parser.add_option('--output-filter-file',
126 help='The path where the compiled filter will be written. This is ' 130 help='The path where the compiled filter will be written. This is '
127 'required if --filter is specified.') 131 'required if --filter is specified.')
132 option_parser.add_option('--allocation-filter-file',
133 help='THe path to the SyzyASAN allocation filter to use.')
134 option_parser.add
Sébastien Marchand 2014/12/15 16:13:27 oops ?
chrisha 2014/12/15 16:17:28 Err, yeah.
128 options, args = option_parser.parse_args() 135 options, args = option_parser.parse_args()
129 136
130 if not options.mode: 137 if not options.mode:
131 option_parser.error('You must provide an instrumentation mode.') 138 option_parser.error('You must provide an instrumentation mode.')
132 if not options.input_executable: 139 if not options.input_executable:
133 option_parser.error('You must provide an input executable.') 140 option_parser.error('You must provide an input executable.')
134 if not options.input_symbol: 141 if not options.input_symbol:
135 option_parser.error('You must provide an input symbol file.') 142 option_parser.error('You must provide an input symbol file.')
136 if not options.destination_dir: 143 if not options.destination_dir:
137 option_parser.error('You must provide a destination directory.') 144 option_parser.error('You must provide a destination directory.')
138 if options.filter and not options.output_filter_file: 145 if options.filter and not options.output_filter_file:
139 option_parser.error('You must provide a filter output file.') 146 option_parser.error('You must provide a filter output file.')
140 147
141 return options 148 return options
142 149
143 150
144 if '__main__' == __name__: 151 if '__main__' == __name__:
145 logging.basicConfig(level=logging.INFO) 152 logging.basicConfig(level=logging.INFO)
146 sys.exit(main(_ParseOptions())) 153 sys.exit(main(_ParseOptions()))
OLDNEW
« no previous file with comments | « chrome/tools/build/win/syzygy/OWNERS ('k') | chrome/tools/build/win/syzygy/reorder.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698