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).
Such events generate an extra set of tracing functions that can be called during TCG code generation and will automatically redirect a call to the appropriate backend-dependent tracing functions when the guest code is executed. 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: [At translation time] * trace_${name}_tcg(bool, TCGv) Declared: "trace/generated-tcg-tracers.h" Defined : "trace/generated-tcg-tracers.h" * gen_helper_trace_${name}_tcg(bool, TCGv) Declared: "trace/generated-helpers.h" Defined : "trace/generated-helpers.h" Automatically transforms all the arguments and allocates them into the appropriate TCG temporary values (which are also freed). Provides a more streamlined interface by allowing events in "trace-events" to take a mix of tracing-supported types and TCG types. * gen_helper_trace_${name}_tcg_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}_tcg_proxy(uint32_t, uint64_t) Declared: "trace/generated-helpers.h" Defined : "trace/generated-helpers.c" Performs the appropriate argument type casts to match the signature of the callee. * trace_${name}(bool, uint64_t) The already-existing tracing function. Signed-off-by: Lluís Vilanova <vilan...@ac.upc.edu> --- Lluís Vilanova (12): trace: [tcg] Add documentation trace: [tracetool,tcg] Allow TCG types in trace event declarations trace: [tracetool] Add method 'Event.api' to get the name of public routines trace: [tracetool,tcg] Provide TCG-related type transformation rules trace: [tracetool] Allow argument types to be transformed 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: [trivial] Include event definitions in "trace.h" trace: [tcg] Include TCG-tracing header on all targets trace: [all] Add "guest_vmem" event .gitignore | 3 + Makefile | 5 + Makefile.objs | 8 +- Makefile.target | 1 docs/tracing.txt | 36 +++++++ include/exec/cpu-all.h | 58 ++++++----- include/exec/def-helper.h | 9 ++ include/exec/exec-all.h | 3 + include/exec/softmmu_header.h | 17 +++ include/trace-tcg.h | 7 + include/trace.h | 1 scripts/tracetool/__init__.py | 49 +++++++++ scripts/tracetool/backend/dtrace.py | 6 + scripts/tracetool/backend/simple.py | 10 +- scripts/tracetool/backend/stderr.py | 5 + scripts/tracetool/backend/tcg.py | 125 ++++++++++++++++++++++++ scripts/tracetool/backend/ust.py | 8 +- scripts/tracetool/format/h.py | 6 + scripts/tracetool/format/tcg_h.py | 47 +++++++++ scripts/tracetool/format/tcg_helper_c.py | 27 +++++ scripts/tracetool/format/tcg_helper_h.py | 38 +++++++ scripts/tracetool/transform.py | 157 ++++++++++++++++++++++++++++++ target-alpha/helper.h | 2 target-alpha/translate.c | 3 + target-arm/helper.h | 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-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 + tcg/tcg-op.h | 8 ++ tcg/tcg.c | 1 trace-events | 15 +++ trace/Makefile.objs | 45 ++++++++- trace/tcg-op-internal.h | 55 +++++++++++ 57 files changed, 771 insertions(+), 53 deletions(-) create mode 100644 include/trace-tcg.h create mode 100644 scripts/tracetool/backend/tcg.py 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 create mode 100644 trace/tcg-op-internal.h