@@ -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
{
@@ -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);
}
}
@@ -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
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(-)