From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
To: Prerna Saxena <prerna@linux.vnet.ibm.com>
Cc: Maneesh Soni <maneesh@linux.vnet.ibm.com>,
qemu-devel@nongnu.org,
Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>,
Ananth Narayan <ananth@in.ibm.com>
Subject: [Qemu-devel] [PATCH] trace: Remove monitor.h dependency from simpletrace
Date: Mon, 12 Jul 2010 10:16:13 +0100 [thread overview]
Message-ID: <1278926173-7216-1-git-send-email-stefanha@linux.vnet.ibm.com> (raw)
In-Reply-To: <20100712102554.0607b14e@zephyr>
User-mode targets don't have a monitor so the simple trace backend
currently does not build on those targets. This patch abstracts the
monitor printing interface so there is no direct coupling between
simpletrace and the monitor.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
I started reading the monitor code today and realized that there is already a
solution to this problem. The monitor printing interface uses FILE* instead of
Monitor*, allowing QEMU subsystems to contain monitor printing code that thinks
it is doing standard library stream I/O. This idiom is used by
cpu_dump_state(), dump_exec_info(), and others.
monitor.c | 14 +++++++++++++-
simpletrace.c | 17 ++++++++---------
tracetool | 4 ++--
3 files changed, 23 insertions(+), 12 deletions(-)
diff --git a/monitor.c b/monitor.c
index 433a3ec..090e13c 100644
--- a/monitor.c
+++ b/monitor.c
@@ -920,6 +920,18 @@ static void do_info_cpu_stats(Monitor *mon)
}
#endif
+#if defined(CONFIG_SIMPLE_TRACE)
+static void do_info_trace(Monitor *mon)
+{
+ st_print_trace((FILE *)mon, &monitor_fprintf);
+}
+
+static void do_info_trace_events(Monitor *mon)
+{
+ st_print_trace_events((FILE *)mon, &monitor_fprintf);
+}
+#endif
+
/**
* do_quit(): Quit QEMU execution
*/
@@ -2584,7 +2596,7 @@ static const mon_cmd_t info_cmds[] = {
.args_type = "",
.params = "",
.help = "show available trace-events & their state",
- .mhandler.info = do_info_all_trace_events,
+ .mhandler.info = do_info_trace_events,
},
#endif
{
diff --git a/simpletrace.c b/simpletrace.c
index 4a4203e..7094f4b 100644
--- a/simpletrace.c
+++ b/simpletrace.c
@@ -1,7 +1,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
-#include "monitor.h"
#include "trace.h"
typedef struct {
@@ -95,24 +94,24 @@ void trace5(TraceEventID event, unsigned long x1, unsigned long x2, unsigned lon
trace(event, x1, x2, x3, x4, x5);
}
-void do_info_trace(Monitor *mon)
+void st_print_trace(FILE *stream, int (*stream_printf)(FILE *stream, const char *fmt, ...))
{
unsigned int i;
- for (i = 0; i < trace_idx ; i++) {
- monitor_printf(mon, "Event %lu : %lx %lx %lx %lx %lx\n",
- trace_buf[i].event, trace_buf[i].x1, trace_buf[i].x2,
- trace_buf[i].x3, trace_buf[i].x4, trace_buf[i].x5);
+ for (i = 0; i < trace_idx; i++) {
+ stream_printf(stream, "Event %lu : %lx %lx %lx %lx %lx\n",
+ trace_buf[i].event, trace_buf[i].x1, trace_buf[i].x2,
+ trace_buf[i].x3, trace_buf[i].x4, trace_buf[i].x5);
}
}
-void do_info_all_trace_events(Monitor *mon)
+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++) {
- monitor_printf(mon, "%s [Event ID %u] : state %u\n",
- trace_list[i].tp_name, i, trace_list[i].state);
+ stream_printf(stream, "%s [Event ID %u] : state %u\n",
+ trace_list[i].tp_name, i, trace_list[i].state);
}
}
diff --git a/tracetool b/tracetool
index 43757e3..8d8f27c 100755
--- a/tracetool
+++ b/tracetool
@@ -139,8 +139,8 @@ void trace2(TraceEventID event, unsigned long x1, unsigned long x2);
void trace3(TraceEventID event, unsigned long x1, unsigned long x2, unsigned long x3);
void trace4(TraceEventID event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4);
void trace5(TraceEventID event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4, unsigned long x5);
-void do_info_trace(Monitor *mon);
-void do_info_all_trace_events(Monitor *mon);
+void st_print_trace(FILE *stream, int (*stream_printf)(FILE *stream, const char *fmt, ...));
+void st_print_trace_events(FILE *stream, int (*stream_printf)(FILE *stream, const char *fmt, ...));
void change_trace_event_state(const char *tname, bool tstate);
EOF
--
1.7.1
next prev parent reply other threads:[~2010-07-12 9:19 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-30 15:41 [Qemu-devel] [PATCH][Tracing] Fix build errors for target i386-linux-user Prerna Saxena
2010-07-01 9:18 ` [Qemu-devel] " Stefan Hajnoczi
2010-07-06 8:04 ` [Qemu-devel] [RFC v2][PATCH][Tracing] " Prerna Saxena
2010-07-06 10:10 ` [Qemu-devel] " Stefan Hajnoczi
2010-07-08 5:28 ` [Qemu-devel] [RFC v3][PATCH][Tracing] " Prerna Saxena
2010-07-08 9:20 ` [Qemu-devel] " Stefan Hajnoczi
2010-07-08 11:20 ` Prerna Saxena
2010-07-08 13:34 ` Stefan Hajnoczi
2010-07-09 11:30 ` [Qemu-devel] [RFC v4][PATCH][Tracing] " Prerna Saxena
2010-07-09 11:43 ` Stefan Hajnoczi
2010-07-12 4:55 ` [Qemu-devel] [RFC v5[PATCH][Tracing] " Prerna Saxena
2010-07-12 9:16 ` Stefan Hajnoczi [this message]
2010-07-12 9:39 ` [Qemu-devel] [PATCH] trace: Remove monitor.h dependency from simpletrace Stefan Hajnoczi
2010-07-09 11:35 ` [Qemu-devel] Re: [RFC v3][PATCH][Tracing] Fix build errors for target i386-linux-user Prerna Saxena
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=1278926173-7216-1-git-send-email-stefanha@linux.vnet.ibm.com \
--to=stefanha@linux.vnet.ibm.com \
--cc=ananth@in.ibm.com \
--cc=maneesh@linux.vnet.ibm.com \
--cc=prerna@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
/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).