qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Lluís <xscript@gmx.net>
To: qemu-devel@nongnu.org
Cc: stefanha@gmail.com, chouteau@adacore.com
Subject: [Qemu-devel] [PATCH v4 04/10] trace-state: separate trace event control and query	routines from the simple backend
Date: Tue, 03 May 2011 22:41:11 +0200	[thread overview]
Message-ID: <20110503204110.438.45733.stgit@ginnungagap.bsc.es> (raw)
In-Reply-To: <20110503204042.438.2257.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.

By moving them, other backends will later be able to provide their own
implementation.

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
---
 Makefile.objs   |    1 +
 hmp-commands.hx |    2 +-
 monitor.c       |   13 +++++++------
 trace/control.c |   36 ++++++++++++++++++++++++++++++++++++
 trace/control.h |   14 ++++++++++++++
 trace/simple.c  |   23 -----------------------
 trace/simple.h  |    2 --
 7 files changed, 59 insertions(+), 32 deletions(-)
 create mode 100644 trace/control.c
 create mode 100644 trace/control.h

diff --git a/Makefile.objs b/Makefile.objs
index 37e6ef7..4a2a4eb 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -356,6 +356,7 @@ trace-obj-y += trace/simple.o
 user-obj-y += qemu-timer-common.o
 endif
 endif
+trace-obj-y += trace/control.o
 
 ######################################################################
 # smartcard
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 834e6a8..5eec93e 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 5f3bc72..b6f78ef 100644
--- a/monitor.c
+++ b/monitor.c
@@ -58,7 +58,8 @@
 #include "osdep.h"
 #include "exec-all.h"
 #ifdef CONFIG_SIMPLE_TRACE
-#include "trace.h"
+#include "trace/simple.h"
+#include "trace/control.h"
 #endif
 #include "ui/qemu-spice.h"
 
@@ -593,11 +594,11 @@ static void do_help_cmd(Monitor *mon, const QDict *qdict)
 }
 
 #ifdef CONFIG_SIMPLE_TRACE
-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
 
@@ -3097,7 +3098,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
new file mode 100644
index 0000000..6138eab
--- /dev/null
+++ b/trace/control.c
@@ -0,0 +1,36 @@
+#include "trace/control.h"
+
+#include "trace.h"
+
+
+void trace_print_events(FILE *stream, fprintf_function stream_printf)
+{
+#if defined(CONFIG_SIMPLE_TRACE)
+    unsigned int i;
+
+    for (i = 0; i < NR_TRACE_EVENTS; i++) {
+        stream_printf(stream, "%s [Event ID %u] : state %u\n",
+                      trace_list[i].tp_name, i, trace_list[i].state);
+    }
+#else
+    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");
+#endif
+}
+
+bool trace_event_set_state (const char *name, bool state)
+{
+#if defined(CONFIG_SIMPLE_TRACE)
+    unsigned int i;
+
+    for (i = 0; i < NR_TRACE_EVENTS; i++) {
+        if (!strcmp(trace_list[i].tp_name, name)) {
+            trace_list[i].state = state;
+            return true;
+        }
+    }
+#else
+    fprintf(stderr, "qemu: warning: cannot set the state of a trace event with the current backend\n");
+#endif
+    return false;
+}
diff --git a/trace/control.h b/trace/control.h
new file mode 100644
index 0000000..37d3aa0
--- /dev/null
+++ b/trace/control.h
@@ -0,0 +1,14 @@
+#ifndef TRACE_CONTROL_H
+#define TRACE_CONTROL_H
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <stdio.h>
+
+#include "qemu-common.h"
+
+
+void trace_print_events (FILE *stream, fprintf_function stream_printf);
+bool trace_event_set_state (const char *name, bool state);
+
+#endif  /* TRACE_CONTROL_H */
diff --git a/trace/simple.c b/trace/simple.c
index f1dbb5e..8aa3376 100644
--- a/trace/simple.c
+++ b/trace/simple.c
@@ -302,29 +302,6 @@ 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, ...))
-{
-    unsigned int i;
-
-    for (i = 0; i < NR_TRACE_EVENTS; i++) {
-        stream_printf(stream, "%s [Event ID %u] : state %u\n",
-                      trace_list[i].tp_name, i, trace_list[i].state);
-    }
-}
-
-bool st_change_trace_event_state(const char *name, bool enabled)
-{
-    unsigned int i;
-
-    for (i = 0; i < NR_TRACE_EVENTS; i++) {
-        if (!strcmp(trace_list[i].tp_name, name)) {
-            trace_list[i].state = enabled;
-            return true;
-        }
-    }
-    return false;
-}
-
 void st_flush_trace_buffer(void)
 {
     flush_trace_file(true);
diff --git a/trace/simple.h b/trace/simple.h
index b19eef1..5a45250 100644
--- a/trace/simple.h
+++ b/trace/simple.h
@@ -31,8 +31,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);

  parent reply	other threads:[~2011-05-03 20:40 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-03 20:40 [Qemu-devel] [RFC][PATCH v4 00/10] trace-state: make the behaviour of "disable" consistent across all backends Lluís
2011-05-03 20:40 ` [Qemu-devel] [PATCH v4 01/10] trace: move backend-specific code into the trace/ directory Lluís
2011-05-03 20:40 ` [Qemu-devel] [PATCH v4 02/10] trace: avoid conditional code compilation during option parsing Lluís
2011-05-03 20:41 ` [Qemu-devel] [PATCH v4 03/10] trace: generalize the "property" concept in the trace-events file Lluís
2011-05-03 20:41 ` Lluís [this message]
2011-05-03 20:41 ` [Qemu-devel] [PATCH v4 05/10] trace-state: always compile support for controlling and querying trace event states Lluís
2011-05-03 20:41 ` [Qemu-devel] [PATCH v4 06/10] trace-state: add "-trace events" argument to control initial state Lluís
2011-05-03 20:41 ` [Qemu-devel] [PATCH v4 07/10] trace-state: always use the "nop" backend on events with the "disable" keyword Lluís
2011-05-03 20:41 ` [Qemu-devel] [PATCH v4 08/10] trace-state: [simple] disable all trace points by default Lluís
2011-05-03 20:41 ` [Qemu-devel] [PATCH v4 09/10] trace-state: [stderr] add support for dynamically enabling/disabling events Lluís
2011-05-04 14:17   ` Lluís
2011-05-03 20:41 ` [Qemu-devel] [PATCH v4 10/10] trace: enable all events Lluís
2011-05-19 14:10 ` [Qemu-devel] [RFC][PATCH v4 00/10] trace-state: make the behaviour of "disable" consistent across all backends 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=20110503204110.438.45733.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).