From patchwork Wed Jun 16 12:44:35 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prerna Saxena X-Patchwork-Id: 106486 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 o5GCihiW001113 for ; Wed, 16 Jun 2010 12:44:44 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752754Ab0FPMom (ORCPT ); Wed, 16 Jun 2010 08:44:42 -0400 Received: from e28smtp05.in.ibm.com ([122.248.162.5]:50586 "EHLO e28smtp05.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750919Ab0FPMol (ORCPT ); Wed, 16 Jun 2010 08:44:41 -0400 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by e28smtp05.in.ibm.com (8.14.4/8.13.1) with ESMTP id o5GCibgR016038 for ; Wed, 16 Jun 2010 18:14:37 +0530 Received: from d28av05.in.ibm.com (d28av05.in.ibm.com [9.184.220.67]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o5GCibHT3915996 for ; Wed, 16 Jun 2010 18:14:37 +0530 Received: from d28av05.in.ibm.com (loopback [127.0.0.1]) by d28av05.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id o5GCiaNI031913 for ; Wed, 16 Jun 2010 22:44:37 +1000 Received: from zephyr (K50wks273870wss.in.ibm.com [9.124.35.32]) by d28av05.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id o5GCiaFV031896; Wed, 16 Jun 2010 22:44:36 +1000 Date: Wed, 16 Jun 2010 18:14:35 +0530 From: Prerna Saxena To: Prerna Saxena Cc: qemu-devel@nongnu.org, Anthony Liguori , Hajnoczi , kvm@vger.kernel.org, Stefan@us.ibm.com, Luiz Capitulino , Maneesh Soni Subject: [PATCH 3/3] Toggle tracepoint state Message-ID: <20100616181435.7e239947@zephyr> In-Reply-To: <20100616180542.474535e3@zephyr> References: <20100616180542.474535e3@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]); Wed, 16 Jun 2010 12:44:44 +0000 (UTC) diff --git a/monitor.c b/monitor.c index 8b60830..238bdf0 100644 --- a/monitor.c +++ b/monitor.c @@ -548,6 +548,15 @@ static void do_commit(Monitor *mon, const QDict *qdict) } } +#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 +2800,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 239ae3f..4221a8f 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,11 +24,29 @@ 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 = qemu_hash(tname); + trace_list[tevent].state = 1; /* Enable all by default */ +} static void trace(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4, unsigned long x5) { TraceRecord *rec = &trace_buf[trace_idx]; + + if (!trace_list[event].state) { + return; + } + rec->event = event; rec->x1 = x1; rec->x2 = x2; @@ -75,3 +99,42 @@ void do_info_trace(Monitor *mon) 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; istate = 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 <