mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-09-01 06:21:52 -06:00
trace: [tracetool] Minimize the amount of per-backend code
Backends now only contain the essential backend-specific code, and most of the work is moved to frontend code. Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
ef0bd3bba6
commit
1dad2ce973
19 changed files with 303 additions and 395 deletions
|
@ -20,17 +20,12 @@ All formats must generate their contents through the 'tracetool.out' routine.
|
|||
Format functions
|
||||
----------------
|
||||
|
||||
All the following functions are optional, and no output will be generated if
|
||||
they do not exist.
|
||||
|
||||
======== =======================================================================
|
||||
======== ==================================================================
|
||||
Function Description
|
||||
======== =======================================================================
|
||||
begin Called to generate the format-specific file header.
|
||||
end Called to generate the format-specific file footer.
|
||||
nop Called to generate the per-event contents when the event is disabled or
|
||||
the selected backend is 'nop'.
|
||||
======== =======================================================================
|
||||
======== ==================================================================
|
||||
generate Called to generate a format-specific file.
|
||||
======== ==================================================================
|
||||
|
||||
"""
|
||||
|
||||
__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
|
||||
|
@ -79,25 +74,12 @@ def exists(name):
|
|||
return tracetool.try_import("tracetool.format." + name)[1]
|
||||
|
||||
|
||||
def _empty(events):
|
||||
pass
|
||||
|
||||
def generate_begin(name, events):
|
||||
"""Generate the header of the format-specific file."""
|
||||
if not exists(name):
|
||||
raise ValueError("unknown format: %s" % name)
|
||||
|
||||
name = name.replace("-", "_")
|
||||
func = tracetool.try_import("tracetool.format." + name,
|
||||
"begin", _empty)[1]
|
||||
func(events)
|
||||
|
||||
def generate_end(name, events):
|
||||
"""Generate the footer of the format-specific file."""
|
||||
if not exists(name):
|
||||
raise ValueError("unknown format: %s" % name)
|
||||
|
||||
name = name.replace("-", "_")
|
||||
func = tracetool.try_import("tracetool.format." + name,
|
||||
"end", _empty)[1]
|
||||
func(events)
|
||||
def generate(events, format, backend):
|
||||
if not exists(format):
|
||||
raise ValueError("unknown format: %s" % format)
|
||||
format = format.replace("-", "_")
|
||||
func = tracetool.try_import("tracetool.format." + format,
|
||||
"generate")[1]
|
||||
if func is None:
|
||||
raise AttributeError("format has no 'generate': %s" % format)
|
||||
func(events, backend)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue