From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=47994 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OsdPZ-00057r-1S for qemu-devel@nongnu.org; Mon, 06 Sep 2010 11:15:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OsdPP-0003zo-No for qemu-devel@nongnu.org; Mon, 06 Sep 2010 11:15:08 -0400 Received: from mtagate6.de.ibm.com ([195.212.17.166]:54792) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OsdPP-0003zR-Co for qemu-devel@nongnu.org; Mon, 06 Sep 2010 11:14:59 -0400 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate6.de.ibm.com (8.13.1/8.13.1) with ESMTP id o86FExOV032536 for ; Mon, 6 Sep 2010 15:14:59 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o86FEp7K3518478 for ; Mon, 6 Sep 2010 17:14:55 +0200 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id o86FEoJ4017988 for ; Mon, 6 Sep 2010 17:14:51 +0200 From: Stefan Hajnoczi Date: Mon, 6 Sep 2010 16:14:01 +0100 Message-Id: <1283786051-29530-5-git-send-email-stefanha@linux.vnet.ibm.com> In-Reply-To: <1283786051-29530-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1283786051-29530-1-git-send-email-stefanha@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 04/14] trace: Support disabled events in trace-events List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Blue Swirl , Anthony Liguori , "Michael S. Tsirkin" , Stefan Hajnoczi , Prerna Saxena Sometimes it is useful to disable a trace event. Removing the event from trace-events is not enough since source code will call the trace_*() function for the event. This patch makes it easy to build without specific trace events by marking them disabled in trace-events: disable multiwrite_cb(void *mcb, int ret) "mcb %p ret %d" This builds without the multiwrite_cb trace event. Signed-off-by: Stefan Hajnoczi trace: Allow bulk enabling/disabling of trace events at compile time For 'simple' trace backend, allow bulk enabling/disabling of trace events at compile time. Trace events that are preceded by 'disable' keyword are compiled in, but turned off by default. These can individually be turned on using the monitor. All other trace events are enabled by default. TODO : This could be enhanced when the trace-event namespace is partitioned into a group and an ID within that group. In such a case, marking a group as enabled would automatically enable all trace-events listed under it. Signed-off-by: Prerna Saxena Signed-off-by: Stefan Hajnoczi --- trace-events | 7 ++++++- tracetool | 44 +++++++++++++++++++++++++++++++++++++++----- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/trace-events b/trace-events index a37d3cc..2a986ec 100644 --- a/trace-events +++ b/trace-events @@ -12,10 +12,15 @@ # # Format of a trace event: # -# ( [, ] ...) "" +# [disable] ( [, ] ...) "" # # Example: qemu_malloc(size_t size) "size %zu" # +# The "disable" keyword will build without the trace event. +# In case of 'simple' trace backend, it will allow the trace event to be +# compiled, but this would be turned off by default. It can be toggled on via +# the monitor. +# # The must be a valid as a C function name. # # Types should be standard C types. Use void * for pointers because the trace diff --git a/tracetool b/tracetool index 2e2e37d..8aeac48 100755 --- a/tracetool +++ b/tracetool @@ -87,6 +87,20 @@ get_fmt() echo "$fmt" } +# Get the state of a trace event +get_state() +{ + local str disable state + str=$(get_name "$1") + disable=${str##disable } + if [ "$disable" = "$str" ] ; then + state=1 + else + state=0 + fi + echo "$state" +} + linetoh_begin_nop() { return @@ -146,10 +160,14 @@ cast_args_to_uint64_t() linetoh_simple() { - local name args argc trace_args + local name args argc trace_args state name=$(get_name "$1") args=$(get_args "$1") argc=$(get_argc "$1") + state=$(get_state "$1") + if [ "$state" = "0" ]; then + name=${name##disable } + fi trace_args="$simple_event_num" if [ "$argc" -gt 0 ] @@ -188,10 +206,14 @@ EOF linetoc_simple() { - local name + local name state name=$(get_name "$1") + state=$(get_state "$1") + if [ "$state" = "0" ] ; then + name=${name##disable } + fi cat <