This patch adds LTTng Userspace Tracer (UST) backend support. The UST system requires no kernel support but libust and liburcu must be installed. $ ./configure --trace-backend ust $ make Start the UST daemon: $ ustd & List available tracepoints and enable some: $ ustctl --list-markers $(pgrep qemu) [...] {PID: 5458, channel/marker: ust/paio_submit, state: 0, fmt: "acb %p opaque %p sector_num %lu nb_sectors %lu type %lu" 0x4b32ba} $ ustctl --enable-marker "ust/paio_submit" $(pgrep qemu) Run the trace: $ ustctl --create-trace $(pgrep qemu) $ ustctl --start-trace $(pgrep qemu) [...] $ ustctl --stop-trace $(pgrep qemu) $ ustctl --destroy-trace $(pgrep qemu) Trace results can be viewed using lttv-gui. More information about UST: http://lttng.org/ust Signed-off-by: Stefan Hajnoczi <stefanha@xxxxxxxxxxxxxxxxxx> --- configure | 5 +++- tracetool | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 79 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 7d2c69b..675d0fc 100755 --- a/configure +++ b/configure @@ -829,7 +829,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 "" echo "NOTE: The object files are built at the place where configure is launched" exit 1 @@ -2302,6 +2302,9 @@ bsd) esac echo "TRACE_BACKEND=$trace_backend" >> $config_host_mak +if test "$trace_backend" = "ust"; then + LIBS="-lust $LIBS" +fi tools= if test `expr "$target_list" : ".*softmmu.*"` != 0 ; then diff --git a/tracetool b/tracetool index f094ddc..9ea9c08 100755 --- a/tracetool +++ b/tracetool @@ -3,12 +3,13 @@ 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 @@ -179,6 +180,78 @@ linetoc_end_simple() return } +linetoh_begin_ust() +{ + echo "#include <ust/tracepoint.h>" +} + +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() +{ + # Clean up after UST headers which pollute the namespace + cat <<EOF +#undef mutex_lock +#undef mutex_unlock +EOF +} + +linetoc_begin_ust() +{ + cat <<EOF +#include <ust/marker.h> +#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() { @@ -228,7 +301,7 @@ tracetoc() # Choose backend case "$1" in -"--nop" | "--simple") backend="${1#--}" ;; +"--nop" | "--simple" | "--ust") backend="${1#--}" ;; *) usage ;; esac shift -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html