[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 09/12] trace: [tcg] Generate TCG tracing routines
From: |
Lluís Vilanova |
Subject: |
[Qemu-devel] [PATCH 09/12] trace: [tcg] Generate TCG tracing routines |
Date: |
Fri, 31 Jan 2014 17:09:52 +0100 |
User-agent: |
StGit/0.16 |
Generate header "trace/generated-tcg-tracers.h" with the necessary routines for
tracing events in guest code:
* trace_${event}_tcg
A shorter routine name to call the 'gen_helper_trace_${event}_tcg' routine.
Makes the coding more similar to that of "trace.h", where "trace_*_tcg" is a
common routine name to clearly denote a TCG tracing action.
NOTE: These routines will be renamed to 'trace_${event}_tcg_backend' when TCG
instrumentation is added.
Signed-off-by: Lluís Vilanova <address@hidden>
---
.gitignore | 1 +
Makefile | 2 ++
include/trace-tcg.h | 7 ++++++
scripts/tracetool/backend/tcg.py | 17 +++++++++++++
scripts/tracetool/format/tcg_h.py | 47 +++++++++++++++++++++++++++++++++++++
trace/Makefile.objs | 9 +++++++
6 files changed, 83 insertions(+)
create mode 100644 include/trace-tcg.h
create mode 100644 scripts/tracetool/format/tcg_h.py
diff --git a/.gitignore b/.gitignore
index 418546c..858a5cb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,6 +12,7 @@ trace/generated-events.h
trace/generated-events.c
trace/generated-helpers.h
trace/generated-helpers.c
+trace/generated-tcg-tracers.h
libcacard/trace/generated-tracers.c
*-timestamp
*-softmmu
diff --git a/Makefile b/Makefile
index 910fb4f..3100439 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-tcg-tracers.h
+
GENERATED_HEADERS += trace/generated-helpers.h
GENERATED_SOURCES += trace/generated-helpers.c
diff --git a/include/trace-tcg.h b/include/trace-tcg.h
new file mode 100644
index 0000000..6f6bdbb
--- /dev/null
+++ b/include/trace-tcg.h
@@ -0,0 +1,7 @@
+#ifndef TRACE_TCG_H
+#define TRACE_TCG_H
+
+#include "trace/generated-tcg-tracers.h"
+#include "trace/generated-events.h"
+
+#endif /* TRACE_TCG_H */
diff --git a/scripts/tracetool/backend/tcg.py b/scripts/tracetool/backend/tcg.py
index b60fb7e..359e5f5 100644
--- a/scripts/tracetool/backend/tcg.py
+++ b/scripts/tracetool/backend/tcg.py
@@ -106,3 +106,20 @@ def tcg_helper_c(events):
args=e.args.transform(HOST_2_TCG_COMPAT, TCG_2_HOST),
values=", ".join(values),
)
+
+
+def tcg_h(events):
+ for e in events:
+ if "tcg" not in e.properties:
+ continue
+
+ e = e.original
+
+ out('static inline void %(name)s(%(args)s)',
+ '{',
+ ' gen_helper_%(name)s(%(argnames)s);',
+ '}',
+ name=e.api(e.QEMU_TRACE_TCG),
+ args=e.args,
+ argnames=", ".join(e.args.names()),
+ )
diff --git a/scripts/tracetool/format/tcg_h.py
b/scripts/tracetool/format/tcg_h.py
new file mode 100644
index 0000000..58e992e
--- /dev/null
+++ b/scripts/tracetool/format/tcg_h.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""
+Generate .h file for TCG code generation.
+"""
+
+__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. */',
+ '/* You must include this file after the inclusion of helper.h */',
+ '',
+ '#ifndef TRACE__GENERATED_TCG_TRACERS_H',
+ '#define TRACE__GENERATED_TCG_TRACERS_H',
+ '',
+ '#include <stdint.h>',
+ '',
+ )
+
+
+def end(events):
+ out('#endif /* TRACE__GENERATED_TCG_TRACERS_H */')
+
+
+def nop(events):
+ for e in events:
+ if "tcg" not in e.properties:
+ continue
+
+ e = e.original
+
+ out('static inline void %(name)s(%(args)s)',
+ '{',
+ '}',
+ name=e.api(e.QEMU_TRACE_TCG),
+ args=e.args,
+ )
diff --git a/trace/Makefile.objs b/trace/Makefile.objs
index de7e9a4..0056aec 100644
--- a/trace/Makefile.objs
+++ b/trace/Makefile.objs
@@ -96,6 +96,15 @@ $(obj)/generated-helpers.o: $(obj)/generated-helpers.c
target-obj-y += generated-helpers.o
+$(obj)/generated-tcg-tracers.h: $(obj)/generated-tcg-tracers.h-timestamp
+$(obj)/generated-tcg-tracers.h-timestamp: $(SRC_PATH)/trace-events
$(BUILD_DIR)/config-host.mak
+ $(call quiet-command,$(TRACETOOL) \
+ --format=tcg-h \
+ --backend=tcg \
+ < $< > $@," GEN $(patsubst %-timestamp,%,$@)")
+ @cmp -s $@ $(patsubst %-timestamp,%,$@) || cp $@ $(patsubst
%-timestamp,%,$@)
+
+
######################################################################
# 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, 2014/01/31
- [Qemu-devel] [PATCH 09/12] trace: [tcg] Generate TCG tracing routines,
Lluís Vilanova <=
- [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