From patchwork Tue Jun 8 07:08:58 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prerna Saxena X-Patchwork-Id: 104892 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 o5879Atd031076 for ; Tue, 8 Jun 2010 07:09:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754014Ab0FHHJI (ORCPT ); Tue, 8 Jun 2010 03:09:08 -0400 Received: from e23smtp05.au.ibm.com ([202.81.31.147]:43541 "EHLO e23smtp05.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753833Ab0FHHJH (ORCPT ); Tue, 8 Jun 2010 03:09:07 -0400 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [202.81.31.247]) by e23smtp05.au.ibm.com (8.14.4/8.13.1) with ESMTP id o587518c002685 for ; Tue, 8 Jun 2010 17:05:01 +1000 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o58794WX1302768 for ; Tue, 8 Jun 2010 17:09:04 +1000 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id o58793H2013223 for ; Tue, 8 Jun 2010 17:09:04 +1000 Received: from zephyr ([9.124.35.20]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id o58791Zr013181; Tue, 8 Jun 2010 17:09:02 +1000 Date: Tue, 8 Jun 2010 12:38:58 +0530 From: Prerna Saxena To: qemu-devel@nongnu.org Cc: Anthony Liguori , Stefan Hajnoczi , kvm@vger.kernel.org, Jan Kiszka , maneesh@linux.vnet.ibm.com, ananth@linux.vnet.ibm.com Subject: [PATCH 3/3] Toggle tracepoint state Message-ID: <20100608123858.6d7dc770@zephyr> In-Reply-To: <20100608122803.6a684a5e@zephyr> References: <20100608122803.6a684a5e@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]); Tue, 08 Jun 2010 07:09:11 +0000 (UTC) diff --git a/monitor.c b/monitor.c index fda29aa..1e05b38 100644 --- a/monitor.c +++ b/monitor.c @@ -547,7 +547,19 @@ 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"); + const char *tp_state = qdict_get_str(qdict, "option"); + if (!strncmp(tp_state, "on", 2)) + change_tracepoint_state(tp_name, 1); + if (!strncmp(tp_state, "off", 3)) + change_tracepoint_state(tp_name, 0); + return; +} +#endif static void user_monitor_complete(void *opaque, QObject *ret_data) { MonitorCompletionData *data = (MonitorCompletionData *)opaque; @@ -2783,6 +2795,15 @@ static const mon_cmd_t info_cmds[] = { .help = "show roms", .mhandler.info = do_info_roms, }, +#ifdef CONFIG_SIMPLE_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 c604aec..36481ea 100644 --- a/qemu-monitor.hx +++ b/qemu-monitor.hx @@ -114,6 +114,8 @@ show migration status show balloon information @item info qtree show device tree +@item info tracepoints +show available tracepoints and their state @end table ETEXI @@ -236,6 +238,20 @@ STEXI @item trace @findex trace show contents of trace buffer +ETEXI + + { + .name = "tracepoint", + .args_type = "name:s,option:s", + .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 8f33a81..75d2fca 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; @@ -64,7 +84,7 @@ void trace5(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long } void do_info_trace(Monitor *mon) { - static unsigned int i, max_idx; + unsigned int i, max_idx; if (trace_idx) max_idx = trace_idx; @@ -77,3 +97,36 @@ void do_info_trace(Monitor *mon) { trace_buf[i].x3, trace_buf[i].x4, trace_buf[i].x5); return; } + +void do_info_all_tracepoints(Monitor *mon) { + unsigned int i; + for (i=0; i= 0) + trace_list[i].state = tstate; + return; +} diff --git a/tracetool b/tracetool index 6c15154..cc2b22c 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 <