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

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

Issue 2559053002: Instrument setup.exe in the SyzyAsan builds.
Patch Set: Fix the component build Created 3 years, 8 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/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, allocation_filter_file): 61 filter_file, allocation_filter_file,
62 defer_crash_reporter_initialization):
62 """Instruments the executable found in input_dir, and writes the resultant 63 """Instruments the executable found in input_dir, and writes the resultant
63 instrumented executable and symbol files to dst_dir. 64 instrumented executable and symbol files to dst_dir.
64 """ 65 """
65 cmd = [os.path.abspath(os.path.join(syzygy_dir, _INSTRUMENT_EXE)), 66 cmd = [os.path.abspath(os.path.join(syzygy_dir, _INSTRUMENT_EXE)),
66 '--overwrite', 67 '--overwrite',
67 '--mode=%s' % mode, 68 '--mode=%s' % mode,
68 '--debug-friendly', 69 '--debug-friendly',
69 '--input-image=%s' % executable, 70 '--input-image=%s' % executable,
70 '--input-pdb=%s' % symbol, 71 '--input-pdb=%s' % symbol,
71 '--output-image=%s' % os.path.abspath( 72 '--output-image=%s' % os.path.abspath(
72 os.path.join(dst_dir, os.path.basename(executable))), 73 os.path.join(dst_dir, os.path.basename(executable))),
73 '--output-pdb=%s' % os.path.abspath( 74 '--output-pdb=%s' % os.path.abspath(
74 os.path.join(dst_dir, os.path.basename(symbol)))] 75 os.path.join(dst_dir, os.path.basename(symbol)))]
75 76
76 if mode == "asan": 77 if mode == "asan":
77 cmd.append('--no-augment-pdb') 78 cmd.append('--no-augment-pdb')
79 asan_rtl_options = [
80 "--enable_feature_randomization",
81 "--prevent_duplicate_corruption_crashes",
82 ]
83 if defer_crash_reporter_initialization:
84 asan_rtl_options.append('--defer_crash_reporter_initialization')
78 # Disable some of the new SysyASAN features. We're seeing an increase in 85 # Disable some of the new SysyASAN features. We're seeing an increase in
79 # crash rates and are wondering if they are to blame. 86 # crash rates and are wondering if they are to blame.
80 cmd.append( 87 cmd.append(
81 '--asan-rtl-options="--enable_feature_randomization ' 88 '--asan-rtl-options="%s"' % ' '.join(asan_rtl_options))
82 '--prevent_duplicate_corruption_crashes"')
83 89
84 # If any filters were specified then pass them on to the instrumenter. 90 # If any filters were specified then pass them on to the instrumenter.
85 if filter_file: 91 if filter_file:
86 cmd.append('--filter=%s' % os.path.abspath(filter_file)) 92 cmd.append('--filter=%s' % os.path.abspath(filter_file))
87 if allocation_filter_file: 93 if allocation_filter_file:
88 cmd.append('--allocation-filter-config-file=%s' % 94 cmd.append('--allocation-filter-config-file=%s' %
89 os.path.abspath(allocation_filter_file)) 95 os.path.abspath(allocation_filter_file))
90 96
91 return _Shell(*cmd) 97 return _Shell(*cmd)
92 98
(...skipping 13 matching lines...) Expand all
106 options.filter, 112 options.filter,
107 options.output_filter_file) 113 options.output_filter_file)
108 114
109 # Instruments the binaries into the destination directory. 115 # Instruments the binaries into the destination directory.
110 _InstrumentBinary(options.syzygy_dir, 116 _InstrumentBinary(options.syzygy_dir,
111 options.mode, 117 options.mode,
112 options.input_executable, 118 options.input_executable,
113 options.input_symbol, 119 options.input_symbol,
114 options.destination_dir, 120 options.destination_dir,
115 options.output_filter_file, 121 options.output_filter_file,
116 options.allocation_filter_file) 122 options.allocation_filter_file,
123 options.defer_crash_reporter_initialization)
117 124
118 125
119 def _ParseOptions(): 126 def _ParseOptions():
120 option_parser = optparse.OptionParser() 127 option_parser = optparse.OptionParser()
121 option_parser.add_option('--input_executable', 128 option_parser.add_option('--input_executable',
122 help='The path to the input executable.') 129 help='The path to the input executable.')
123 option_parser.add_option('--input_symbol', 130 option_parser.add_option('--input_symbol',
124 help='The path to the input symbol file.') 131 help='The path to the input symbol file.')
125 option_parser.add_option('--mode', 132 option_parser.add_option('--mode',
126 help='Specifies which instrumentation mode is to be used.') 133 help='Specifies which instrumentation mode is to be used.')
127 option_parser.add_option('--syzygy-dir', default=_DEFAULT_SYZYGY_DIR, 134 option_parser.add_option('--syzygy-dir', default=_DEFAULT_SYZYGY_DIR,
128 help='Instrumenter executable to use, defaults to "%default".') 135 help='Instrumenter executable to use, defaults to "%default".')
129 option_parser.add_option('-d', '--destination_dir', 136 option_parser.add_option('-d', '--destination_dir',
130 help='Destination directory for instrumented files.') 137 help='Destination directory for instrumented files.')
131 option_parser.add_option('--filter', 138 option_parser.add_option('--filter',
132 help='An optional filter. This will be compiled and passed to the ' 139 help='An optional filter. This will be compiled and passed to the '
133 'instrumentation executable.') 140 'instrumentation executable.')
134 option_parser.add_option('--output-filter-file', 141 option_parser.add_option('--output-filter-file',
135 help='The path where the compiled filter will be written. This is ' 142 help='The path where the compiled filter will be written. This is '
136 'required if --filter is specified.') 143 'required if --filter is specified.')
137 option_parser.add_option('--allocation-filter-file', 144 option_parser.add_option('--allocation-filter-file',
138 help='The path to the SyzyASAN allocation filter to use.') 145 help='The path to the SyzyASAN allocation filter to use.')
146 option_parser.add_option('--defer-crash-reporter-initialization',
147 help='Defer the crash reporter initialization, the client has to call '
148 'asan_InitializeCrashReporter to initialize it.',
149 action="store_true")
139 options, args = option_parser.parse_args() 150 options, args = option_parser.parse_args()
140 151
141 if not options.mode: 152 if not options.mode:
142 option_parser.error('You must provide an instrumentation mode.') 153 option_parser.error('You must provide an instrumentation mode.')
143 if not options.input_executable: 154 if not options.input_executable:
144 option_parser.error('You must provide an input executable.') 155 option_parser.error('You must provide an input executable.')
145 if not options.input_symbol: 156 if not options.input_symbol:
146 option_parser.error('You must provide an input symbol file.') 157 option_parser.error('You must provide an input symbol file.')
147 if not options.destination_dir: 158 if not options.destination_dir:
148 option_parser.error('You must provide a destination directory.') 159 option_parser.error('You must provide a destination directory.')
149 if options.filter and not options.output_filter_file: 160 if options.filter and not options.output_filter_file:
150 option_parser.error('You must provide a filter output file.') 161 option_parser.error('You must provide a filter output file.')
151 162
152 return options 163 return options
153 164
154 165
155 if '__main__' == __name__: 166 if '__main__' == __name__:
156 logging.basicConfig(level=logging.INFO) 167 logging.basicConfig(level=logging.INFO)
157 sys.exit(main(_ParseOptions())) 168 sys.exit(main(_ParseOptions()))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698