Patchwork [1/2] trace: always use the "nop" backend on events with the "disable" keyword

login
register
mail settings
Submitter =?utf-8?Q?Llu=C3=ADs?=
Date Nov. 8, 2010, 10:35 p.m.
Message ID <20101108223539.8577.36493.stgit@ginnungagap.bsc.es>
Download mbox | patch
Permalink /patch/70472/
State New
Headers show

Comments

=?utf-8?Q?Llu=C3=ADs?= - Nov. 8, 2010, 10:35 p.m.
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 a propery event is set (a keyword before the event
  name)

Signed-off-by: LluĂ­s Vilanova <vilanova@ac.upc.edu>
---
 tracetool |   66 +++++++++++++++++++++++++++++--------------------------------
 1 files changed, 31 insertions(+), 35 deletions(-)

Patch

diff --git a/tracetool b/tracetool
index 7010858..9b6f801 100755
--- a/tracetool
+++ b/tracetool
@@ -31,7 +31,31 @@  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% *}
+    if [ -z "$props" ]; then
+        echo "0"
+        return
+    fi
+    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 +112,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 +171,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 +213,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))
 }
@@ -321,16 +323,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