From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=54019 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OjYBs-0000IK-9y for qemu-devel@nongnu.org; Thu, 12 Aug 2010 09:51:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OjYBq-0006g9-F8 for qemu-devel@nongnu.org; Thu, 12 Aug 2010 09:51:27 -0400 Received: from mtagate4.de.ibm.com ([195.212.17.164]:55801) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OjYBq-0006fg-7d for qemu-devel@nongnu.org; Thu, 12 Aug 2010 09:51:26 -0400 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate4.de.ibm.com (8.13.1/8.13.1) with ESMTP id o7CAasp3021719 for ; Thu, 12 Aug 2010 10:36:54 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 o7CAasXo1868028 for ; Thu, 12 Aug 2010 12:36:54 +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 o7CAarUI022785 for ; Thu, 12 Aug 2010 12:36:54 +0200 From: Stefan Hajnoczi Date: Thu, 12 Aug 2010 11:36:30 +0100 Message-Id: <1281609395-17621-10-git-send-email-stefanha@linux.vnet.ibm.com> In-Reply-To: <1281609395-17621-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1281609395-17621-1-git-send-email-stefanha@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 09/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: Julien Desfossez , 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 eae62da..e96d1f3 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 30dc812..d840e6f 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 <