diff options
Diffstat (limited to 'scripts/tracetool')
-rwxr-xr-x | scripts/tracetool | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/scripts/tracetool b/scripts/tracetool index 2155a57df..743d24628 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 @@ -158,7 +163,7 @@ linetoc_end_nop() linetoh_begin_simple() { cat <<EOF -#include "simpletrace.h" +#include "trace/simple.h" EOF simple_event_num=0 @@ -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 ] @@ -220,14 +221,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)) } @@ -244,7 +241,12 @@ linetoh_begin_stderr() { cat <<EOF #include <stdio.h> +#include "trace/stderr.h" + +extern TraceEvent trace_list[]; EOF + + stderr_event_num=0 } linetoh_stderr() @@ -263,29 +265,47 @@ linetoh_stderr() cat <<EOF static inline void trace_$name($args) { - fprintf(stderr, "$name $fmt\n" $argnames); + if (trace_list[$stderr_event_num].state != 0) { + fprintf(stderr, "$name $fmt\n" $argnames); + } } EOF + stderr_event_num=$((stderr_event_num + 1)) + } linetoh_end_stderr() { -return + cat <<EOF +#define NR_TRACE_EVENTS $stderr_event_num +EOF } linetoc_begin_stderr() { -return + cat <<EOF +#include "trace.h" + +TraceEvent trace_list[] = { +EOF + stderr_event_num=0 } linetoc_stderr() { -return + local name + name=$(get_name "$1") + cat <<EOF +{.tp_name = "$name", .state=0}, +EOF + stderr_event_num=$(($stderr_event_num + 1)) } linetoc_end_stderr() { -return + cat <<EOF +}; +EOF } #END OF STDERR @@ -379,14 +399,10 @@ EOF linetoh_dtrace() { - local name args argnames state nameupper + local name args argnames nameupper name=$(get_name "$1") args=$(get_args "$1") argnames=$(get_argnames "$1", ",") - state=$(get_state "$1") - if [ "$state" = "0" ] ; then - name=${name##disable } - fi nameupper=`echo $name | tr '[:lower:]' '[:upper:]'` @@ -430,13 +446,9 @@ EOF linetod_dtrace() { - local name args state + local name args name=$(get_name "$1") args=$(get_args "$1") - state=$(get_state "$1") - if [ "$state" = "0" ] ; then - name=${name##disable } - fi # DTrace provider syntax expects foo() for empty # params, not foo(void) @@ -464,14 +476,10 @@ linetostap_begin_dtrace() linetostap_dtrace() { - local i arg name args arglist state + local i arg name args arglist name=$(get_name "$1") args=$(get_args "$1") arglist=$(get_argnames "$1", "") - state=$(get_state "$1") - if [ "$state" = "0" ] ; then - name=${name##disable } - fi # Define prototype for probe arguments cat <<EOF @@ -516,18 +524,10 @@ convert() # Skip comments and empty lines test -z "${str%%#*}" && continue - # Process the line. The nop backend handles disabled lines. - disable=${str%%disable *} echo - if test -z "$disable"; then - # Pass the disabled state as an arg for the simple - # or DTrace backends which handle it dynamically. - # For all other backends, call lineto$1_nop() - if [ $backend = "simple" -o "$backend" = "dtrace" ]; then - "$process_line" "$str" - else - "lineto$1_nop" "${str##disable }" - fi + # Process the line. The nop backend handles disabled lines. + if has_property "$str" "disable"; then + "lineto$1_nop" "$str" else "$process_line" "$str" fi |