From: "Lluís Vilanova" <vilanova@ac.upc.edu>
To: qemu-devel@nongnu.org
Cc: blauwirbel@gmail.com, stefanha@gmail.com
Subject: [Qemu-devel] [PATCH v3 1/6] trace: Provide a generic tracing event descriptor
Date: Fri, 10 Feb 2012 15:28:38 +0100 [thread overview]
Message-ID: <20120210142837.13518.106.stgit@ginnungagap.bsc.es> (raw)
In-Reply-To: <20120210142832.13518.22003.stgit@ginnungagap.bsc.es>
Uses tracetool to generate a backend-independent tracing event description.
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
---
Makefile | 5 +++
Makefile.objs | 15 +++++++-
scripts/tracetool.py | 94 ++++++++++++++++++++++++++++++++++++++++++++----
trace/event-internal.h | 28 ++++++++++++++
4 files changed, 134 insertions(+), 8 deletions(-)
create mode 100644 trace/event-internal.h
diff --git a/Makefile b/Makefile
index a9f3c7e..13e603c 100644
--- a/Makefile
+++ b/Makefile
@@ -4,9 +4,14 @@
BUILD_DIR=$(CURDIR)
GENERATED_HEADERS = config-host.h trace.h qemu-options.def
+
+GENERATED_HEADERS += trace-events.h
+GENERATED_SOURCES += trace-events.c
+
ifeq ($(TRACE_BACKEND),dtrace)
GENERATED_HEADERS += trace-dtrace.h
endif
+
GENERATED_HEADERS += qmp-commands.h qapi-types.h qapi-visit.h
GENERATED_SOURCES += qmp-marshal.c qapi-types.c qapi-visit.c trace.c
diff --git a/Makefile.objs b/Makefile.objs
index e6644c6..31abd21 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -348,6 +348,19 @@ libdis-$(CONFIG_SPARC_DIS) += sparc-dis.o
######################################################################
# trace
+trace-events.h: trace-events.h-timestamp
+trace-events.h-timestamp: $(SRC_PATH)/trace-events $(TRACETOOL)
+ $(call tracetool-gen,events-h,events)
+ $(call tracetool-ci)
+
+trace-events.c: trace-events.c-timestamp
+trace-events.c-timestamp: $(SRC_PATH)/trace-events $(TRACETOOL)
+ $(call tracetool-gen,events-c,events)
+ $(call tracetool-ci)
+
+trace-obj-y += trace-events.o
+
+
ifeq ($(TRACE_BACKEND),dtrace)
TRACE_H_EXTRA_DEPS=trace-dtrace.h
endif
@@ -389,7 +402,7 @@ trace/simple.o: trace/simple.c $(GENERATED_HEADERS)
trace-obj-$(CONFIG_TRACE_DTRACE) += trace-dtrace.o
ifneq ($(TRACE_BACKEND),dtrace)
-trace-obj-y = trace.o
+trace-obj-y += trace.o
endif
trace-nested-$(CONFIG_TRACE_DEFAULT) += default.o
diff --git a/scripts/tracetool.py b/scripts/tracetool.py
index 7053a74..724b595 100755
--- a/scripts/tracetool.py
+++ b/scripts/tracetool.py
@@ -118,6 +118,73 @@ def get_backend_descr(backend):
# formats
##################################################
+# format: events-h
+
+@for_format("events-h", BEGIN, "Generate .h for event description")
+def process(events):
+ print """\
+/* This file is autogenerated by tracetool, do not edit. */
+
+#ifndef TRACE_EVENTS_H
+#define TRACE_EVENTS_H
+
+#include <stdbool.h>
+"""
+
+ # event identifiers
+ print """
+typedef enum {\
+"""
+ for event in events:
+ print " TRACE_%s," % event.name.upper()
+ print """\
+ TRACE_EVENT_COUNT
+} TraceEventID;
+"""
+
+ # static state
+ for e in events:
+ if 'disable' in e.properties:
+ enabled = 0
+ else:
+ enabled = 1
+ print "#define TRACE_%s_ENABLED %d" % (e.name.upper(), enabled)
+
+ print """\
+#include "trace/event-internal.h"
+
+#endif /* TRACE_EVENTS_H */\
+"""
+
+
+##################################################
+# format: events-c
+
+@for_format("events-c", BEGIN, "Generate .h for event description")
+def process(events):
+ print """\
+/* This file is autogenerated by tracetool, do not edit. */
+
+#include "trace.h"
+#include "trace-events.h"
+#include "trace/control.h"
+
+
+TraceEvent trace_events[TRACE_EVENT_COUNT] = {\
+"""
+ for e in events:
+ print """\
+ { .id = %(id)s, .name = \"%(name)s\", .sstate = %(sstate)s, .dstate = 0 },\
+""" % { "id": "TRACE_" + e.name.upper(),
+ "name": e.name,
+ "sstate": "TRACE_%s_ENABLED" % e.name.upper(),
+ }
+ print """\
+};
+"""
+
+
+##################################################
# format: h
@for_format("h", BEGIN, "Generate .h file")
@@ -131,13 +198,6 @@ def trace_h_begin(events):
@for_format("h", END)
def trace_h_end(events):
- for e in events:
- if 'disable' in e.properties:
- enabled = 0
- else:
- enabled = 1
- print "#define TRACE_%s_ENABLED %d" % (e.name.upper(), enabled)
- print
print '#endif /* TRACE_H */'
@@ -154,6 +214,26 @@ def trace_c_begin(events):
# backends
##################################################
+# backend: events
+
+@for_backend("events", "events-h", "Generic event description")
+def process(events):
+ pass
+
+@for_backend("nop", "events-h")
+def process(events):
+ pass
+
+@for_backend("events", "events-c")
+def process(events):
+ pass
+
+@for_backend("nop", "events-c")
+def process(events):
+ pass
+
+
+##################################################
# backend: nop
@for_backend("nop", "h", "Tracing disabled")
diff --git a/trace/event-internal.h b/trace/event-internal.h
new file mode 100644
index 0000000..d62e82f
--- /dev/null
+++ b/trace/event-internal.h
@@ -0,0 +1,28 @@
+/*
+ * Interface for configuring and controlling the state of tracing events.
+ *
+ * Copyright (C) 2012 Lluís Vilanova <vilanova@ac.upc.edu>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef TRACE__EVENT_H
+#define TRACE__EVENT_H
+
+#include "trace-events.h"
+
+
+typedef struct TraceEvent {
+ /** Unique event identifier. */
+ TraceEventID id;
+ /** Event name. */
+ const char * name;
+ /** Static instrumentation state. */
+ const bool sstate;
+ /** Dynamic instrumentation state. */
+ bool dstate;
+} TraceEvent;
+
+
+#endif /* TRACE__EVENT_H */
next prev parent reply other threads:[~2012-02-10 14:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-10 14:28 [Qemu-devel] [PATCH v3 0/6] trace: Generic event state description Lluís Vilanova
2012-02-10 14:28 ` Lluís Vilanova [this message]
2012-02-10 14:28 ` [Qemu-devel] [PATCH v3 2/6] trace: Provide a detailed event control interface Lluís Vilanova
2012-02-10 14:28 ` [Qemu-devel] [PATCH v3 3/6] trace: [monitor] Use new " Lluís Vilanova
2012-02-10 14:28 ` [Qemu-devel] [PATCH v3 4/6] trace: [default] " Lluís Vilanova
2012-02-10 14:29 ` [Qemu-devel] [PATCH v3 5/6] trace: [simple] Port to generic event information and new " Lluís Vilanova
2012-02-10 14:29 ` [Qemu-devel] [PATCH v3 6/6] trace: [stderr] " Lluís Vilanova
2012-03-14 13:32 ` [Qemu-devel] [PATCH v3 0/6] trace: Generic event state description Lluís Vilanova
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=20120210142837.13518.106.stgit@ginnungagap.bsc.es \
--to=vilanova@ac.upc.edu \
--cc=blauwirbel@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
/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).