From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:34903) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qz2In-0003kP-OS for qemu-devel@nongnu.org; Thu, 01 Sep 2011 04:07:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qz2Ib-0007i3-VA for qemu-devel@nongnu.org; Thu, 01 Sep 2011 04:07:04 -0400 Received: from mtagate7.uk.ibm.com ([194.196.100.167]:56257) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qz2Ib-0007Xq-Do for qemu-devel@nongnu.org; Thu, 01 Sep 2011 04:06:57 -0400 Received: from d06nrmr1307.portsmouth.uk.ibm.com (d06nrmr1307.portsmouth.uk.ibm.com [9.149.38.129]) by mtagate7.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p8186VR8027217 for ; Thu, 1 Sep 2011 08:06:31 GMT Received: from d06av09.portsmouth.uk.ibm.com (d06av09.portsmouth.uk.ibm.com [9.149.37.250]) by d06nrmr1307.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p8186V7R2408604 for ; Thu, 1 Sep 2011 09:06:31 +0100 Received: from d06av09.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p8186Uam020116 for ; Thu, 1 Sep 2011 02:06:30 -0600 From: Stefan Hajnoczi Date: Thu, 1 Sep 2011 09:06:18 +0100 Message-Id: <1314864386-14202-8-git-send-email-stefanha@linux.vnet.ibm.com> In-Reply-To: <1314864386-14202-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1314864386-14202-1-git-send-email-stefanha@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 07/15] trace: generalize the "property" concept in the trace-events file List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Anthony Liguori , =?UTF-8?q?Llu=C3=ADs?= , =?UTF-8?q?Llu=C3=ADs=20Vilanova?= From: Llu=C3=ADs This adds/modifies the following functions: * get_name: Get _only_ the event name * has_property: Return whether an event has a property (keyword before th= e event name) Signed-off-by: Llu=C3=ADs Vilanova --- docs/tracing.txt | 4 +- scripts/tracetool | 73 ++++++++++++++++++++++++-----------------------= ------ 2 files changed, 35 insertions(+), 42 deletions(-) diff --git a/docs/tracing.txt b/docs/tracing.txt index c99a0f2..1ad106a 100644 --- a/docs/tracing.txt +++ b/docs/tracing.txt @@ -38,7 +38,7 @@ generate code for the trace events. Trace events are i= nvoked directly from source code like this: =20 #include "trace.h" /* needed for trace event prototype */ - + =20 void *qemu_malloc(size_t size) { void *ptr; @@ -103,7 +103,7 @@ portability macros, ensure they are preceded and foll= owed 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. =20 -5. Declare trace events with the "disable" keyword. Some trace events c= an +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. diff --git a/scripts/tracetool b/scripts/tracetool index 9ed4fae..e649a5b 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=3D${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=3D${1%%\(*} + props=3D${props% *} + for prop in $props; do + if [ "$prop" =3D "$2" ]; then + return 0 + fi + done + return 1 } =20 # Get the argument list of a trace event, including types and names @@ -101,20 +120,6 @@ get_fmt() echo "$fmt" } =20 -# Get the state of a trace event -get_state() -{ - local str disable state - str=3D$(get_name "$1") - disable=3D${str##disable } - if [ "$disable" =3D "$str" ] ; then - state=3D1 - else - state=3D0 - fi - echo "$state" -} - linetoh_begin_nop() { return @@ -174,14 +179,10 @@ cast_args_to_uint64_t() =20 linetoh_simple() { - local name args argc trace_args state + local name args argc trace_args name=3D$(get_name "$1") args=3D$(get_args "$1") argc=3D$(get_argc "$1") - state=3D$(get_state "$1") - if [ "$state" =3D "0" ]; then - name=3D${name##disable } - fi =20 trace_args=3D"$simple_event_num" if [ "$argc" -gt 0 ] @@ -222,9 +223,10 @@ linetoc_simple() { local name state name=3D$(get_name "$1") - state=3D$(get_state "$1") - if [ "$state" =3D "0" ] ; then - name=3D${name##disable } + if has_property "$1" "disable"; then + state=3D"0" + else + state=3D"1" fi cat <