From patchwork Thu Jun 10 19:24:27 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prerna Saxena X-Patchwork-Id: 105450 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o5AJOedC022668 for ; Thu, 10 Jun 2010 19:24:40 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759565Ab0FJTYh (ORCPT ); Thu, 10 Jun 2010 15:24:37 -0400 Received: from e28smtp06.in.ibm.com ([122.248.162.6]:57548 "EHLO e28smtp06.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759128Ab0FJTYg (ORCPT ); Thu, 10 Jun 2010 15:24:36 -0400 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by e28smtp06.in.ibm.com (8.14.4/8.13.1) with ESMTP id o5AJOXtZ022378 for ; Fri, 11 Jun 2010 00:54:33 +0530 Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o5AJOXsr2859102 for ; Fri, 11 Jun 2010 00:54:33 +0530 Received: from d28av03.in.ibm.com (loopback [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id o5AJOWfA019053 for ; Fri, 11 Jun 2010 05:24:33 +1000 Received: from zephyr ([9.77.123.112]) by d28av03.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id o5AJOVdi019040; Fri, 11 Jun 2010 05:24:31 +1000 Date: Fri, 11 Jun 2010 00:54:27 +0530 From: Prerna Saxena To: qemu-devel@nongnu.org Cc: Anthony Liguori , Stefan Hajnoczi , kvm@vger.kernel.org, Jan Kiszka , Luiz Capitulino , maneesh@linux.vnet.ibm.com, ananth@linux.vnet.ibm.com Subject: [RFC v2] [PATCH 3/3] Toggle tracepoint state Message-ID: <20100611005427.4e76c315@zephyr> In-Reply-To: <20100611003811.2635fa5d@zephyr> References: <20100611003811.2635fa5d@zephyr> Organization: IBM X-Mailer: Claws Mail 3.7.5 (GTK+ 2.16.6; i586-redhat-linux-gnu) Mime-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 10 Jun 2010 19:24:40 +0000 (UTC) diff --git a/monitor.c b/monitor.c index 8b60830..e4c7bef 100644 --- a/monitor.c +++ b/monitor.c @@ -547,7 +547,14 @@ static void do_commit(Monitor *mon, const QDict *qdict) bdrv_commit(dinfo->bdrv); } } - +#ifdef CONFIG_SIMPLE_TRACE +static void do_change_tracepoint_state(Monitor *mon, const QDict *qdict) +{ + const char *tp_name = qdict_get_str(qdict, "name"); + bool new_state = qdict_get_bool(qdict, "option"); + change_tracepoint_state(tp_name, new_state); +} +#endif static void user_monitor_complete(void *opaque, QObject *ret_data) { MonitorCompletionData *data = (MonitorCompletionData *)opaque; @@ -2791,6 +2798,13 @@ static const mon_cmd_t info_cmds[] = { .help = "show current contents of trace buffer", .mhandler.info = do_info_trace, }, + { + .name = "tracepoints", + .args_type = "", + .params = "", + .help = "show available tracepoints & their state", + .mhandler.info = do_info_all_tracepoints, + }, #endif { .name = NULL, diff --git a/qemu-monitor.hx b/qemu-monitor.hx index 766c30f..8540b8f 100644 --- a/qemu-monitor.hx +++ b/qemu-monitor.hx @@ -117,6 +117,8 @@ show device tree #ifdef CONFIG_SIMPLE_TRACE @item info trace show contents of trace buffer +@item info tracepoints +show available tracepoints and their state #endif @end table ETEXI @@ -225,6 +227,22 @@ STEXI @item logfile @var{filename} @findex logfile Output logs to @var{filename}. +#ifdef CONFIG_SIMPLE_TRACE +ETEXI + + { + .name = "tracepoint", + .args_type = "name:s,option:b", + .params = "name on|off", + .help = "changes status of a specific tracepoint", + .mhandler.cmd = do_change_tracepoint_state, + }, + +STEXI +@item tracepoint +@findex tracepoint +changes status of a tracepoint +#endif ETEXI { diff --git a/simpletrace.c b/simpletrace.c index 00df45a..b601d24 100644 --- a/simpletrace.c +++ b/simpletrace.c @@ -3,6 +3,12 @@ #include "trace.h" typedef struct { + char *tp_name; + bool state; + unsigned int hash; +} Tracepoint; + +typedef struct { unsigned long event; unsigned long x1; unsigned long x2; @@ -18,10 +24,24 @@ enum { static TraceRecord trace_buf[TRACE_BUF_LEN]; static unsigned int trace_idx; static FILE *trace_fp; +static Tracepoint trace_list[NR_TRACEPOINTS]; + +void init_tracepoint(const char *tname, TraceEvent tevent) { + if (!tname || tevent > NR_TRACEPOINTS) + return; + + trace_list[tevent].tp_name = (char*)qemu_malloc(strlen(tname)+1); + strncpy(trace_list[tevent].tp_name, tname, strlen(tname)); + trace_list[tevent].hash = tdb_hash(tname); + trace_list[tevent].state = 1; /* Enable all by default */ + return; +} static void trace(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4, unsigned long x5) { + if (!trace_list[event].state) + return; TraceRecord *rec = &trace_buf[trace_idx]; rec->event = event; rec->x1 = x1; @@ -74,3 +94,36 @@ void do_info_trace(Monitor *mon) 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_tracepoints(Monitor *mon) +{ + unsigned int i; + for (i=0; i= 0) + trace_list[i].state = tstate; +} diff --git a/tracetool b/tracetool index 2c73bab..00af205 100755 --- a/tracetool +++ b/tracetool @@ -123,14 +123,20 @@ linetoc_end_nop() linetoh_begin_simple() { cat < + typedef unsigned int TraceEvent; +void init_tracepoint_table(void); +void init_tracepoint(const char *tname, TraceEvent tevent); void trace1(TraceEvent event, unsigned long x1); void trace2(TraceEvent event, unsigned long x1, unsigned long x2); void trace3(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long x3); void trace4(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4); void trace5(TraceEvent 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_tracepoints(Monitor *mon); +void change_tracepoint_state(const char *tname, bool tstate); EOF simple_event_num=0 @@ -163,22 +169,38 @@ EOF linetoh_end_simple() { - return + cat <