[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] trace: Remove monitor.h dependency from simpletrace
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PATCH] trace: Remove monitor.h dependency from simpletrace |
Date: |
Mon, 12 Jul 2010 10:16:13 +0100 |
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 <address@hidden>
---
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
- [Qemu-devel] Re: [PATCH][Tracing] Fix build errors for target i386-linux-user, Stefan Hajnoczi, 2010/07/01
- [Qemu-devel] [RFC v2][PATCH][Tracing] Fix build errors for target i386-linux-user, Prerna Saxena, 2010/07/06
- [Qemu-devel] Re: [RFC v2][PATCH][Tracing] Fix build errors for target i386-linux-user, Stefan Hajnoczi, 2010/07/06
- [Qemu-devel] [RFC v3][PATCH][Tracing] Fix build errors for target i386-linux-user, Prerna Saxena, 2010/07/08
- [Qemu-devel] Re: [RFC v3][PATCH][Tracing] Fix build errors for target i386-linux-user, Stefan Hajnoczi, 2010/07/08
- [Qemu-devel] Re: [RFC v3][PATCH][Tracing] Fix build errors for target i386-linux-user, Prerna Saxena, 2010/07/08
- [Qemu-devel] Re: [RFC v3][PATCH][Tracing] Fix build errors for target i386-linux-user, Stefan Hajnoczi, 2010/07/08
- [Qemu-devel] [RFC v4][PATCH][Tracing] Fix build errors for target i386-linux-user, Prerna Saxena, 2010/07/09
- Re: [Qemu-devel] [RFC v4][PATCH][Tracing] Fix build errors for target i386-linux-user, Stefan Hajnoczi, 2010/07/09
- [Qemu-devel] [RFC v5[PATCH][Tracing] Fix build errors for target i386-linux-user, Prerna Saxena, 2010/07/12
- [Qemu-devel] [PATCH] trace: Remove monitor.h dependency from simpletrace,
Stefan Hajnoczi <=
- Re: [Qemu-devel] [PATCH] trace: Remove monitor.h dependency from simpletrace, Stefan Hajnoczi, 2010/07/12
- [Qemu-devel] Re: [RFC v3][PATCH][Tracing] Fix build errors for target i386-linux-user, Prerna Saxena, 2010/07/09