qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Lluís Vilanova" <vilanova@ac.upc.edu>,
	"Stefan Hajnoczi" <stefanha@redhat.com>
Subject: [Qemu-devel] [PULL 09/18] trace: [tcg] Declare TCG tracing helper routines
Date: Tue, 12 Aug 2014 14:37:46 +0100	[thread overview]
Message-ID: <1407850675-11890-10-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1407850675-11890-1-git-send-email-stefanha@redhat.com>

From: Lluís Vilanova <vilanova@ac.upc.edu>

Generates file "trace/generated-helpers.h" with TCG helper declarations to trace
events in guest code at execution time ('trace_${event}_exec_proxy').

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 .gitignore                               |  1 +
 Makefile                                 |  2 ++
 scripts/tracetool/__init__.py            |  1 +
 scripts/tracetool/format/tcg_helper_h.py | 50 ++++++++++++++++++++++++++++++++
 trace/Makefile.objs                      | 24 +++++++++++----
 5 files changed, 73 insertions(+), 5 deletions(-)
 create mode 100644 scripts/tracetool/format/tcg_helper_h.py

diff --git a/.gitignore b/.gitignore
index 2286d0a..da56d70 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-ust-provider.h
 /trace/generated-ust.c
 /libcacard/trace/generated-tracers.c
diff --git a/Makefile b/Makefile
index d6b9dc1..84e9ad4 100644
--- a/Makefile
+++ b/Makefile
@@ -57,6 +57,8 @@ GENERATED_HEADERS += trace/generated-tracers-dtrace.h
 endif
 GENERATED_SOURCES += trace/generated-tracers.c
 
+GENERATED_HEADERS += trace/generated-helpers.h
+
 ifeq ($(findstring ust,$(TRACE_BACKENDS)),ust)
 GENERATED_HEADERS += trace/generated-ust-provider.h
 GENERATED_SOURCES += trace/generated-ust.c
diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
index de48c80..a51e0f2 100644
--- a/scripts/tracetool/__init__.py
+++ b/scripts/tracetool/__init__.py
@@ -227,6 +227,7 @@ class Event(object):
                                           fmt)
 
     QEMU_TRACE               = "trace_%(name)s"
+    QEMU_TRACE_TCG           = QEMU_TRACE + "_tcg"
 
     def api(self, fmt=None):
         if fmt is None:
diff --git a/scripts/tracetool/format/tcg_helper_h.py b/scripts/tracetool/format/tcg_helper_h.py
new file mode 100644
index 0000000..a8ba7ba
--- /dev/null
+++ b/scripts/tracetool/format/tcg_helper_h.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""
+Generate trace/generated-helpers.h.
+"""
+
+__author__     = "Lluís Vilanova <vilanova@ac.upc.edu>"
+__copyright__  = "Copyright 2012-2014, Lluís Vilanova <vilanova@ac.upc.edu>"
+__license__    = "GPL version 2 or (at your option) any later version"
+
+__maintainer__ = "Stefan Hajnoczi"
+__email__      = "stefanha@linux.vnet.ibm.com"
+
+
+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. */',
+        '',
+        )
+
+    for e in events:
+        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)"
+        args = e_args.transform(HOST_2_TCG_COMPAT, HOST_2_TCG,
+                                TCG_2_TCG_HELPER_DECL)
+        types = ", ".join(args.types())
+        if types != "":
+            types = ", " + types
+
+        flags = "TCG_CALL_NO_RWG, "
+
+        out(fmt,
+            flags=flags,
+            argc=len(args),
+            name=e.api() + "_proxy",
+            types=types,
+            )
diff --git a/trace/Makefile.objs b/trace/Makefile.objs
index d7a8696..0a2e6cd 100644
--- a/trace/Makefile.objs
+++ b/trace/Makefile.objs
@@ -49,6 +49,9 @@ util-obj-y += generated-events.o
 ######################################################################
 # Auto-generated tracing routines
 
+##################################################
+# Execution level
+
 $(obj)/generated-tracers.h: $(obj)/generated-tracers.h-timestamp
 	@cmp -s $< $@ || cp $< $@
 $(obj)/generated-tracers.h-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak
@@ -57,8 +60,8 @@ $(obj)/generated-tracers.h-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/conf
 		--backends=$(TRACE_BACKENDS) \
 		< $< > $@,"  GEN   $(patsubst %-timestamp,%,$@)")
 
-######################################################################
-# Auto-generated tracing routines (non-DTrace)
+##############################
+# non-DTrace
 
 $(obj)/generated-tracers.c: $(obj)/generated-tracers.c-timestamp
 	@cmp -s $< $@ || cp $< $@
@@ -70,9 +73,8 @@ $(obj)/generated-tracers.c-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/conf
 
 $(obj)/generated-tracers.o: $(obj)/generated-tracers.c $(obj)/generated-tracers.h
 
-
-######################################################################
-# Auto-generated DTrace code
+##############################
+# DTrace
 
 # Normal practice is to name DTrace probe file with a '.d' extension
 # but that gets picked up by QEMU's Makefile as an external dependency
@@ -94,6 +96,18 @@ $(obj)/generated-tracers-dtrace.o: $(obj)/generated-tracers-dtrace.dtrace
 util-obj-y += generated-tracers-dtrace.o
 endif
 
+##################################################
+# Translation level
+
+$(obj)/generated-helpers.h: $(obj)/generated-helpers.h-timestamp
+$(obj)/generated-helpers.h-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak
+	$(call quiet-command,$(TRACETOOL) \
+		--format=tcg-helper-h \
+		--backend=$(TRACE_BACKENDS) \
+		< $< > $@,"  GEN   $(patsubst %-timestamp,%,$@)")
+	@cmp -s $@ $(patsubst %-timestamp,%,$@) || cp $@ $(patsubst %-timestamp,%,$@)
+
+
 ######################################################################
 # Backend code
 
-- 
1.9.3

  parent reply	other threads:[~2014-08-12 13:38 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-12 13:37 [Qemu-devel] [PULL 00/18] Tracing patches Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 01/18] trace: extract stap_escape() function for reuse Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 02/18] trace: add tracetool simpletrace_stap format Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 03/18] simpletrace: add simpletrace.py --no-header option Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 04/18] trace: install simpletrace SystemTap tapset Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 05/18] trace: [tcg] Add documentation Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 06/18] trace: [tcg] Argument type transformation rules Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 07/18] trace: [tcg] Argument type transformation machinery Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 08/18] trace: [tcg] Add 'tcg' event property Stefan Hajnoczi
2014-08-12 13:37 ` Stefan Hajnoczi [this message]
2014-08-12 13:37 ` [Qemu-devel] [PULL 10/18] trace: [tcg] Define TCG tracing helper routines Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 11/18] trace: [tcg] Define TCG tracing helper routine wrappers Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 12/18] trace: [tcg] Include TCG-tracing helpers Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 13/18] trace: [tcg] Generate TCG tracing routines Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 14/18] trace: [tcg] Include event definitions in "trace.h" Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 15/18] trace: [tcg] Include TCG-tracing header on all targets Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 16/18] trace: teach lttng backend to use format strings Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 17/18] trace: add some tcg tracing support Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 18/18] virtio-rng: add some trace events Stefan Hajnoczi
2014-08-15 16:43 ` [Qemu-devel] [PULL 00/18] Tracing patches Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1407850675-11890-10-git-send-email-stefanha@redhat.com \
    --to=stefanha@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vilanova@ac.upc.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).