trace: Show vCPU info in guest code events
v9 cover trace: Show vCPU info in guest code events
NOTE: This series should complete the framework for guest code tracing. From
here on, other series can concurrently add actual events and improve the guest code tracing features and performance (e.g., control tracing independently on each vCPU).
This series introduces the "vcpu" property for tracing events. This property identifies events that are tied to a particular virtual CPU (e.g., executing an instruction).
Events with this property have an implicit vcpu argument, which is shown in the trace. In the case of events executed at TCG translation time, two implicit arguments are added:
* The vCPU performing the code translation (shown in the translation-time trace)
* The vCPU executing the translated code (shown in the execution-time trace)
Note that the "vcpu" and "tcg" properties are not merged into a single one, since events can be defined that relate to a vCPU but are never raised from TCG code (e.g., interrupts).
Changes in v9
=============
* Rebase on 774ae42.
* Fix CPUState typedef, and refactor into a separate patch [Stefan Hajnoczi].
* Fix TCGv_cpu -> TCGv_env rename in sparc [Stefan Hajnoczi].
Changes in v8
=============
* Rebase on 1b16240.
* Minor fix in message formatting ('tracetool.vcpu' module).
* Fix management of event arguments with TCG types.
* Tested with various (non sent) events with different mixes of native and TCG arguments.
Changes in v7
=============
* Fix the modified event copying code.
* Minor fix in commit message for patch 3.
Changes in v6
=============
* Rebase on 84c0781.
* Replace the added 'TCGv_cpu' type for 'TCGv_env', since the users are really pointing to 'CPUArchState'.
* Add functions to simplify event argument management.
* Add minor event copy cleanup (remove long "event.original.original" chains).
* Make it easier to change arguments injected by the 'vcpu' property.
Changes in v5
=============
* Rebase on 357e81c.
* Split from the previous (larger and more complex) v4 series.
Changes in v4
=============
* Fix typo in commit message (Stefan Hajnoczi).
* Simplify per-vCPU tracing state initialization (Stefan Hajnoczi).
* Update copyright years.
Changes in v3
=============
* Update QAPI version (Eric Blake).
* Fix '#optional' annotation in QAPI (Eric Blake).
Changes in v2
=============
* Rebase on 5522a84.
* Improve patch descriptions.
* Refactor code generation into a separate patch.
* Fix forward declarations (Stefan Hajnoczi & Eduardo Habkost).
* Fix "since" tags in QAPI interface (Eric Blake).
* Unify QAPI/QMP interface with an optional 'vcpu' argument (Eric Blake).
* Fix QMP+GTK header workaround (Stefan Hajnoczi).
---
Lluís Vilanova (7):
trace: Extend API to manage event arguments
trace: Remove unnecessary intermediate event copies
tcg: Add type for vCPU pointers
tcg: Move definition of type TCGv
[trivial] trace: Add helper function to cast event arguments
typedefs: Add CPUState
trace: Add 'vcpu' event property to trace guest vCPU
docs/tracing.txt | 41 +++++++++++++ include/qemu/typedefs.h | 1 include/qom/cpu.h | 1 scripts/tracetool/__init__.py | 35 +++++++++-- scripts/tracetool/format/events_h.py | 4 + scripts/tracetool/format/h.py | 3 + scripts/tracetool/format/tcg_h.py | 33 +++++++--- scripts/tracetool/format/tcg_helper_c.py | 45 +++++++++++--- scripts/tracetool/format/tcg_helper_h.py | 7 +- scripts/tracetool/format/tcg_helper_wrapper_h.py | 5 +- scripts/tracetool/format/ust_events_c.py | 1 scripts/tracetool/transform.py | 4 + scripts/tracetool/vcpu.py | 70 ++++++++++++++++++++++ stubs/target-get-monitor-def.c | 3 - target-alpha/translate.c | 2 - target-arm/translate.c | 2 - target-arm/translate.h | 2 - target-cris/translate.c | 2 - target-i386/translate.c | 2 - target-lm32/translate.c | 2 - target-m68k/translate.c | 2 - target-microblaze/translate.c | 2 - target-mips/translate.c | 2 - target-moxie/translate.c | 2 - target-openrisc/translate.c | 2 - target-ppc/translate.c | 2 - target-s390x/translate.c | 2 - target-sh4/translate.c | 2 - target-sparc/translate.c | 5 +- target-tilegx/translate.c | 2 - target-tricore/translate.c | 2 - target-unicore32/translate.c | 2 - target-xtensa/translate.c | 2 - tcg/tcg-op.h | 2 - tcg/tcg.h | 8 +++ trace/control.h | 3 + 36 files changed, 242 insertions(+), 65 deletions(-) create mode 100644 scripts/tracetool/vcpu.py
To: [email protected]
Cc: Stefan Hajnoczi <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: Eric Blake <[email protected]>
Cc: Alex Bennée <[email protected]>
PATCH v9 1/7 trace: Extend API to manage event arguments
Lets the user manage event arguments as a list, and simplifies argument concatenation.
--- scripts/tracetool/__init__.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
scripts/tracetool/__init__.py +13 -2
@@ -50,9 +50,14 @@ class Arguments: Parameters ---------- args : - List of (type, name) tuples. + List of (type, name) tuples or Arguments objects. """ - self._args = args + self._args = [] + for arg in args: + if isinstance(arg, Arguments): + self._args.extend(arg._args) + else: + self._args.append(arg) def copy(self): """Create a new copy."""
@@ -83,6 +88,12 @@ class Arguments: res.append((arg_type, identifier)) return Arguments(res) + def __getitem__(self, index): + if isinstance(index, slice): + return Arguments(self._args[index]) + else: + return self._args[index] + def __iter__(self): """Iterate over the (type, name) pairs.""" return iter(self._args)
PATCH v9 2/7 trace: Remove unnecessary intermediate event copies
In reply to Lluís VilanovaThe current code forces the use of a chain of ".original" dereferences, which looks odd.
--- scripts/tracetool/__init__.py | 5 ++--- scripts/tracetool/format/events_h.py | 4 ++-- scripts/tracetool/format/tcg_h.py | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-)
scripts/tracetool/__init__.py +2 -3
@@ -6,7 +6,7 @@ Machinery for generating tracing-related intermediate files. """ __author__ = "Lluís Vilanova <[email protected]>" -__copyright__ = "Copyright 2012-2014, Lluís Vilanova <[email protected]>" +__copyright__ = "Copyright 2012-2016, Lluís Vilanova <[email protected]>" __license__ = "GPL version 2 or (at your option) any later version" __maintainer__ = "Stefan Hajnoczi"
@@ -288,13 +288,12 @@ def _read_events(fobj): if atrans == aorig: args_trans.append(atrans) event_trans.args = Arguments(args_trans) - event_trans = event_trans.copy() event_exec = event.copy() event_exec.name += "_exec" event_exec.properties += ["tcg-exec"] event_exec.fmt = event.fmt[1] - event_exec = event_exec.transform(tracetool.transform.TCG_2_HOST) + event_exec.args = event_exec.args.transform(tracetool.transform.TCG_2_HOST) new_event = [event_trans, event_exec] event.event_trans, event.event_exec = new_event
scripts/tracetool/format/events_h.py +2 -2
@@ -6,7 +6,7 @@ trace/generated-events.h """ __author__ = "Lluís Vilanova <[email protected]>" -__copyright__ = "Copyright 2012-2014, Lluís Vilanova <[email protected]>" +__copyright__ = "Copyright 2012-2016, Lluís Vilanova <[email protected]>" __license__ = "GPL version 2 or (at your option) any later version" __maintainer__ = "Stefan Hajnoczi"
@@ -43,7 +43,7 @@ def generate(events, backend): if "tcg-trans" in e.properties: # a single define for the two "sub-events" out('#define TRACE_%(name)s_ENABLED %(enabled)d', - name=e.original.original.name.upper(), + name=e.original.name.upper(), enabled=enabled) out('#define TRACE_%s_ENABLED %d' % (e.name.upper(), enabled))
scripts/tracetool/format/tcg_h.py +2 -2
@@ -6,7 +6,7 @@ Generate .h file for TCG code generation. """ __author__ = "Lluís Vilanova <[email protected]>" -__copyright__ = "Copyright 2012-2014, Lluís Vilanova <[email protected]>" +__copyright__ = "Copyright 2012-2016, Lluís Vilanova <[email protected]>" __license__ = "GPL version 2 or (at your option) any later version" __maintainer__ = "Stefan Hajnoczi"
@@ -36,7 +36,7 @@ def generate(events, backend): continue # get the original event definition - e = e.original.original + e = e.original out('static inline void %(name_tcg)s(%(args)s)', '{',
PATCH v9 4/7 tcg: Move definition of type TCGv
In reply to Lluís VilanovaThe target-dependant type TCGv must be defined in "tcg/tcg.h" before including the tracing helper wrappers in "tcg/tcg-op.h".
It also makes more sense to define it here, where other TCG types are defined too.
--- tcg/tcg-op.h | 2 -- tcg/tcg.h | 7 +++++++ 2 files changed, 7 insertions(+), 2 deletions(-)
tcg/tcg-op.h +0 -2
@@ -756,7 +756,6 @@ static inline void tcg_gen_exit_tb(uintptr_t val)void tcg_gen_goto_tb (unsigned idx);#if TARGET_LONG_BITS ==32 -#define TCGv TCGv_i32#define tcg_temp_new () tcg_temp_new_i32()#define tcg_global_reg_new tcg_global_reg_new_i32#define tcg_global_mem_new tcg_global_mem_new_i32
@@ -768,7 +767,6 @@ void tcg_gen_goto_tb(unsigned idx);#define tcg_gen_qemu_ld_tl tcg_gen_qemu_ld_i32#define tcg_gen_qemu_st_tl tcg_gen_qemu_st_i32#else -#define TCGv TCGv_i64#define tcg_temp_new () tcg_temp_new_i64()#define tcg_global_reg_new tcg_global_reg_new_i64#define tcg_global_mem_new tcg_global_mem_new_i64
tcg/tcg.h +7 -0
@@ -309,6 +309,13 @@ typedef struct TCGv_i32_d *TCGv_i32;typedef struct TCGv_i64_d *TCGv_i64 ;typedef struct TCGv_ptr_d *TCGv_ptr ;typedef TCGv_ptr TCGv_env ; +#if TARGET_LONG_BITS ==32 +#define TCGv TCGv_i32 +#elif TARGET_LONG_BITS ==64 +#define TCGv TCGv_i64 +#else +#error Unhandled TARGET_LONG_BITS value +#endif static inline TCGv_i32 QEMU_ARTIFICIAL MAKE_TCGV_I32(intptr_t i) {
PATCH v9 5/7 trace: Add helper function to cast event arguments
In reply to Lluís Vilanova--- scripts/tracetool/__init__.py | 4 ++++ 1 file changed, 4 insertions(+)
scripts/tracetool/__init__.py +4 -0
@@ -121,6 +121,10 @@ class Arguments: """List of argument types.""" return [ type_ for type_, _ in self._args ] + def casted(self): + """List of argument names casted to their type.""" + return ["(%s)%s" % (type_, name) for type_, name in self._args] + def transform(self, *trans): """Return a new Arguments instance with transformed types.
PATCH v9 6/7 typedefs: Add CPUState
In reply to Lluís Vilanova--- include/qemu/typedefs.h | 1 + include/qom/cpu.h | 1 - stubs/target-get-monitor-def.c | 3 +-- 3 files changed, 2 insertions(+), 3 deletions(-)
include/qemu/typedefs.h +1 -0
@@ -18,6 +18,7 @@ typedef struct BusState BusState;typedef struct CharDriverState CharDriverState ;typedef struct CompatProperty CompatProperty ;typedef struct CPUAddressSpace CPUAddressSpace ; +typedef struct CPUState CPUState ;typedef struct DeviceListener DeviceListener ;typedef struct DeviceState DeviceState ;typedef struct DisplayChangeListener DisplayChangeListener ;
include/qom/cpu.h +0 -1
@@ -62,7 +62,6 @@ typedef uint64_t vaddr;#define CPU_CLASS (class) OBJECT_CLASS_CHECK(CPUClass, (class), TYPE_CPU)#define CPU_GET_CLASS (obj) OBJECT_GET_CLASS(CPUClass, (obj), TYPE_CPU) -typedef struct CPUState CPUState ;typedef struct CPUWatchpoint CPUWatchpoint ; typedef void (*CPUUnassignedAccess)(CPUState *cpu, hwaddr addr,
stubs/target-get-monitor-def.c +1 -2
@@ -20,10 +20,9 @@*/ #include "qemu/osdep.h" +#include "qemu/typedefs.h" #include "stdint.h" -typedef struct CPUState CPUState ; -int target_get_monitor_def (CPUState *cs,const char *name,uint64_t *pval);int target_get_monitor_def (CPUState *cs,const char *name,uint64_t *pval)
PATCH v9 7/7 trace: Add 'vcpu' event property to trace guest vCPU
In reply to Lluís VilanovaThis property identifies events that trace vCPU-specific information.
It adds a "CPUState*" argument to events with the property, identifying the vCPU raising the event. TCG translation events also have a "TCGv_env" implicit argument that is later used as the "CPUState*" argument at execution time.
--- docs/tracing.txt | 41 +++++++++++++ scripts/tracetool/__init__.py | 11 +++ scripts/tracetool/format/h.py | 3 + scripts/tracetool/format/tcg_h.py | 31 +++++++--- scripts/tracetool/format/tcg_helper_c.py | 45 +++++++++++--- scripts/tracetool/format/tcg_helper_h.py | 7 +- scripts/tracetool/format/tcg_helper_wrapper_h.py | 5 +- scripts/tracetool/format/ust_events_c.py | 1 scripts/tracetool/transform.py | 4 + scripts/tracetool/vcpu.py | 70 ++++++++++++++++++++++ trace/control.h | 3 + 11 files changed, 189 insertions(+), 32 deletions(-) create mode 100644 scripts/tracetool/vcpu.py
docs/tracing.txt +41 -0
@@ -347,3 +347,44 @@ This will immediately call: and will generate the TCG code to call: void trace_foo(uint8_t a1, uint32_t a2); + +=== "vcpu" === + +Identifies events that trace vCPU-specific information. It implicitly adds a +"CPUState*" argument, and extends the tracing print format to show the vCPU +information. If used together with the "tcg" property, it adds a second +"TCGv_env" argument that must point to the per-target global TCG register that +points to the vCPU when guest code is executed (usually the "cpu_env" variable). + +The following example events: + + foo(uint32_t a) "a=%x" + vcpu bar(uint32_t a) "a=%x" + tcg vcpu baz(uint32_t a) "a=%x", "a=%x" + +Can be used as: + + #include "trace-tcg.h" + + CPUArchState *env; + TCGv_ptr cpu_env; + + void some_disassembly_func(...) + { + /* trace emitted at this point */ + trace_foo(0xd1); + /* trace emitted at this point */ + trace_bar(ENV_GET_CPU(env), 0xd2); + /* trace emitted at this point (env) and when guest code is executed (cpu_env) */ + trace_baz_tcg(ENV_GET_CPU(env), cpu_env, 0xd3); + } + +If the translating vCPU has address 0xc1 and code is later executed by vCPU +0xc2, this would be an example output: + + // at guest code translation + foo a=0xd1 + bar cpu=0xc1 a=0xd2 + baz_trans cpu=0xc1 a=0xd3 + // at guest code execution + baz_exec cpu=0xc2 a=0xd3
scripts/tracetool/__init__.py +9 -2
@@ -161,7 +161,7 @@ class Event(object): "(?:(?:(?P<fmt_trans>\".+),)?\s*(?P<fmt>\".+))?" "\s*") - _VALID_PROPS = set(["disable", "tcg", "tcg-trans", "tcg-exec"]) + _VALID_PROPS = set(["disable", "tcg", "tcg-trans", "tcg-exec", "vcpu"]) def __init__(self, name, props, fmt, args, orig=None): """
@@ -230,7 +230,13 @@ class Event(object): if "tcg" in props and isinstance(fmt, str): raise ValueError("Events with 'tcg' property must have two formats") - return Event(name, props, fmt, args) + event = Event(name, props, fmt, args) + + # add implicit arguments when using the 'vcpu' property + import tracetool.vcpu + event = tracetool.vcpu.transform_event(event) + + return event def __repr__(self): """Evaluable string representation for this object."""
@@ -285,6 +291,7 @@ def _read_events(fobj): event_trans.name += "_trans" event_trans.properties += ["tcg-trans"] event_trans.fmt = event.fmt[0] + # ignore TCG arguments args_trans = [] for atrans, aorig in zip( event_trans.transform(tracetool.transform.TCG_2_HOST).args,
scripts/tracetool/format/h.py +2 -1
@@ -6,7 +6,7 @@ trace/generated-tracers.h """ __author__ = "Lluís Vilanova <[email protected]>" -__copyright__ = "Copyright 2012-2014, Lluís Vilanova <[email protected]>" +__copyright__ = "Copyright 2012-2016, Lluís Vilanova <[email protected]>" __license__ = "GPL version 2 or (at your option) any later version" __maintainer__ = "Stefan Hajnoczi"
@@ -23,6 +23,7 @@ def generate(events, backend): '#define TRACE__GENERATED_TRACERS_H', '', '#include "qemu-common.h"', + '#include "qemu/typedefs.h"', '') backend.generate_begin(events)
scripts/tracetool/format/tcg_h.py +21 -10
@@ -13,7 +13,18 @@ __maintainer__ = "Stefan Hajnoczi" __email__ = "[email protected]" -from tracetool import out +from tracetool import out, Arguments +import tracetool.vcpu + + +def vcpu_transform_args(args): + assert len(args) == 1 + return Arguments([ + args, + # NOTE: this name must be kept in sync with the one in "tcg_h" + # NOTE: Current helper code uses TCGv_env (CPUArchState*) + ("TCGv_env", "__tcg_" + args.names()[0]), + ]) def generate(events, backend):
@@ -35,21 +46,21 @@ def generate(events, backend): if "tcg-trans" not in e.properties: continue - # get the original event definition - e = e.original - out('static inline void %(name_tcg)s(%(args)s)', '{', - name_tcg=e.api(e.QEMU_TRACE_TCG), - args=e.args) + name_tcg=e.original.api(e.QEMU_TRACE_TCG), + args=tracetool.vcpu.transform_args("tcg_h", e.original)) if "disable" not in e.properties: + args_trans = e.original.event_trans.args + args_exec = tracetool.vcpu.transform_args( + "tcg_helper_c", e.original.event_exec, "wrapper") out(' %(name_trans)s(%(argnames_trans)s);', ' gen_helper_%(name_exec)s(%(argnames_exec)s);', - name_trans=e.event_trans.api(e.QEMU_TRACE), - name_exec=e.event_exec.api(e.QEMU_TRACE), - argnames_trans=", ".join(e.event_trans.args.names()), - argnames_exec=", ".join(e.event_exec.args.names())) + name_trans=e.original.event_trans.api(e.QEMU_TRACE), + name_exec=e.original.event_exec.api(e.QEMU_TRACE), + argnames_trans=", ".join(args_trans.names()), + argnames_exec=", ".join(args_exec.names())) out('}')
scripts/tracetool/format/tcg_helper_c.py +34 -11
67 lines not on this page · raw message
scripts/tracetool/format/tcg_helper_h.py +3 -4
@@ -6,7 +6,7 @@ Generate trace/generated-helpers.h. """ __author__ = "Lluís Vilanova <[email protected]>" -__copyright__ = "Copyright 2012-2014, Lluís Vilanova <[email protected]>" +__copyright__ = "Copyright 2012-2016, Lluís Vilanova <[email protected]>" __license__ = "GPL version 2 or (at your option) any later version" __maintainer__ = "Stefan Hajnoczi"
@@ -15,6 +15,7 @@ __email__ = "[email protected]" from tracetool import out from tracetool.transform import * +import tracetool.vcpu def generate(events, backend):
@@ -29,11 +30,9 @@ def generate(events, backend): if "tcg-exec" not in e.properties: continue - # tracetool.generate always transforms types to host - e_args = e.original.args - # TCG helper proxy declaration fmt = "DEF_HELPER_FLAGS_%(argc)d(%(name)s, %(flags)svoid%(types)s)" + e_args = tracetool.vcpu.transform_args("tcg_helper_c", e.original, "header") args = e_args.transform(HOST_2_TCG_COMPAT, HOST_2_TCG, TCG_2_TCG_HELPER_DECL) types = ", ".join(args.types())
scripts/tracetool/format/tcg_helper_wrapper_h.py +3 -2
@@ -6,7 +6,7 @@ Generate trace/generated-helpers-wrappers.h. """ __author__ = "Lluís Vilanova <[email protected]>" -__copyright__ = "Copyright 2012-2014, Lluís Vilanova <[email protected]>" +__copyright__ = "Copyright 2012-2016, Lluís Vilanova <[email protected]>" __license__ = "GPL version 2 or (at your option) any later version" __maintainer__ = "Stefan Hajnoczi"
@@ -15,6 +15,7 @@ __email__ = "[email protected]" from tracetool import out from tracetool.transform import * +import tracetool.vcpu def generate(events, backend):
@@ -33,7 +34,7 @@ def generate(events, backend): continue # tracetool.generate always transforms types to host - e_args = e.original.args + e_args = tracetool.vcpu.transform_args("tcg_helper_c", e.original, "wrapper") # mixed-type to TCG helper bridge args_tcg_compat = e_args.transform(HOST_2_TCG_COMPAT)
scripts/tracetool/format/ust_events_c.py +1 -0
@@ -32,4 +32,5 @@ def generate(events, backend): ' */', '#pragma GCC diagnostic ignored "-Wredundant-decls"', '', + '#include "qemu/typedefs.h"', '#include "generated-ust-provider.h"')
scripts/tracetool/transform.py +3 -1
@@ -6,7 +6,7 @@ Type-transformation rules. """ __author__ = "Lluís Vilanova <[email protected]>" -__copyright__ = "Copyright 2012-2014, Lluís Vilanova <[email protected]>" +__copyright__ = "Copyright 2012-2016, Lluís Vilanova <[email protected]>" __license__ = "GPL version 2 or (at your option) any later version" __maintainer__ = "Stefan Hajnoczi"
@@ -98,6 +98,7 @@ HOST_2_TCG = { "uint32_t": "TCGv_i32", "uint64_t": "TCGv_i64", "void *" : "TCGv_ptr", + "CPUArchState *": "TCGv_env", None: _host_2_tcg, }
@@ -130,6 +131,7 @@ TCG_2_TCG_HELPER_DECL = { "TCGv_ptr": "ptr", "TCGv_i32": "i32", "TCGv_i64": "i64", + "TCGv_env": "env", None: _tcg_2_tcg_helper_decl_error, }
scripts/tracetool/vcpu.py new file +70 -0
70 lines not on this page · raw message
trace/control.h +2 -1
@@ -1,7 +1,7 @@/* * Interface for configuring and controlling the state of tracing events. * -* Copyright (C) 2011-2014 Lluís Vilanova <[email protected]> +* Copyright (C) 2011-2016 Lluís Vilanova <[email protected]> * * This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory.
@@ -11,6 +11,7 @@#define TRACE__CONTROL_H #include "qemu-common.h" +#include "qemu/typedefs.h" #include "trace/generated-events.h"
PATCH v9 3/7 tcg: Add type for vCPU pointers
In reply to Lluís VilanovaAdds the 'TCGv_env' type for pointers to 'CPUArchState' objects. The tracing infrastructure later needs to differentiate between regular pointers and pointers to vCPUs.
Also changes all targets to use the new 'TCGv_env' type instead of the generic 'TCGv_ptr'. As of now, the change is merely cosmetic ('TCGv_env' translates into 'TCGv_ptr'), but that could change in the future to enforce the difference.
Note that a 'TCGv_env' type (for 'CPUState') is not added, since all helpers currently receive the architecture-specific pointer ('CPUArchState').
--- target-alpha/translate.c | 2 +- target-arm/translate.c | 2 +- target-arm/translate.h | 2 +- target-cris/translate.c | 2 +- target-i386/translate.c | 2 +- target-lm32/translate.c | 2 +- target-m68k/translate.c | 2 +- target-microblaze/translate.c | 2 +- target-mips/translate.c | 2 +- target-moxie/translate.c | 2 +- target-openrisc/translate.c | 2 +- target-ppc/translate.c | 2 +- target-s390x/translate.c | 2 +- target-sh4/translate.c | 2 +- target-sparc/translate.c | 5 +++-- target-tilegx/translate.c | 2 +- target-tricore/translate.c | 2 +- target-unicore32/translate.c | 2 +- target-xtensa/translate.c | 2 +- tcg/tcg.h | 1 + 20 files changed, 22 insertions(+), 20 deletions(-)
target-alpha/translate.c +1 -1
@@ -93,7 +93,7 @@ typedef enum { } ExitStatus;/* global register indexes */ -static TCGv_ptr cpu_env; +static TCGv_env cpu_env;static TCGv cpu_std_ir[31 ];static TCGv cpu_fir[31 ];static TCGv cpu_pc;
target-arm/translate.c +1 -1
@@ -56,7 +56,7 @@#define IS_USER (s) (s->user)#endif -TCGv_ptr cpu_env; +TCGv_env cpu_env;/* We reuse the same 64-bit temporaries for efficiency. */ static TCGv_i64 cpu_V0, cpu_V1, cpu_M0;static TCGv_i32 cpu_R[16 ];
target-arm/translate.h +1 -1
@@ -70,7 +70,7 @@ typedef struct DisasCompare { } DisasCompare;/* Share the TCG temporaries common between 32 and 64 bit modes. */ -extern TCGv_ptr cpu_env; +extern TCGv_env cpu_env;extern TCGv_i32 cpu_NF, cpu_ZF, cpu_CF, cpu_VF;extern TCGv_i64 cpu_exclusive_addr;extern TCGv_i64 cpu_exclusive_val;
target-cris/translate.c +1 -1
@@ -60,7 +60,7 @@#define CC_MASK_NZVC 0xf#define CC_MASK_RNZV 0x10e -static TCGv_ptr cpu_env; +static TCGv_env cpu_env;static TCGv cpu_R[16 ];static TCGv cpu_PR[16 ];static TCGv cc_x;
target-i386/translate.c +1 -1
@@ -65,7 +65,7 @@//#define MACRO_TEST 1 /* global register indexes */ -static TCGv_ptr cpu_env; +static TCGv_env cpu_env;static TCGv cpu_A0;static TCGv cpu_cc_dst, cpu_cc_src, cpu_cc_src2, cpu_cc_srcT;static TCGv_i32 cpu_cc_op;
target-lm32/translate.c +1 -1
@@ -44,7 +44,7 @@#define MEM_INDEX 0 -static TCGv_ptr cpu_env; +static TCGv_env cpu_env;static TCGv cpu_R[32 ];static TCGv cpu_pc;static TCGv cpu_ie;
target-m68k/translate.c +1 -1
@@ -50,7 +50,7 @@static TCGv_i32 cpu_halted;static TCGv_i32 cpu_exception_index; -static TCGv_ptr cpu_env; +static TCGv_env cpu_env;static char cpu_reg_names[3 *8 *3 +5 *4 ];static TCGv cpu_dregs[8 ];
target-microblaze/translate.c +1 -1
@@ -46,7 +46,7 @@ (((src) >> start) & ((1 << (end - start + 1)) - 1))static TCGv env_debug; -static TCGv_ptr cpu_env; +static TCGv_env cpu_env;static TCGv cpu_R[32 ];static TCGv cpu_SR[18 ];static TCGv env_imm;
target-mips/translate.c +1 -1
@@ -1353,7 +1353,7 @@ enum { };/* global register indices */ -static TCGv_ptr cpu_env; +static TCGv_env cpu_env;static TCGv cpu_gpr[32 ], cpu_PC;static TCGv cpu_HI[MIPS_DSP_ACC ], cpu_LO[MIPS_DSP_ACC ];static TCGv cpu_dspctrl, btarget, bcond;
target-moxie/translate.c +1 -1
@@ -56,7 +56,7 @@ enum {static TCGv cpu_pc;static TCGv cpu_gregs[16 ]; -static TCGv_ptr cpu_env; +static TCGv_env cpu_env;static TCGv cc_a, cc_b;#include "exec/gen-icount.h"
target-openrisc/translate.c +1 -1
@@ -53,7 +53,7 @@ typedef struct DisasContext {uint32_t delayed_branch; } DisasContext; -static TCGv_ptr cpu_env; +static TCGv_env cpu_env;static TCGv cpu_sr;static TCGv cpu_R[32 ];static TCGv cpu_pc;
target-ppc/translate.c +1 -1
@@ -49,7 +49,7 @@/* Code translation helpers */ /* global register indexes */ -static TCGv_ptr cpu_env; +static TCGv_env cpu_env;static char cpu_reg_names[10 *3 +22 *4 /* GPR */ +10 *4 +22 *5 /* SPE GPRh */ + 10*4 + 22*5 /* FPR */
target-s390x/translate.c +1 -1
@@ -37,7 +37,7 @@#include "exec/cpu_ldst.h" /* global register indexes */ -static TCGv_ptr cpu_env; +static TCGv_env cpu_env;#include "exec/gen-icount.h" #include "exec/helper-proto.h"
target-sh4/translate.c +1 -1
@@ -61,7 +61,7 @@ enum { };/* global register indexes */ -static TCGv_ptr cpu_env; +static TCGv_env cpu_env;static TCGv cpu_gregs[24 ];static TCGv cpu_sr, cpu_sr_m, cpu_sr_q, cpu_sr_t;static TCGv cpu_pc, cpu_ssr, cpu_spc, cpu_gbr;
target-sparc/translate.c +3 -2
@@ -39,7 +39,8 @@according to jump_pc[T2] */ /* global register indexes */ -static TCGv_ptr cpu_env, cpu_regwptr; +static TCGv_env cpu_env; +static TCGv_ptr cpu_regwptr;static TCGv cpu_cc_src, cpu_cc_src2, cpu_cc_dst;static TCGv_i32 cpu_cc_op;static TCGv_i32 cpu_psr;
@@ -2291,7 +2292,7 @@ static void gen_fmovq(DisasContext *dc, DisasCompare *cmp, int rd, int rs) }#ifndef CONFIG_USER_ONLY -static inline void gen_load_trap_state_at_tl (TCGv_ptr r_tsptr,TCGv_ptr cpu_env) +static inline void gen_load_trap_state_at_tl (TCGv_ptr r_tsptr,TCGv_env cpu_env) {TCGv_i32 r_tl =tcg_temp_new_i32 ();
target-tilegx/translate.c +1 -1
@@ -32,7 +32,7 @@#define FMT64X "%016" PRIx64 -static TCGv_ptr cpu_env; +static TCGv_env cpu_env;static TCGv cpu_pc;static TCGv cpu_regs[TILEGX_R_COUNT ];
target-tricore/translate.c +1 -1
@@ -47,7 +47,7 @@ static TCGv cpu_PSW_SV;static TCGv cpu_PSW_AV;static TCGv cpu_PSW_SAV;/* CPU env */ -static TCGv_ptr cpu_env; +static TCGv_env cpu_env;#include "exec/gen-icount.h"
target-unicore32/translate.c +1 -1
@@ -48,7 +48,7 @@ typedef struct DisasContext {conditional executions state has been updated. */ #define DISAS_SYSCALL 5 -static TCGv_ptr cpu_env; +static TCGv_env cpu_env;static TCGv_i32 cpu_R[32 ];/* FIXME: These should be removed. */
target-xtensa/translate.c +1 -1
@@ -74,7 +74,7 @@ typedef struct DisasContext {unsigned cpenable; } DisasContext; -static TCGv_ptr cpu_env; +static TCGv_env cpu_env;static TCGv_i32 cpu_pc;static TCGv_i32 cpu_R[16 ];static TCGv_i32 cpu_FR[16 ];
tcg/tcg.h +1 -0
@@ -308,6 +308,7 @@ typedef tcg_target_ulong TCGArg;typedef struct TCGv_i32_d *TCGv_i32 ;typedef struct TCGv_i64_d *TCGv_i64 ;typedef struct TCGv_ptr_d *TCGv_ptr ; +typedef TCGv_ptr TCGv_env ; static inline TCGv_i32 QEMU_ARTIFICIAL MAKE_TCGV_I32(intptr_t i) {
Quoted 21 lines · Lluís Vilanova
NOTE: This series should complete the framework for guest code tracing. From
here on, other series can concurrently add actual events and improve the guest code tracing features and performance (e.g., control tracing independently on each vCPU).This series introduces the "vcpu" property for tracing events. This property identifies events that are tied to a particular virtual CPU (e.g., executing an instruction).
Events with this property have an implicit vcpu argument, which is shown in the trace. In the case of events executed at TCG translation time, two implicit arguments are added:
* The vCPU performing the code translation (shown in the translation-time trace)
* The vCPU executing the translated code (shown in the execution-time trace)Note that the "vcpu" and "tcg" properties are not merged into a single one, since events can be defined that relate to a vCPU but are never raised from TCG code (e.g., interrupts).
Quoted 6 lines
Changes in v9
=============* Rebase on 774ae42.
* Fix CPUState typedef, and refactor into a separate patch [Stefan Hajnoczi].
* FixTCGv_cpu->TCGv_envrename in sparc [Stefan Hajnoczi].
[...]
Hi Stefan,
I know it's soft-freeze day, but did you have a chance to take a look at this series and the other two I sent on top? ("trace: Add events for vCPU memory accesses" and "trace: Per-vCPU tracing states").
Thanks a lot,
Lluis
Stefan Hajnoczi
AppliedQuoted 143 lines · Lluís Vilanova
NOTE: This series should complete the framework for guest code tracing. From
here on, other series can concurrently add actual events and improve the guest code tracing features and performance (e.g., control tracing independently on each vCPU).This series introduces the "vcpu" property for tracing events. This property identifies events that are tied to a particular virtual CPU (e.g., executing an instruction).
Events with this property have an implicit vcpu argument, which is shown in the trace. In the case of events executed at TCG translation time, two implicit arguments are added:
* The vCPU performing the code translation (shown in the translation-time trace)
* The vCPU executing the translated code (shown in the execution-time trace)Note that the "vcpu" and "tcg" properties are not merged into a single one, since events can be defined that relate to a vCPU but are never raised from TCG code (e.g., interrupts).
Changes in v9
=============* Rebase on 774ae42.
* Fix CPUState typedef, and refactor into a separate patch [Stefan Hajnoczi].
* FixTCGv_cpu->TCGv_envrename in sparc [Stefan Hajnoczi].Changes in v8
=============* Rebase on 1b16240.
* Minor fix in message formatting ('tracetool.vcpu' module).
* Fix management of event arguments with TCG types.
* Tested with various (non sent) events with different mixes of native and TCG arguments.Changes in v7
=============* Fix the modified event copying code.
* Minor fix in commit message for patch 3.Changes in v6
=============* Rebase on 84c0781.
* Replace the added 'TCGv_cpu' type for 'TCGv_env', since the users are really pointing to 'CPUArchState'.
* Add functions to simplify event argument management.
* Add minor event copy cleanup (remove long "event.original.original" chains).
* Make it easier to change arguments injected by the 'vcpu' property.Changes in v5
=============* Rebase on 357e81c.
* Split from the previous (larger and more complex) v4 series.Changes in v4
=============* Fix typo in commit message (Stefan Hajnoczi).
* Simplify per-vCPU tracing state initialization (Stefan Hajnoczi).
* Update copyright years.Changes in v3
=============* Update QAPI version (Eric Blake).
* Fix '#optional' annotation in QAPI (Eric Blake).Changes in v2
=============* Rebase on 5522a84.
* Improve patch descriptions.
* Refactor code generation into a separate patch.
* Fix forward declarations (Stefan Hajnoczi & Eduardo Habkost).
* Fix "since" tags in QAPI interface (Eric Blake).
* Unify QAPI/QMP interface with an optional 'vcpu' argument (Eric Blake).
* Fix QMP+GTK header workaround (Stefan Hajnoczi).Signed-off-by Lluís Vilanova <[email protected]>---
Lluís Vilanova (7):
trace: Extend API to manage event arguments
trace: Remove unnecessary intermediate event copies
tcg: Add type for vCPU pointers
tcg: Move definition of type TCGv
[trivial] trace: Add helper function to cast event arguments
typedefs: Add CPUState
trace: Add 'vcpu' event property to trace guest vCPUdocs/tracing.txt | 41 +++++++++++++ include/qemu/typedefs.h | 1 include/qom/cpu.h | 1 scripts/tracetool/__init__.py | 35 +++++++++-- scripts/tracetool/format/events_h.py | 4 + scripts/tracetool/format/h.py | 3 + scripts/tracetool/format/tcg_h.py | 33 +++++++--- scripts/tracetool/format/tcg_helper_c.py | 45 +++++++++++--- scripts/tracetool/format/tcg_helper_h.py | 7 +- scripts/tracetool/format/tcg_helper_wrapper_h.py | 5 +- scripts/tracetool/format/ust_events_c.py | 1 scripts/tracetool/transform.py | 4 + scripts/tracetool/vcpu.py | 70 ++++++++++++++++++++++ stubs/target-get-monitor-def.c | 3 - target-alpha/translate.c | 2 - target-arm/translate.c | 2 - target-arm/translate.h | 2 - target-cris/translate.c | 2 - target-i386/translate.c | 2 - target-lm32/translate.c | 2 - target-m68k/translate.c | 2 - target-microblaze/translate.c | 2 - target-mips/translate.c | 2 - target-moxie/translate.c | 2 - target-openrisc/translate.c | 2 - target-ppc/translate.c | 2 - target-s390x/translate.c | 2 - target-sh4/translate.c | 2 - target-sparc/translate.c | 5 +- target-tilegx/translate.c | 2 - target-tricore/translate.c | 2 - target-unicore32/translate.c | 2 - target-xtensa/translate.c | 2 - tcg/tcg-op.h | 2 - tcg/tcg.h | 8 +++ trace/control.h | 3 + 36 files changed, 242 insertions(+), 65 deletions(-) create mode 100644 scripts/tracetool/vcpu.py
Quoted 6 lines
To: [email protected]
Cc: Stefan Hajnoczi <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: Eric Blake <[email protected]>
Cc: Alex Bennée <[email protected]>
Thanks, applied to my tracing tree:
https://github.com/stefanha/qemu/commits/tracing
Stefan