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

Side by Side Diff: third_party/WebKit/Source/build/scripts/make_instrumenting_probes.py

Issue 2800853002: [instrumentation] Turn inspector override "probes" return values into output parameters. (Closed)
Patch Set: update BUILD.gn 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/build/scripts/templates/InstrumentingProbesImpl.cpp.tmpl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2017 The Chromium Authors. All rights reserved. 1 # Copyright 2017 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import ast 5 import ast
6 import optparse 6 import optparse
7 import os.path 7 import os.path
8 import re 8 import re
9 import sys 9 import sys
10 10
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 self.forward_declarations.sort() 117 self.forward_declarations.sort()
118 118
119 119
120 class Method(object): 120 class Method(object):
121 def __init__(self, source): 121 def __init__(self, source):
122 match = re.match(r"(?:(\w+\*?)\s+)?(\w+)\s*\((.*)\)\s*;", source) 122 match = re.match(r"(?:(\w+\*?)\s+)?(\w+)\s*\((.*)\)\s*;", source)
123 if not match: 123 if not match:
124 sys.stderr.write("Cannot parse %s\n" % source) 124 sys.stderr.write("Cannot parse %s\n" % source)
125 sys.exit(1) 125 sys.exit(1)
126 126
127 self.return_type = match.group(1) or ""
128 self.name = match.group(2) 127 self.name = match.group(2)
129 self.is_scoped = self.return_type == "" 128 self.is_scoped = not match.group(1)
129 if not self.is_scoped and match.group(1) != "void":
130 raise Exception("Instant probe must return void: %s" % self.name)
130 131
131 # Splitting parameters by a comma, assuming that attribute lists contain no more than one attribute. 132 # Splitting parameters by a comma, assuming that attribute lists contain no more than one attribute.
132 self.params = map(Parameter, map(str.strip, match.group(3).split(","))) 133 self.params = map(Parameter, map(str.strip, match.group(3).split(",")))
133 134
134 self.returns_value = self.return_type != "" and self.return_type != "voi d"
135 if self.return_type == "bool":
136 self.default_return_value = "false"
137 elif self.returns_value:
138 sys.stderr.write("Can only return bool: %s\n" % self.name)
139 sys.exit(1)
140
141 135
142 class Parameter(object): 136 class Parameter(object):
143 def __init__(self, source): 137 def __init__(self, source):
144 self.options = [] 138 self.options = []
145 match, source = match_and_consume(r"\[(\w*)\]", source) 139 match, source = match_and_consume(r"\[(\w*)\]", source)
146 if match: 140 if match:
147 self.options.append(match.group(1)) 141 self.options.append(match.group(1))
148 142
149 parts = map(str.strip, source.split("=")) 143 parts = map(str.strip, source.split("="))
150 self.default_value = parts[1] if len(parts) != 1 else None 144 self.default_value = parts[1] if len(parts) != 1 else None
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 unused_probes.discard(probe) 200 unused_probes.discard(probe)
207 if probe not in all_pidl_probes: 201 if probe not in all_pidl_probes:
208 raise Exception('Probe %s is not declared in PIDL file' % probe) 202 raise Exception('Probe %s is not declared in PIDL file' % probe)
209 observers_by_probe.setdefault(probe, set()).add(observer_name) 203 observers_by_probe.setdefault(probe, set()).add(observer_name)
210 if unused_probes: 204 if unused_probes:
211 raise Exception("Unused probes: %s" % unused_probes) 205 raise Exception("Unused probes: %s" % unused_probes)
212 206
213 for f in files: 207 for f in files:
214 for probe in f.declarations: 208 for probe in f.declarations:
215 probe.agents = observers_by_probe[probe.name] 209 probe.agents = observers_by_probe[probe.name]
216 if probe.returns_value and len(probe.agents) > 1:
217 raise Exception("Can only return value from a single observer: % s\n" % probe.name)
218 return all_observers 210 return all_observers
219 211
220 212
221 cmdline_parser = optparse.OptionParser() 213 cmdline_parser = optparse.OptionParser()
222 cmdline_parser.add_option("--output_dir") 214 cmdline_parser.add_option("--output_dir")
223 cmdline_parser.add_option("--config") 215 cmdline_parser.add_option("--config")
224 216
225 try: 217 try:
226 arg_options, arg_values = cmdline_parser.parse_args() 218 arg_options, arg_values = cmdline_parser.parse_args()
227 if len(arg_values) != 1: 219 if len(arg_values) != 1:
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 sink_h_file = open(output_dirpath + "/" + to_singular(base_name) + "Sink.h", "w" ) 257 sink_h_file = open(output_dirpath + "/" + to_singular(base_name) + "Sink.h", "w" )
266 sink_h_file.write(sink_h_template.render(template_context)) 258 sink_h_file.write(sink_h_template.render(template_context))
267 sink_h_file.close() 259 sink_h_file.close()
268 260
269 for f in files: 261 for f in files:
270 template_context["file"] = f 262 template_context["file"] = f
271 h_template = jinja_env.get_template("/InstrumentingProbesInl.h.tmpl") 263 h_template = jinja_env.get_template("/InstrumentingProbesInl.h.tmpl")
272 h_file = open(output_dirpath + "/" + f.header_name + ".h", "w") 264 h_file = open(output_dirpath + "/" + f.header_name + ".h", "w")
273 h_file.write(h_template.render(template_context)) 265 h_file.write(h_template.render(template_context))
274 h_file.close() 266 h_file.close()
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/build/scripts/templates/InstrumentingProbesImpl.cpp.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698