From patchwork Fri Jul 9 11:30:36 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prerna Saxena X-Patchwork-Id: 58391 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 95FCBB6F10 for ; Fri, 9 Jul 2010 21:31:28 +1000 (EST) Received: from localhost ([127.0.0.1]:34674 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OXBnf-0006zs-CH for incoming@patchwork.ozlabs.org; Fri, 09 Jul 2010 07:31:23 -0400 Received: from [140.186.70.92] (port=46376 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OXBn3-0006zk-G1 for qemu-devel@nongnu.org; Fri, 09 Jul 2010 07:30:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OXBn2-00057Z-6G for qemu-devel@nongnu.org; Fri, 09 Jul 2010 07:30:45 -0400 Received: from e23smtp01.au.ibm.com ([202.81.31.143]:53088) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OXBn1-00057Q-KQ for qemu-devel@nongnu.org; Fri, 09 Jul 2010 07:30:44 -0400 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [202.81.31.246]) by e23smtp01.au.ibm.com (8.14.4/8.13.1) with ESMTP id o69BS35W002431 for ; Fri, 9 Jul 2010 21:28:03 +1000 Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o69BUeD81216738 for ; Fri, 9 Jul 2010 21:30:41 +1000 Received: from d23av02.au.ibm.com (loopback [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id o69BUeNB021912 for ; Fri, 9 Jul 2010 21:30:40 +1000 Received: from zephyr ([9.124.35.83]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id o69BUcTN021890; Fri, 9 Jul 2010 21:30:39 +1000 Date: Fri, 9 Jul 2010 17:00:36 +0530 From: Prerna Saxena To: qemu-devel Message-ID: <20100709170036.122681fa@zephyr> In-Reply-To: <20100708133419.GA22424@stefan-thinkpad.transitives.com> References: <20100630211145.41631855@zephyr> <20100701091839.GB2344@stefan-thinkpad.transitives.com> <20100706133417.1a344397@zephyr> <20100706101001.GA6651@stefan-thinkpad.transitives.com> <20100708105858.7b456295@zephyr> <20100708092031.GC2174@stefan-thinkpad.transitives.com> <4C35B494.2050800@linux.vnet.ibm.com> <20100708133419.GA22424@stefan-thinkpad.transitives.com> Organization: IBM X-Mailer: Claws Mail 3.7.5 (GTK+ 2.16.6; i586-redhat-linux-gnu) Mime-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: Maneesh Soni , Stefan Hajnoczi , Ananth Narayan Subject: [Qemu-devel] [RFC v4][PATCH][Tracing] Fix build errors for target i386-linux-user X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org [PATCH] Separate monitor command handler interfaces and tracing internals. Changelog from v3 : 1. Cleanups. Signed-off-by: Prerna Saxena --- monitor.c | 23 +++++++++++++++++++++++ simpletrace.c | 52 ++++++++++++++++++++++++++++++---------------------- tracetool | 7 +++++++ 3 files changed, 60 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..78507ec 100644 --- a/simpletrace.c +++ b/simpletrace.c @@ -1,8 +1,8 @@ #include #include -#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,32 @@ 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[]) +{ + TraceRecord rec; + if (idx >= TRACE_BUF_LEN) { + return NULL; + } + rec = trace_buf[idx]; + 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