[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 07/12] trace: [tcg] Define TCG tracing helper routin
From: |
Lluís Vilanova |
Subject: |
[Qemu-devel] [PATCH 07/12] trace: [tcg] Define TCG tracing helper routines |
Date: |
Fri, 31 Jan 2014 17:09:41 +0100 |
User-agent: |
StGit/0.16 |
Generate file "trace/generated-helpers.c" with the necessary TCG helper routines
for tracing events in guest code:
* helper_trace_${event}_tcg_proxy
TCG helper implementation to cast TCG-compatible argument types to native
types and call tracing routine 'trace_${event}'.
Signed-off-by: Lluís Vilanova <address@hidden>
---
.gitignore | 1 +
Makefile | 1 +
Makefile.objs | 8 +++++++-
Makefile.target | 1 +
scripts/tracetool/backend/tcg.py | 23 +++++++++++++++++++++++
scripts/tracetool/format/tcg_helper_c.py | 27 +++++++++++++++++++++++++++
trace/Makefile.objs | 12 ++++++++++++
7 files changed, 72 insertions(+), 1 deletion(-)
create mode 100644 scripts/tracetool/format/tcg_helper_c.py
diff --git a/.gitignore b/.gitignore
index 8e61ca1..418546c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,6 +11,7 @@ trace/generated-tracers.dtrace
trace/generated-events.h
trace/generated-events.c
trace/generated-helpers.h
+trace/generated-helpers.c
libcacard/trace/generated-tracers.c
*-timestamp
*-softmmu
diff --git a/Makefile b/Makefile
index d1ec29b..910fb4f 100644
--- a/Makefile
+++ b/Makefile
@@ -58,6 +58,7 @@ endif
GENERATED_SOURCES += trace/generated-tracers.c
GENERATED_HEADERS += trace/generated-helpers.h
+GENERATED_SOURCES += trace/generated-helpers.c
# Don't try to regenerate Makefile or configure
# We don't generate any of them
diff --git a/Makefile.objs b/Makefile.objs
index ac1d0e1..c9570de 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -1,7 +1,7 @@
#######################################################################
# Common libraries for tools and emulators
stub-obj-y = stubs/
-util-obj-y = util/ qobject/ qapi/ trace/
+util-obj-y = util/ qobject/ qapi/
#######################################################################
# block-obj-y is code used by both qemu system emulation and qemu-img
@@ -105,6 +105,11 @@ version-obj-$(CONFIG_WIN32) += $(BUILD_DIR)/version.o
version-lobj-$(CONFIG_WIN32) += $(BUILD_DIR)/version.lo
######################################################################
+# tracing
+util-obj-y += trace/
+target-obj-y += trace/
+
+######################################################################
# guest agent
# FIXME: a few definitions from qapi-types.o/qapi-visit.o are needed
@@ -124,5 +129,6 @@ nested-vars += \
qga-obj-y \
qga-vss-dll-obj-y \
block-obj-y \
+ target-obj-y \
common-obj-y
dummy := $(call unnest-vars)
diff --git a/Makefile.target b/Makefile.target
index af6ac7e..43896ee 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -145,6 +145,7 @@ nested-vars += obj-y
include $(SRC_PATH)/Makefile.objs
all-obj-y = $(obj-y)
+all-obj-y += $(target-obj-y)
all-obj-y += $(addprefix ../, $(common-obj-y))
ifndef CONFIG_HAIKU
diff --git a/scripts/tracetool/backend/tcg.py b/scripts/tracetool/backend/tcg.py
index 04aa2b8..b60fb7e 100644
--- a/scripts/tracetool/backend/tcg.py
+++ b/scripts/tracetool/backend/tcg.py
@@ -17,6 +17,10 @@ from tracetool import out
from tracetool.transform import *
+# get the actual set of rules for this backend
+TCG_2_HOST = TCG_2_HOST("tcg")
+
+
def tcg_helper_h(events):
out('#define tcg_temp_new_nop(v) (v)',
'#define tcg_temp_free_nop(v)',
@@ -83,3 +87,22 @@ def tcg_helper_h(events):
code_free="\n ".join(code_free),
tmp_names=", ".join(["__%s" % name for _, name in e.args]),
)
+
+
+def tcg_helper_c(events):
+ events = (e for e in events
+ if "tcg" in e.properties)
+
+ for e in events:
+ values = ["(%s)%s" % (t, n)
+ for t, n in e.args.transform(TCG_2_HOST)]
+
+ out('void %(name_tcg)s(%(args)s)',
+ '{',
+ ' %(name)s(%(values)s);',
+ '}',
+ name_tcg="helper_%s_proxy" % e.api(e.QEMU_TRACE_TCG),
+ name=e.api(e.QEMU_TRACE),
+ args=e.args.transform(HOST_2_TCG_COMPAT, TCG_2_HOST),
+ values=", ".join(values),
+ )
diff --git a/scripts/tracetool/format/tcg_helper_c.py
b/scripts/tracetool/format/tcg_helper_c.py
new file mode 100644
index 0000000..a3540a6
--- /dev/null
+++ b/scripts/tracetool/format/tcg_helper_c.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""
+Generate trace/generated-helpers.c.
+"""
+
+__author__ = "Lluís Vilanova <address@hidden>"
+__copyright__ = "Copyright 2012-2014, Lluís Vilanova <address@hidden>"
+__license__ = "GPL version 2 or (at your option) any later version"
+
+__maintainer__ = "Stefan Hajnoczi"
+__email__ = "address@hidden"
+
+
+from tracetool import out
+
+
+def begin(events):
+ out('/* This file is autogenerated by tracetool, do not edit. */',
+ '',
+ '#include "qemu-common.h"',
+ '#define TRACE_TCG_HELPER',
+ '#include "trace.h"',
+ '#include "helper.h"',
+ '',
+ )
diff --git a/trace/Makefile.objs b/trace/Makefile.objs
index c2a0ac0..de7e9a4 100644
--- a/trace/Makefile.objs
+++ b/trace/Makefile.objs
@@ -83,6 +83,18 @@ $(obj)/generated-helpers.h-timestamp:
$(SRC_PATH)/trace-events $(BUILD_DIR)/conf
< $< > $@," GEN $(patsubst %-timestamp,%,$@)")
@cmp -s $@ $(patsubst %-timestamp,%,$@) || cp $@ $(patsubst
%-timestamp,%,$@)
+$(obj)/generated-helpers.c: $(obj)/generated-helpers.c-timestamp
+$(obj)/generated-helpers.c-timestamp: $(SRC_PATH)/trace-events
$(BUILD_DIR)/config-host.mak
+ $(call quiet-command,$(TRACETOOL) \
+ --format=tcg-helper-c \
+ --backend=tcg \
+ < $< > $@," GEN $(patsubst %-timestamp,%,$@)")
+ @cmp -s $@ $(patsubst %-timestamp,%,$@) || cp $@ $(patsubst
%-timestamp,%,$@)
+
+$(obj)/generated-helpers.o: $(obj)/generated-helpers.c
+
+target-obj-y += generated-helpers.o
+
######################################################################
# Backend code
- [Qemu-devel] [PATCH 00/12] trace: [tcg] Allow tracing guest events in TCG-generated code, Lluís Vilanova, 2014/01/31
- [Qemu-devel] [PATCH 01/12] trace: [tcg] Add documentation, Lluís Vilanova, 2014/01/31
- [Qemu-devel] [PATCH 02/12] trace: [tracetool, tcg] Allow TCG types in trace event declarations, Lluís Vilanova, 2014/01/31
- [Qemu-devel] [PATCH 03/12] trace: [tracetool] Add method 'Event.api' to get the name of public routines, Lluís Vilanova, 2014/01/31
- [Qemu-devel] [PATCH 04/12] trace: [tracetool, tcg] Provide TCG-related type transformation rules, Lluís Vilanova, 2014/01/31
- [Qemu-devel] [PATCH 05/12] trace: [tracetool] Allow argument types to be transformed, Lluís Vilanova, 2014/01/31
- [Qemu-devel] [PATCH 06/12] trace: [tcg] Declare TCG tracing helper routines, Lluís Vilanova, 2014/01/31
- [Qemu-devel] [PATCH 07/12] trace: [tcg] Define TCG tracing helper routines,
Lluís Vilanova <=
- [Qemu-devel] [PATCH 09/12] trace: [tcg] Generate TCG tracing routines, Lluís Vilanova, 2014/01/31
- [Qemu-devel] [PATCH 10/12] trace: [trivial] Include event definitions in "trace.h", Lluís Vilanova, 2014/01/31
- [Qemu-devel] [PATCH 12/12] trace: [all] Add "guest_vmem" event, Lluís Vilanova, 2014/01/31
- [Qemu-devel] [PATCH 11/12] trace: [tcg] Include TCG-tracing header on all targets, Lluís Vilanova, 2014/01/31
- [Qemu-devel] [PATCH 08/12] trace: [tcg] Include TCG-tracing helpers on all helper.h, Lluís Vilanova, 2014/01/31