From 49926043c1319ce99481d45c87c602c20b9dbb79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs?= Date: Wed, 31 Aug 2011 20:31:10 +0200 Subject: trace: generalize the "property" concept in the trace-events file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 | 4 +-- scripts/tracetool | 73 +++++++++++++++++++++++++------------------------------ 2 files changed, 35 insertions(+), 42 deletions(-) diff --git a/docs/tracing.txt b/docs/tracing.txt index c99a0f27cf..1ad106a5d7 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; @@ -103,7 +103,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. diff --git a/scripts/tracetool b/scripts/tracetool index 9ed4fae70f..e649a5b807 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 <