From patchwork Wed Apr 6 18:34:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?Q?Llu=C3=ADs?= X-Patchwork-Id: 90053 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 290F8B6EEB for ; Thu, 7 Apr 2011 04:42:53 +1000 (EST) Received: from localhost ([127.0.0.1]:37273 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q7Xgn-00078x-0I for incoming@patchwork.ozlabs.org; Wed, 06 Apr 2011 14:42:49 -0400 Received: from [140.186.70.92] (port=43109 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q7XZv-0004IS-RY for qemu-devel@nongnu.org; Wed, 06 Apr 2011 14:35:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q7XZt-0001mH-Vq for qemu-devel@nongnu.org; Wed, 06 Apr 2011 14:35:43 -0400 Received: from mailout-de.gmx.net ([213.165.64.23]:52607) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1Q7XZt-0001lx-LL for qemu-devel@nongnu.org; Wed, 06 Apr 2011 14:35:41 -0400 Received: (qmail invoked by alias); 06 Apr 2011 18:35:35 -0000 Received: from unknown (EHLO localhost) [84.88.53.92] by mail.gmx.net (mp009) with SMTP; 06 Apr 2011 20:35:35 +0200 X-Authenticated: #12333383 X-Provags-ID: V01U2FsdGVkX1/4KScSArr4PYv2axnUoYxACTEUoT94VJovgEk6hv c8HEtSAwAFwT7K To: qemu-devel@nongnu.org From: =?utf-8?b?TGx1w61z?= Date: Wed, 06 Apr 2011 20:34:31 +0200 Message-ID: <20110406183431.22854.56191.stgit@ginnungagap.bsc.es> In-Reply-To: <20110406183341.22854.93929.stgit@ginnungagap.bsc.es> References: <20110406183341.22854.93929.stgit@ginnungagap.bsc.es> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Y-GMX-Trusted: 0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 213.165.64.23 Cc: stefanha@gmail.com, chouteau@adacore.com Subject: [Qemu-devel] [PATCH v2 06/11] trace: generalize the "property" concept in the trace-events file 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 This adds/modifies the following functions: * get_name: Get _only_ the event name * has_property: Return whether an event has a property (keyword before the event name) Signed-off-by: LluĂ­s Vilanova --- docs/tracing.txt | 6 ++-- scripts/tracetool | 73 ++++++++++++++++++++++++----------------------------- 2 files changed, 36 insertions(+), 43 deletions(-) diff --git a/docs/tracing.txt b/docs/tracing.txt index 34b0901..a9fd85b 100644 --- a/docs/tracing.txt +++ b/docs/tracing.txt @@ -38,7 +38,7 @@ generate code for the trace events. Trace events are invoked directly from source code like this: #include "trace.h" /* needed for trace event prototype */ - + void *qemu_malloc(size_t size) { void *ptr; @@ -98,7 +98,7 @@ portability macros, ensure they are preceded and followed by double quotes: 4. Name trace events after their function. If there are multiple trace events in one function, append a unique distinguisher at the end of the name. -5. Declare trace events with the "disable" keyword. Some trace events can +5. Declare trace events with the "disable" property. Some trace events can produce a lot of output and users are typically only interested in a subset of trace events. Marking trace events disabled by default saves the user from having to manually disable noisy trace events. @@ -168,7 +168,7 @@ The st_change_trace_event_state() function can be used to enable or disable trac events at runtime inside QEMU: #include "trace.h" - + st_change_trace_event_state("virtio_irq", true); /* enable */ [...] st_change_trace_event_state("virtio_irq", false); /* disable */ diff --git a/scripts/tracetool b/scripts/tracetool index d88cb43..6d8ead2 100755 --- a/scripts/tracetool +++ b/scripts/tracetool @@ -43,7 +43,26 @@ EOF # Get the name of a trace event get_name() { - echo ${1%%\(*} + local name + name=${1%%\(*} + echo "${name##* }" +} + +# Get the given property of a trace event +# 1: trace-events line +# 2: property name +# -> return 0 if property is present, or 1 otherwise +has_property() +{ + local props prop + props=${1%%\(*} + props=${props% *} + for prop in $props; do + if [ "$prop" = "$2" ]; then + return 0 + fi + done + return 1 } # Get the argument list of a trace event, including types and names @@ -101,20 +120,6 @@ 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 @@ -174,14 +179,10 @@ cast_args_to_uint64_t() linetoh_simple() { - local name args argc trace_args state + local name args argc trace_args 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 ] @@ -222,9 +223,10 @@ linetoc_simple() { local name state name=$(get_name "$1") - state=$(get_state "$1") - if [ "$state" = "0" ] ; then - name=${name##disable } + if has_property "$1" "disable"; then + state="0" + else + state="1" fi cat <