qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v2 06/10] trace: [tcg] Define TCG tracing helper rou


From: Lluís Vilanova
Subject: [Qemu-devel] [PATCH v2 06/10] trace: [tcg] Define TCG tracing helper routines
Date: Wed, 28 May 2014 19:32:06 +0200
User-agent: StGit/0.17.1-dirty

Generate file "trace/generated-helpers.c" with the necessary TCG helper routines
for tracing events in guest code at execution time:

* helper_trace_${event}_exec_proxy

  TCG helper implementation to cast TCG-compatible argument types to native
  types and call tracing routine 'trace_${event}_exec'.


Signed-off-by: Lluís Vilanova <address@hidden>
---
 .gitignore                               |    1 +
 Makefile                                 |    1 +
 Makefile.objs                            |    7 ++++
 Makefile.target                          |    5 +++
 scripts/tracetool/format/tcg_helper_c.py |   51 ++++++++++++++++++++++++++++++
 trace/Makefile.objs                      |   12 +++++++
 6 files changed, 76 insertions(+), 1 deletion(-)
 create mode 100644 scripts/tracetool/format/tcg_helper_c.py

diff --git a/.gitignore b/.gitignore
index 7750e3e..e5d4847 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,6 +11,7 @@
 /trace/generated-events.h
 /trace/generated-events.c
 /trace/generated-helpers.h
+/trace/generated-helpers.c
 /trace/generated-ust-provider.h
 /trace/generated-ust.c
 /libcacard/trace/generated-tracers.c
diff --git a/Makefile b/Makefile
index e3ac3fd..8544290 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
 
 ifeq ($(findstring ust,$(TRACE_BACKENDS)),ust)
 GENERATED_HEADERS += trace/generated-ust-provider.h
diff --git a/Makefile.objs b/Makefile.objs
index b897e1d..4e0dea7 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
@@ -107,6 +107,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
diff --git a/Makefile.target b/Makefile.target
index 8155496..edafa35 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -145,15 +145,20 @@ endif # CONFIG_SOFTMMU
 dummy := $(call unnest-vars,,obj-y)
 all-obj-y := $(obj-y)
 
+target-obj-y :=
 block-obj-y :=
 common-obj-y :=
 include $(SRC_PATH)/Makefile.objs
+dummy := $(call unnest-vars,,target-obj-y)
+target-obj-y-save := $(target-obj-y)
 dummy := $(call unnest-vars,.., \
                block-obj-y \
                block-obj-m \
                common-obj-y \
                common-obj-m)
+target-obj-y := $(target-obj-y-save)
 all-obj-y += $(common-obj-y)
+all-obj-y += $(target-obj-y)
 all-obj-$(CONFIG_SOFTMMU) += $(block-obj-y)
 
 ifndef CONFIG_HAIKU
diff --git a/scripts/tracetool/format/tcg_helper_c.py 
b/scripts/tracetool/format/tcg_helper_c.py
new file mode 100644
index 0000000..d4e2823
--- /dev/null
+++ b/scripts/tracetool/format/tcg_helper_c.py
@@ -0,0 +1,51 @@
+#!/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
+from tracetool.transform import *
+
+
+def generate(events, backend):
+    events = [e for e in events
+              if "disable" not in e.properties]
+
+    out('/* This file is autogenerated by tracetool, do not edit. */',
+        '',
+        '#include "qemu-common.h"',
+        '#define TRACE_TCG_HELPER',
+        '#include "trace.h"',
+        '#include "helper.h"',
+        '',
+        )
+
+    for e in events:
+        if "tcg-exec" not in e.properties:
+            continue
+
+        # tracetool.generate always transforms types to host
+        e_args = e.original.args
+
+        values = ["(%s)%s" % (t, n)
+                  for t, n in e.args.transform(TCG_2_TCG_HELPER_DEF)]
+
+        out('void %(name_tcg)s(%(args)s)',
+            '{',
+            '    %(name)s(%(values)s);',
+            '}',
+            name_tcg="helper_%s_proxy" % e.api(),
+            name=e.api(),
+            args=e_args.transform(HOST_2_TCG_COMPAT, TCG_2_TCG_HELPER_DEF),
+            values=", ".join(values),
+            )
diff --git a/trace/Makefile.objs b/trace/Makefile.objs
index 0a2e6cd..2d36142 100644
--- a/trace/Makefile.objs
+++ b/trace/Makefile.objs
@@ -107,6 +107,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=$(TRACE_BACKENDS) \
+               < $< > $@,"  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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]