diff options
-rwxr-xr-x | configure | 20 | ||||
-rwxr-xr-x | tracetool | 85 |
2 files changed, 102 insertions, 3 deletions
@@ -903,7 +903,7 @@ echo " --enable-docs enable documentation build" echo " --disable-docs disable documentation build" echo " --disable-vhost-net disable vhost-net acceleration support" echo " --enable-vhost-net enable vhost-net acceleration support" -echo " --trace-backend=B Trace backend nop simple" +echo " --trace-backend=B Trace backend nop simple ust" echo " --trace-file=NAME Full PATH,NAME of file to store traces" echo " Default:trace-<pid>" echo "" @@ -2080,6 +2080,24 @@ if test "$?" -ne 0 ; then exit 1 fi +########################################## +# For 'ust' backend, test if ust headers are present +if test "$trace_backend" = "ust"; then + cat > $TMPC << EOF +#include <ust/tracepoint.h> +#include <ust/marker.h> +int main(void) { return 0; } +EOF + if compile_prog "" "" ; then + LIBS="-lust $LIBS" + else + echo + echo "Error: Trace backend 'ust' missing libust header files" + echo + exit 1 + fi +fi +########################################## # End of CC checks # After here, no more $cc or $ld runs @@ -13,12 +13,13 @@ set -f usage() { cat >&2 <<EOF -usage: $0 [--nop | --simple] [-h | -c] +usage: $0 [--nop | --simple | --ust] [-h | -c] Generate tracing code for a file on stdin. Backends: --nop Tracing disabled --simple Simple built-in backend + --ust LTTng User Space Tracing backend Output formats: -h Generate .h file @@ -225,6 +226,86 @@ linetoc_end_simple() EOF } +# Clean up after UST headers which pollute the namespace +ust_clean_namespace() { + cat <<EOF +#undef mutex_lock +#undef mutex_unlock +#undef inline +#undef wmb +EOF +} + +linetoh_begin_ust() +{ + echo "#include <ust/tracepoint.h>" + ust_clean_namespace +} + +linetoh_ust() +{ + local name args argnames + name=$(get_name "$1") + args=$(get_args "$1") + argnames=$(get_argnames "$1") + + cat <<EOF +DECLARE_TRACE(ust_$name, TPPROTO($args), TPARGS($argnames)); +#define trace_$name trace_ust_$name +EOF +} + +linetoh_end_ust() +{ + return +} + +linetoc_begin_ust() +{ + cat <<EOF +#include <ust/marker.h> +$(ust_clean_namespace) +#include "trace.h" +EOF +} + +linetoc_ust() +{ + local name args argnames fmt + name=$(get_name "$1") + args=$(get_args "$1") + argnames=$(get_argnames "$1") + fmt=$(get_fmt "$1") + + cat <<EOF +DEFINE_TRACE(ust_$name); + +static void ust_${name}_probe($args) +{ + trace_mark(ust, $name, "$fmt", $argnames); +} +EOF + + # Collect names for later + names="$names $name" +} + +linetoc_end_ust() +{ + cat <<EOF +static void __attribute__((constructor)) trace_init(void) +{ +EOF + + for name in $names; do + cat <<EOF + register_trace_ust_$name(ust_${name}_probe); +EOF + done + + echo "}" +} + # Process stdin by calling begin, line, and end functions for the backend convert() { @@ -282,7 +363,7 @@ tracetoc() # Choose backend case "$1" in -"--nop" | "--simple") backend="${1#--}" ;; +"--nop" | "--simple" | "--ust") backend="${1#--}" ;; *) usage ;; esac shift |