From patchwork Mon Aug 30 13:27:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 63038 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4D846B6EEC for ; Mon, 30 Aug 2010 23:55:42 +1000 (EST) Received: from localhost ([127.0.0.1]:51627 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oq4pc-0003Lw-4A for incoming@patchwork.ozlabs.org; Mon, 30 Aug 2010 09:55:28 -0400 Received: from [140.186.70.92] (port=48497 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oq4Od-0001A0-5n for qemu-devel@nongnu.org; Mon, 30 Aug 2010 09:27:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Oq4Oa-00044w-Hd for qemu-devel@nongnu.org; Mon, 30 Aug 2010 09:27:35 -0400 Received: from mtagate4.de.ibm.com ([195.212.17.164]:46453) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oq4Oa-00044X-8K for qemu-devel@nongnu.org; Mon, 30 Aug 2010 09:27:32 -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 o7UDRRfW000713 for ; Mon, 30 Aug 2010 13:27:27 GMT Received: from d12av04.megacenter.de.ibm.com (d12av04.megacenter.de.ibm.com [9.149.165.229]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o7UDRR6p3272912 for ; Mon, 30 Aug 2010 15:27:27 +0200 Received: from d12av04.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av04.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id o7UDRR6b007704 for ; Mon, 30 Aug 2010 15:27:28 +0200 Received: from stefan-thinkpad.ibm.com (sig-9-146-224-127.de.ibm.com [9.146.224.127]) by d12av04.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id o7UDROUM007601; Mon, 30 Aug 2010 15:27:27 +0200 From: Stefan Hajnoczi To: Date: Mon, 30 Aug 2010 14:27:06 +0100 Message-Id: <1283174836-6330-5-git-send-email-stefanha@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1283174836-6330-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1283174836-6330-1-git-send-email-stefanha@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: Blue Swirl , Anthony Liguori , Stefan Hajnoczi , Prerna Saxena Subject: [Qemu-devel] [PATCH 04/14] trace: Support disabled events in trace-events X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 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 <