• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

修訂4e86df17326d2afaf74622c082d906ed3f96d1d7 (tree)
時間2022-01-27 19:24:18
作者Vladimir Sementsov-Ogievskiy <vsementsov@virt...>
CommiterMarkus Armbruster

Log Message

qapi/gen: Add FOO.trace-events output module

We are going to generate trace events for QMP commands. We should
generate both trace_*() function calls and trace-events files listing
events for trace generator.

So, add an output module FOO.trace-events for each FOO schema module.

Since we're going to add trace events only to command marshallers,
make the trace-events output optional, so we don't generate so many
useless empty files.

Currently nobody set add_trace_events to True, so new functionality is
disabled. It will be enabled for QAPISchemaGenCommandVisitor
in a further commit.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20220126161130.3240892-2-vsementsov@virtuozzo.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>

Change Summary

差異

--- a/scripts/qapi/gen.py
+++ b/scripts/qapi/gen.py
@@ -192,6 +192,11 @@ class QAPIGenH(QAPIGenC):
192192 return guardend(self.fname)
193193
194194
195+class QAPIGenTrace(QAPIGen):
196+ def _top(self) -> str:
197+ return super()._top() + '# AUTOMATICALLY GENERATED, DO NOT MODIFY\n\n'
198+
199+
195200 @contextmanager
196201 def ifcontext(ifcond: QAPISchemaIfCond, *args: QAPIGenCCode) -> Iterator[None]:
197202 """
@@ -244,15 +249,18 @@ class QAPISchemaModularCVisitor(QAPISchemaVisitor):
244249 what: str,
245250 user_blurb: str,
246251 builtin_blurb: Optional[str],
247- pydoc: str):
252+ pydoc: str,
253+ gen_tracing: bool = False):
248254 self._prefix = prefix
249255 self._what = what
250256 self._user_blurb = user_blurb
251257 self._builtin_blurb = builtin_blurb
252258 self._pydoc = pydoc
253259 self._current_module: Optional[str] = None
254- self._module: Dict[str, Tuple[QAPIGenC, QAPIGenH]] = {}
260+ self._module: Dict[str, Tuple[QAPIGenC, QAPIGenH,
261+ Optional[QAPIGenTrace]]] = {}
255262 self._main_module: Optional[str] = None
263+ self._gen_tracing = gen_tracing
256264
257265 @property
258266 def _genc(self) -> QAPIGenC:
@@ -264,6 +272,14 @@ class QAPISchemaModularCVisitor(QAPISchemaVisitor):
264272 assert self._current_module is not None
265273 return self._module[self._current_module][1]
266274
275+ @property
276+ def _gen_trace_events(self) -> QAPIGenTrace:
277+ assert self._gen_tracing
278+ assert self._current_module is not None
279+ gent = self._module[self._current_module][2]
280+ assert gent is not None
281+ return gent
282+
267283 @staticmethod
268284 def _module_dirname(name: str) -> str:
269285 if QAPISchemaModule.is_user_module(name):
@@ -293,7 +309,12 @@ class QAPISchemaModularCVisitor(QAPISchemaVisitor):
293309 basename = self._module_filename(self._what, name)
294310 genc = QAPIGenC(basename + '.c', blurb, self._pydoc)
295311 genh = QAPIGenH(basename + '.h', blurb, self._pydoc)
296- self._module[name] = (genc, genh)
312+
313+ gent: Optional[QAPIGenTrace] = None
314+ if self._gen_tracing:
315+ gent = QAPIGenTrace(basename + '.trace-events')
316+
317+ self._module[name] = (genc, genh, gent)
297318 self._current_module = name
298319
299320 @contextmanager
@@ -304,11 +325,13 @@ class QAPISchemaModularCVisitor(QAPISchemaVisitor):
304325 self._current_module = old_module
305326
306327 def write(self, output_dir: str, opt_builtins: bool = False) -> None:
307- for name, (genc, genh) in self._module.items():
328+ for name, (genc, genh, gent) in self._module.items():
308329 if QAPISchemaModule.is_builtin_module(name) and not opt_builtins:
309330 continue
310331 genc.write(output_dir)
311332 genh.write(output_dir)
333+ if gent is not None:
334+ gent.write(output_dir)
312335
313336 def _begin_builtin_module(self) -> None:
314337 pass