All of lore.kernel.org
 help / color / mirror / Atom feed
From: Prerna Saxena <prerna@linux.vnet.ibm.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: Maneesh Soni <maneesh@linux.vnet.ibm.com>,
	Stefan@gnu.org, qemu-devel <qemu-devel@nongnu.org>,
	Hajnoczi <stefanha@linux.vnet.ibm.com>,
	Ananth Narayan <ananth@in.ibm.com>
Subject: [Qemu-devel] [RFC v5[PATCH][Tracing] Fix build errors for target i386-linux-user
Date: Mon, 12 Jul 2010 10:25:54 +0530	[thread overview]
Message-ID: <20100712102554.0607b14e@zephyr> (raw)
In-Reply-To: <AANLkTimJVMgWXQem1EZ7-D1tD9N-P1vH0gw8rBetCXXW@mail.gmail.com>

[PATCH] Separate monitor command handler interfaces and tracing internals.

Changelog from v3:
 - cleanup ( removed unnecessary references to 'rec' )

Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
---
 monitor.c     |   23 +++++++++++++++++++++++
 simpletrace.c |   50 ++++++++++++++++++++++++++++----------------------
 tracetool     |    7 +++++++
 3 files changed, 58 insertions(+), 22 deletions(-)

diff --git a/monitor.c b/monitor.c
index 433a3ec..1f89938 100644
--- a/monitor.c
+++ b/monitor.c
@@ -540,6 +540,29 @@ static void do_change_trace_event_state(Monitor *mon, const QDict *qdict)
     bool new_state = qdict_get_bool(qdict, "option");
     change_trace_event_state(tp_name, new_state);
 }
+
+void do_info_trace(Monitor *mon)
+{
+    unsigned int i;
+    char rec[MAX_TRACE_STR_LEN];
+    unsigned int trace_idx = get_trace_idx();
+
+    for (i = 0; i < trace_idx ; i++) {
+        if (format_trace_string(i, rec)) {
+            monitor_printf(mon, rec);
+        }
+    }
+}
+
+void do_info_all_trace_events(Monitor *mon)
+{
+    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);
+    }
+}
 #endif
 
 static void user_monitor_complete(void *opaque, QObject *ret_data)
diff --git a/simpletrace.c b/simpletrace.c
index 57c41fc..9e3b46c 100644
--- a/simpletrace.c
+++ b/simpletrace.c
@@ -1,8 +1,8 @@
 #include <stdlib.h>
 #include <stdio.h>
-#include "monitor.h"
 #include "trace.h"
 
+/* Remember to update MAX_TRACE_STR_LEN when changing TraceRecord structure */
 typedef struct {
     unsigned long event;
     unsigned long x1;
@@ -69,27 +69,6 @@ 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)
-{
-    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);
-    }
-}
-
-void do_info_all_trace_events(Monitor *mon)
-{
-    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);
-    }
-}
-
 static TraceEvent* find_trace_event_by_name(const char *tname)
 {
     unsigned int i;
@@ -115,3 +94,30 @@ void change_trace_event_state(const char *tname, bool tstate)
         tp->state = tstate;
     }
 }
+
+/**
+ * Return the current trace index.
+ *
+ */
+unsigned int get_trace_idx(void)
+{
+    return trace_idx;
+}
+
+/**
+ * returns formatted TraceRecord at a given index in the trace buffer.
+ * FORMAT : "Event %lu : %lx %lx %lx %lx %lx\n"
+ * 
+ * @idx : index in the buffer for which trace record is returned.
+ * @trace_str : output string passed.
+ */
+char* format_trace_string(unsigned int idx, char trace_str[])
+{
+    if (idx >= TRACE_BUF_LEN) {
+        return NULL;
+    }
+    sprintf(&trace_str[0], "Event %lu : %lx %lx %lx %lx %lx\n",
+                     trace_buf[idx].event, trace_buf[idx].x1, trace_buf[idx].x2,
+                       trace_buf[idx].x3, trace_buf[idx].x4, trace_buf[idx].x5);
+    return &trace_str[0];
+}
diff --git a/tracetool b/tracetool
index c77280d..b7a0499 100755
--- a/tracetool
+++ b/tracetool
@@ -125,6 +125,11 @@ typedef struct {
     bool state;
 } TraceEvent;
 
+/* Max size of trace string to be displayed via the monitor.
+ * Format : "Event %lu : %lx %lx %lx %lx %lx\n"
+ */
+#define MAX_TRACE_STR_LEN 100
+
 void trace1(TraceEventID event, unsigned long x1);
 void trace2(TraceEventID event, unsigned long x1, unsigned long x2);
 void trace3(TraceEventID event, unsigned long x1, unsigned long x2, unsigned long x3);
@@ -133,6 +138,8 @@ void trace5(TraceEventID event, unsigned long x1, unsigned long x2, unsigned lon
 void do_info_trace(Monitor *mon);
 void do_info_all_trace_events(Monitor *mon);
 void change_trace_event_state(const char *tname, bool tstate);
+unsigned int get_trace_idx(void);
+char* format_trace_string(unsigned int idx, char *trace_str);
 EOF
 
     simple_event_num=0
-- 
1.6.2.5



-- 
Prerna Saxena

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

  reply	other threads:[~2010-07-12  4:56 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                   ` Prerna Saxena [this message]
2010-07-12  9:16                     ` [Qemu-devel] [PATCH] trace: Remove monitor.h dependency from simpletrace Stefan Hajnoczi
2010-07-12  9:39                       ` 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=20100712102554.0607b14e@zephyr \
    --to=prerna@linux.vnet.ibm.com \
    --cc=Stefan@gnu.org \
    --cc=ananth@in.ibm.com \
    --cc=maneesh@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --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.