1 # -*- coding: utf-8 -*-
4 Generic management for the 'vcpu' property.
8 __author__
= "Lluís Vilanova <vilanova@ac.upc.edu>"
9 __copyright__
= "Copyright 2016, Lluís Vilanova <vilanova@ac.upc.edu>"
10 __license__
= "GPL version 2 or (at your option) any later version"
12 __maintainer__
= "Stefan Hajnoczi"
13 __email__
= "stefanha@redhat.com"
16 from tracetool
import Arguments
, try_import
19 def transform_event(event
):
20 """Transform event to comply with the 'vcpu' property (if present)."""
21 if "vcpu" in event
.properties
:
22 # events with 'tcg-trans' and 'tcg-exec' are auto-generated from
23 # already-patched events
24 assert "tcg-trans" not in event
.properties
25 assert "tcg-exec" not in event
.properties
27 event
.args
= Arguments([("void *", "__cpu"), event
.args
])
28 if "tcg" in event
.properties
:
30 event
.fmt
= [fmt
+ event
.fmt
[0],
34 event
.fmt
= fmt
+ event
.fmt
38 def transform_args(format
, event
, *args
, **kwargs
):
39 """Transforms the arguments to suit the specified format.
41 The format module must implement function 'vcpu_args', which receives the
42 implicit arguments added by the 'vcpu' property, and must return suitable
43 arguments for the given format.
45 The function is only called for events with the 'vcpu' property.
53 Passed to 'vcpu_transform_args'.
58 The transformed arguments, including the non-implicit ones.
61 if "vcpu" in event
.properties
:
62 ok
, func
= try_import("tracetool.format." + format
,
63 "vcpu_transform_args")
66 return Arguments([func(event
.args
[:1], *args
, **kwargs
),