From: Lluís <xscript@gmx.net>
To: qemu-devel@nongnu.org, chouteau@adacore.com
Cc: stefanha@gmail.com
Subject: [Qemu-devel] [PATCH v6 08/14] trace-state: separate trace event control and query routines from the simple backend
Date: Thu, 25 Aug 2011 17:52:23 +0200 [thread overview]
Message-ID: <20110825155223.19177.10713.stgit@ginnungagap.bsc.es> (raw)
In-Reply-To: <20110825155128.19177.80104.stgit@ginnungagap.bsc.es>
Move the 'st_print_trace_events' and 'st_change_trace_event_state' into
backend-agnostic 'trace_print_events' and 'trace_event_set_state' (respectively)
in the "trace/control.c" file.
Uses "QEMU_WEAK" to provide a default implementation that signals it as not
implemented.
Backends can provide their own implementation if supported.
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
---
Makefile.objs | 1 +
hmp-commands.hx | 2 +-
monitor.c | 11 ++++++-----
trace/control.c | 11 +++++++++++
trace/control.h | 17 ++++++++++++-----
trace/simple.c | 16 ++++++++--------
trace/simple.h | 2 --
7 files changed, 39 insertions(+), 21 deletions(-)
diff --git a/Makefile.objs b/Makefile.objs
index 3530bcf..8950086 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -378,6 +378,7 @@ trace-obj-$(CONFIG_TRACE_SYSTEMTAP) += trace-dtrace.o
ifneq ($(TRACE_BACKEND),dtrace)
trace-obj-y = trace.o
endif
+trace-obj-y += trace/control.o
trace-nested-$(CONFIG_TRACE_SIMPLE) += simple.o
trace-obj-$(CONFIG_TRACE_SIMPLE) += qemu-timer-common.o
diff --git a/hmp-commands.hx b/hmp-commands.hx
index ad4174f..d77e75f 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -186,7 +186,7 @@ ETEXI
.args_type = "name:s,option:b",
.params = "name on|off",
.help = "changes status of a specific trace event",
- .mhandler.cmd = do_change_trace_event_state,
+ .mhandler.cmd = do_trace_event_set_state,
},
STEXI
diff --git a/monitor.c b/monitor.c
index 9c6e99c..74cb6a2 100644
--- a/monitor.c
+++ b/monitor.c
@@ -60,6 +60,7 @@
#ifdef CONFIG_TRACE_SIMPLE
#include "trace.h"
#endif
+#include "trace/control.h"
#include "ui/qemu-spice.h"
//#define DEBUG
@@ -593,11 +594,11 @@ static void do_help_cmd(Monitor *mon, const QDict *qdict)
}
#ifdef CONFIG_TRACE_SIMPLE
-static void do_change_trace_event_state(Monitor *mon, const QDict *qdict)
+static void do_trace_event_set_state(Monitor *mon, const QDict *qdict)
{
const char *tp_name = qdict_get_str(qdict, "name");
bool new_state = qdict_get_bool(qdict, "option");
- int ret = st_change_trace_event_state(tp_name, new_state);
+ int ret = trace_event_set_state(tp_name, new_state);
if (!ret) {
monitor_printf(mon, "unknown event name \"%s\"\n", tp_name);
@@ -1002,9 +1003,9 @@ static void do_info_trace(Monitor *mon)
st_print_trace((FILE *)mon, &monitor_fprintf);
}
-static void do_info_trace_events(Monitor *mon)
+static void do_trace_print_events(Monitor *mon)
{
- st_print_trace_events((FILE *)mon, &monitor_fprintf);
+ trace_print_events((FILE *)mon, &monitor_fprintf);
}
#endif
@@ -3148,7 +3149,7 @@ static const mon_cmd_t info_cmds[] = {
.args_type = "",
.params = "",
.help = "show available trace-events & their state",
- .mhandler.info = do_info_trace_events,
+ .mhandler.info = do_trace_print_events,
},
#endif
{
diff --git a/trace/control.c b/trace/control.c
index cb14f4b..b27ba30 100644
--- a/trace/control.c
+++ b/trace/control.c
@@ -11,6 +11,17 @@
#include "trace/control.h"
+void trace_print_events (FILE *stream, fprintf_function stream_printf)
+{
+ fprintf(stderr, "qemu: warning: cannot print the trace events with the current backend\n");
+ stream_printf(stream, "error: operation not supported with the current backend\n");
+}
+
+bool trace_event_set_state (const char *name, bool state)
+{
+ fprintf(stderr, "qemu: warning: cannot set the state of a trace event with the current backend\n");
+ return false;
+}
bool trace_config_init (void)
{
diff --git a/trace/control.h b/trace/control.h
index 8b52d5e..d1e277b 100644
--- a/trace/control.h
+++ b/trace/control.h
@@ -7,15 +7,22 @@
* the COPYING file in the top-level directory.
*/
-#ifndef TRACE_CONFIG_H
-#define TRACE_CONFIG_H
-
-#include <stdbool.h>
+#ifndef TRACE_CONTROL_H
+#define TRACE_CONTROL_H
+#include "qemu-common.h"
#include "compiler.h"
/* Backends can re-implement routines marked as QEMU_WEAK */
+/** Print the state of all events. */
+void trace_print_events (FILE *stream, fprintf_function stream_printf) QEMU_WEAK;
+/** Set the state of an event.
+ *
+ * @return Whether the state changed.
+ */
+bool trace_event_set_state (const char *name, bool state) QEMU_WEAK;
+
/** Whether any cmdline trace option is avilable. */
bool trace_config_init (void) QEMU_WEAK;
/** Configure output trace file.
@@ -24,4 +31,4 @@ bool trace_config_init (void) QEMU_WEAK;
*/
bool trace_config_init_file (const char *file) QEMU_WEAK;
-#endif /* TRACE_CONFIG_H */
+#endif /* TRACE_CONTROL_H */
diff --git a/trace/simple.c b/trace/simple.c
index f3891c1..aa6403e 100644
--- a/trace/simple.c
+++ b/trace/simple.c
@@ -303,7 +303,12 @@ void st_print_trace(FILE *stream, int (*stream_printf)(FILE *stream, const char
}
}
-void st_print_trace_events(FILE *stream, int (*stream_printf)(FILE *stream, const char *fmt, ...))
+void st_flush_trace_buffer(void)
+{
+ flush_trace_file(true);
+}
+
+void trace_print_events (FILE *stream, fprintf_function stream_printf)
{
unsigned int i;
@@ -313,24 +318,19 @@ void st_print_trace_events(FILE *stream, int (*stream_printf)(FILE *stream, cons
}
}
-bool st_change_trace_event_state(const char *name, bool enabled)
+bool trace_event_set_state (const char *name, bool state)
{
unsigned int i;
for (i = 0; i < NR_TRACE_EVENTS; i++) {
if (!strcmp(trace_list[i].tp_name, name)) {
- trace_list[i].state = enabled;
+ trace_list[i].state = state;
return true;
}
}
return false;
}
-void st_flush_trace_buffer(void)
-{
- flush_trace_file(true);
-}
-
bool trace_config_init (void)
{
pthread_t thread;
diff --git a/trace/simple.h b/trace/simple.h
index 08b9a52..466e75b 100644
--- a/trace/simple.h
+++ b/trace/simple.h
@@ -30,8 +30,6 @@ void trace4(TraceEventID event, uint64_t x1, uint64_t x2, uint64_t x3, uint64_t
void trace5(TraceEventID event, uint64_t x1, uint64_t x2, uint64_t x3, uint64_t x4, uint64_t x5);
void trace6(TraceEventID event, uint64_t x1, uint64_t x2, uint64_t x3, uint64_t x4, uint64_t x5, uint64_t x6);
void st_print_trace(FILE *stream, fprintf_function stream_printf);
-void st_print_trace_events(FILE *stream, fprintf_function stream_printf);
-bool st_change_trace_event_state(const char *tname, bool tstate);
void st_print_trace_file_status(FILE *stream, fprintf_function stream_printf);
void st_set_trace_file_enabled(bool enable);
bool st_set_trace_file(const char *file);
next prev parent reply other threads:[~2011-08-25 15:52 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-25 15:51 [Qemu-devel] [PATCH v6 00/14] trace-state: make the behaviour of "disable" consistent across all backends Lluís
2011-08-25 15:51 ` [Qemu-devel] [PATCH v6 01/14] [simple] Include qemu-timer-common.o in trace-obj-y Lluís
2011-08-25 15:51 ` [Qemu-devel] [PATCH v6 02/14] provide support for default implementations using weak symbols Lluís
2011-08-25 17:40 ` Blue Swirl
2011-08-25 18:27 ` Lluís
2011-08-25 15:51 ` [Qemu-devel] [PATCH v6 03/14] trace: [configure] rename CONFIG_*_TRACE into CONFIG_TRACE_* Lluís
2011-08-25 15:51 ` [Qemu-devel] [PATCH v6 04/14] trace: [make] replace 'ifeq' with values in CONFIG_TRACE_* Lluís
2011-08-25 15:52 ` [Qemu-devel] [PATCH v6 05/14] trace: move backend-specific code into the trace/ directory Lluís
2011-08-25 15:52 ` [Qemu-devel] [PATCH v6 06/14] trace: avoid conditional code compilation during option parsing Lluís
2011-08-25 15:52 ` [Qemu-devel] [PATCH v6 07/14] trace: generalize the "property" concept in the trace-events file Lluís
2011-08-25 15:52 ` Lluís [this message]
2011-08-25 15:52 ` [Qemu-devel] [PATCH v6 09/14] trace-state: always compile support for controlling and querying trace event states Lluís
2011-08-25 15:52 ` [Qemu-devel] [PATCH v6 10/14] trace-state: add "-trace events" argument to control initial state Lluís
2011-08-25 15:52 ` [Qemu-devel] [PATCH v6 11/14] trace-state: always use the "nop" backend on events with the "disable" keyword Lluís
2011-08-25 15:52 ` [Qemu-devel] [PATCH v6 12/14] trace-state: [simple] disable all trace points by default Lluís
2011-08-25 15:52 ` [Qemu-devel] [PATCH v6 13/14] trace-state: [stderr] add support for dynamically enabling/disabling events Lluís
2011-08-25 16:04 ` Lluís
2011-08-25 15:53 ` [Qemu-devel] [PATCH v6 14/14] trace: enable all events Lluís
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=20110825155223.19177.10713.stgit@ginnungagap.bsc.es \
--to=xscript@gmx.net \
--cc=chouteau@adacore.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).