NOTE: TCG code for execution-time event tracing is always generated, regardless of wether the event has been dynamically disabled or not (unless the event has the static "disable" property).
This approach keeps this series simple, and a future series will handle the case of having per-CPU tracing states for these events, and only generate the code if the event is dynamicaly enabled. Adds the base ability to specify which events in the "trace-events" file may be used to trace guest activity in the TCG code (using the "tcg" event propery). An event with that property actually generates two independent events "${name}_trans" and "${name}_exec", and a set of conveniency functions. Having two events allows us to trace both translation and execution of guest code (e.g., generating vs executing a basic block). See the first patch for more information on its usage. Files generating guest code (TCG) must include "trace-tcg.h". Files declaring per-target helpers ("${target}/helper.h") must include "trace/generated-helpers.h". The flow of the generated routines is (conveniency wrappers are inlined): [At translation time] * trace_${name}_tcg(bool, TCGv) Declared: "trace/generated-tcg-tracers.h" Defined : "trace/generated-tcg-tracers.h" Invokes "trace_${name}_trans" (with all non-TCG arguments) and "gen_helper_trace_${name}_exec" (with all arguments). * trace_${name}_trans(bool) Declared: "trace/generated-tracers.h" Defined : "trace/generated-tracers.h" Invokes the actual tracing backends for the translation-time event. * gen_helper_trace_${name}_exec(bool, TCGv) Declared: "trace/generated-helpers.h" Defined : "trace/generated-helpers.h" Conveniency wrapper that will allocate (and free) TCG temporaries for all non-TCG arguments before calling "gen_helper_trace_${name}_exec_proxy". * gen_helper_trace_${name}_exec_proxy(TCGi32, TCGv) Declared: "trace/generated-helpers.h" Defined : "trace/generated-helpers.h" (using helper machinery) The actual TCG helper function, created using QEMU's TCG helper machinery. [At execution time] * helper_trace_${name}_exec_proxy(uint32_t, uint64_t) Declared: "trace/generated-helpers.h" Defined : "trace/generated-helpers.c" Conveniency wrapper that casts arguments to the appropriate type before calling "trace_${name}_exec". This is necessary because TCG helpers can only receive a limited number of argument types (e.g., must use 'uint32_t' instead of 'bool'). * trace_${name}_exec(bool, uint64_t) Declared: "trace/generated-tracers.h" Defined : "trace/generated-tracers.h" Invokes the actual tracing backends for the execution-time event. Signed-off-by: Lluís Vilanova <vilan...@ac.upc.edu> --- Changes in v3: * None (re-send with cover). Changes in v2: * Split the guest memory access event out of this series. * Generate two independent events from each "tcg" event (one for translation-time events and one for execution-time events). Lluís Vilanova (10): trace: [tcg] Add documentation trace: [tcg] Argument type transformation rules trace: [tcg] Argument type transformation machinery trace: [tcg] Add 'tcg' event property trace: [tcg] Declare TCG tracing helper routines trace: [tcg] Define TCG tracing helper routines trace: [tcg] Include TCG-tracing helpers on all helper.h trace: [tcg] Generate TCG tracing routines trace: [tcg] Include event definitions in "trace.h" trace: [tcg] Include TCG-tracing header on all targets .gitignore | 3 + Makefile | 5 + Makefile.objs | 7 + Makefile.target | 5 + docs/tracing.txt | 40 +++++++ include/exec/def-helper.h | 9 ++ include/trace-tcg.h | 7 + include/trace.h | 1 scripts/tracetool/__init__.py | 95 ++++++++++++++++- scripts/tracetool/format/events_h.py | 5 + scripts/tracetool/format/tcg_h.py | 56 ++++++++++ scripts/tracetool/format/tcg_helper_c.py | 51 +++++++++ scripts/tracetool/format/tcg_helper_h.py | 91 ++++++++++++++++ scripts/tracetool/transform.py | 166 ++++++++++++++++++++++++++++++ target-alpha/helper.h | 2 target-alpha/translate.c | 3 + target-arm/helper.h | 2 target-arm/translate-a64.c | 2 target-arm/translate.c | 3 + target-cris/helper.h | 2 target-cris/translate.c | 3 + target-i386/helper.h | 2 target-i386/translate.c | 3 + target-lm32/helper.h | 2 target-lm32/translate.c | 3 + target-m68k/helper.h | 2 target-m68k/translate.c | 3 + target-microblaze/helper.h | 2 target-microblaze/translate.c | 3 + target-mips/helper.h | 2 target-mips/translate.c | 3 + target-moxie/helper.h | 2 target-openrisc/helper.h | 2 target-openrisc/translate.c | 3 + target-ppc/helper.h | 2 target-ppc/translate.c | 3 + target-s390x/helper.h | 2 target-s390x/translate.c | 2 target-sh4/helper.h | 2 target-sh4/translate.c | 3 + target-sparc/helper.h | 2 target-sparc/translate.c | 3 + target-unicore32/helper.h | 2 target-unicore32/translate.c | 3 + target-xtensa/helper.h | 2 target-xtensa/translate.c | 3 + trace/Makefile.objs | 45 +++++++- 47 files changed, 652 insertions(+), 12 deletions(-) create mode 100644 include/trace-tcg.h create mode 100644 scripts/tracetool/format/tcg_h.py create mode 100644 scripts/tracetool/format/tcg_helper_c.py create mode 100644 scripts/tracetool/format/tcg_helper_h.py create mode 100644 scripts/tracetool/transform.py To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi <stefa...@redhat.com> Cc: Richard Henderson <r...@twiddle.net> Cc: Peter Maydell <peter.mayd...@linaro.org>