All of lore.kernel.org
 help / color / mirror / Atom feed
From: Prerna Saxena <prerna@linux.vnet.ibm.com>
To: qemu-devel <qemu-devel@nongnu.org>
Cc: Anthony Liguori <aliguori@us.ibm.com>,
	Hajnoczi <stefanha@linux.vnet.ibm.com>,
	Mahesh <mahesh@linux.vnet.ibm.com>,
	Stefan@gnu.org, Luiz Capitulino <lcapitulino@redhat.com>,
	Ananth Narayan <ananth@linux.vnet.ibm.com>
Subject: [Qemu-devel] [Tracing][RFC v2 PATCH 1/2] Introduce 'query-trace' & 'query-trace-events' interfaces
Date: Fri, 15 Oct 2010 10:10:10 +0530	[thread overview]
Message-ID: <20101015101010.05cebc96@zephyr> (raw)
In-Reply-To: <20101015100615.10915d2a@zephyr>

[PATCH 1/2] Introduce QMP interfaces : query-trace & query-trace-events


Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
---
 monitor.c     |   46 +++++++++++++++++++++++++++++++++++++++++---
 simpletrace.c |   58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 simpletrace.h |    4 +++
 3 files changed, 104 insertions(+), 4 deletions(-)

diff --git a/monitor.c b/monitor.c
index fbb678d..7a150ae 100644
--- a/monitor.c
+++ b/monitor.c
@@ -941,15 +941,33 @@ static void do_info_cpu_stats(Monitor *mon)
 #endif
 
 #if defined(CONFIG_SIMPLE_TRACE)
-static void do_info_trace(Monitor *mon)
+static void do_info_trace_print(Monitor *mon)
 {
     st_print_trace((FILE *)mon, &monitor_fprintf);
 }
 
-static void do_info_trace_events(Monitor *mon)
+static void do_info_trace(Monitor *mon, QObject **ret_data)
+{
+    QList *trace_event_list = NULL;
+
+    st_print_trace_to_qlist(&trace_event_list);
+
+    *ret_data = QOBJECT(trace_event_list);
+}
+
+static void do_info_trace_events_print(Monitor *mon, const QObject *data)
 {
     st_print_trace_events((FILE *)mon, &monitor_fprintf);
 }
+
+static void do_info_trace_events(Monitor *mon, QObject **ret_data)
+{
+    QList *trace_event_list = NULL;
+
+    st_print_trace_events_to_qlist(&trace_event_list);
+
+    *ret_data = QOBJECT(trace_event_list);
+}
 #endif
 
 /**
@@ -2606,14 +2624,16 @@ static const mon_cmd_t info_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show current contents of trace buffer",
-        .mhandler.info = do_info_trace,
+        .user_print = do_info_trace_print,
+        .mhandler.info_new = do_info_trace,
     },
     {
         .name       = "trace-events",
         .args_type  = "",
         .params     = "",
         .help       = "show available trace-events & their state",
-        .mhandler.info = do_info_trace_events,
+        .user_print = do_info_trace_events_print,
+        .mhandler.info_new = do_info_trace_events,
     },
 #endif
     {
@@ -2748,6 +2768,24 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .mhandler.info_async = do_info_balloon,
         .flags      = MONITOR_CMD_ASYNC,
     },
+#if defined(CONFIG_SIMPLE_TRACE)
+    {
+        .name       = "trace",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show current contents of trace buffer",
+        .user_print = do_info_trace_print,
+        .mhandler.info_new = do_info_trace,
+    },
+    {
+        .name       = "trace-events",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show available trace-events & their state",
+        .user_print = do_info_trace_events_print,
+        .mhandler.info_new = do_info_trace_events,
+    },
+#endif
     { /* NULL */ },
 };
 
diff --git a/simpletrace.c b/simpletrace.c
index f849e42..a964312 100644
--- a/simpletrace.c
+++ b/simpletrace.c
@@ -220,6 +220,43 @@ void st_print_trace(FILE *stream, int (*stream_printf)(FILE *stream, const char
     }
 }
 
+/**
+ * Add the current contents of trace-buffer as a QList.
+ * NOTE: This assumes trace_list hasnt already been allocated with a QList.
+ *        The initialization happens here.
+ */
+void st_print_trace_to_qlist(QList **tlist)
+{
+    QObject *data;
+    unsigned int i;
+
+    assert(tlist);
+
+    *tlist = qlist_new();
+
+    for (i = 0; i < trace_idx; i++) {
+          data = qobject_from_jsonf("{"
+                                    " 'timestamp': %" PRId64 ","
+                                    " 'event': %" PRId64 ","
+                                    " 'arg1': %" PRId64 ","
+                                    " 'arg2': %" PRId64 ","
+                                    " 'arg3': %" PRId64 ","
+                                    " 'arg4': %" PRId64 ","
+                                    " 'arg5': %" PRId64 ","
+                                    " 'arg6': %" PRId64
+                                    "}",
+                                    trace_buf[i].timestamp_ns,
+                                    trace_buf[i].event,
+                                    trace_buf[i].x1,
+                                    trace_buf[i].x2,
+                                    trace_buf[i].x3,
+                                    trace_buf[i].x4,
+                                    trace_buf[i].x5,
+                                    trace_buf[i].x6);
+          qlist_append_obj(*tlist, data);
+    }
+}
+
 void st_print_trace_events(FILE *stream, int (*stream_printf)(FILE *stream, const char *fmt, ...))
 {
     unsigned int i;
@@ -230,6 +267,27 @@ void st_print_trace_events(FILE *stream, int (*stream_printf)(FILE *stream, cons
     }
 }
 
+/**
+ * Add current set of trace-events as a QList.
+ * NOTE: This assumes trace_list hasnt already been allocated with a QList.
+ *        The initialization happens here.
+ */
+void st_print_trace_events_to_qlist(QList **tlist)
+{
+    QObject *data;
+    unsigned int i;
+
+    assert(tlist);
+
+    *tlist = qlist_new();
+
+    for (i = 0; i < NR_TRACE_EVENTS; i++) {
+          data = qobject_from_jsonf("{ 'name': %s, 'event-id': %d, 'state': %d}                                    ", trace_list[i].tp_name, i,
+                                    trace_list[i].state);
+          qlist_append_obj(*tlist, data);
+    }
+}
+
 static TraceEvent* find_trace_event_by_name(const char *tname)
 {
     unsigned int i;
diff --git a/simpletrace.h b/simpletrace.h
index cf35897..6043c21 100644
--- a/simpletrace.h
+++ b/simpletrace.h
@@ -14,6 +14,8 @@
 #include <stdint.h>
 #include <stdbool.h>
 #include <stdio.h>
+#include "qdict.h"
+#include "qjson.h"
 
 typedef uint64_t TraceEventID;
 
@@ -36,5 +38,7 @@ void st_print_trace_file_status(FILE *stream, int (*stream_printf)(FILE *stream,
 void st_set_trace_file_enabled(bool enable);
 bool st_set_trace_file(const char *file);
 void st_flush_trace_buffer(void);
+void st_print_trace_to_qlist(QList **tlist);
+void st_print_trace_events_to_qlist(QList **tlist);
 
 #endif /* SIMPLETRACE_H */
-- 
1.7.2.2



-- 
Prerna Saxena

Linux Technology Centre,
IBM Systems and Technology Lab,
Bangalore, India

  reply	other threads:[~2010-10-15  4:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-15  4:36 [Qemu-devel] [Tracing][RFC v2 PATCH 0/2] QMP Query interfaces for tracing Prerna Saxena
2010-10-15  4:40 ` Prerna Saxena [this message]
2010-10-15  9:35   ` [Qemu-devel] Re: [Tracing][RFC v2 PATCH 1/2] Introduce 'query-trace' & 'query-trace-events' interfaces Stefan Hajnoczi
2010-10-15  4:43 ` [Qemu-devel] [Tracing][RFC v2 PATCH 2/2] Documentation for QMP interfaces 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=20101015101010.05cebc96@zephyr \
    --to=prerna@linux.vnet.ibm.com \
    --cc=Stefan@gnu.org \
    --cc=aliguori@us.ibm.com \
    --cc=ananth@linux.vnet.ibm.com \
    --cc=lcapitulino@redhat.com \
    --cc=mahesh@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@linux.vnet.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.