Any event with the keyword/property "disable" generates an empty trace event using the "nop" backend, regardless of the current backend.
Generalize the "property" concept in the trace-events file, so tracetool now has: * get_name: Get only the event name * get_property: Return if an event property is set (a keyword before the event name) Signed-off-by: Lluís Vilanova <vilan...@ac.upc.edu> --- tracetool | 62 +++++++++++++++++++++++++++---------------------------------- 1 files changed, 27 insertions(+), 35 deletions(-) diff --git a/tracetool b/tracetool index f0fe01d..4afeee9 100755 --- a/tracetool +++ b/tracetool @@ -31,7 +31,27 @@ 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 +# -> "1" if property is present; "0" otherwise +get_property() +{ + local props prop + props=${1%%\(*} + props=${props% *} + for prop in $props; do + if [ "$prop" = "$2" ]; then + echo "1" + return + fi + done + echo "0" } # Get the argument list of a trace event, including types and names @@ -88,20 +108,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 @@ -161,14 +167,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 ] @@ -207,14 +209,10 @@ EOF linetoc_simple() { - local name state + local name name=$(get_name "$1") - state=$(get_state "$1") - if [ "$state" = "0" ] ; then - name=${name##disable } - fi cat <<EOF -{.tp_name = "$name", .state=$state}, +{.tp_name = "$name", .state=0}, EOF simple_event_num=$((simple_event_num + 1)) } @@ -322,16 +320,10 @@ convert() test -z "${str%%#*}" && continue # Process the line. The nop backend handles disabled lines. - disable=${str%%disable *} + disable=$(get_property "$str" "disable") echo - if test -z "$disable"; then - # Pass the disabled state as an arg to lineto$1_simple(). - # For all other cases, call lineto$1_nop() - if [ $backend = "simple" ]; then - "$process_line" "$str" - else - "lineto$1_nop" "${str##disable }" - fi + if [ "$disable" = "1" ]; then + "lineto$1_nop" "$str" else "$process_line" "$str" fi