diff options
| author | Manuel Traut <manut@linutronix.de> | 2017-08-25 15:44:50 +0200 |
|---|---|---|
| committer | John Ogness <john.ogness@linutronix.de> | 2017-12-19 11:38:06 +0100 |
| commit | 4d5f8223acb7ab90af7fc4b8aa1c391838c1af21 (patch) | |
| tree | 63ee8b04ff3285c73832058fb064f883bdc15574 /application-devel/tracing/lttng-c/trace.sh | |
| parent | 77a4d59ce232c27b63068390401e723488630c3c (diff) | |
add a userspace tracing example
using lttng-ust, perf and tshark
traces can be shown in tracecompass
Signed-off-by: Manuel Traut <manut@linutronix.de>
Diffstat (limited to 'application-devel/tracing/lttng-c/trace.sh')
| -rwxr-xr-x | application-devel/tracing/lttng-c/trace.sh | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/application-devel/tracing/lttng-c/trace.sh b/application-devel/tracing/lttng-c/trace.sh new file mode 100755 index 0000000..5a52bee --- /dev/null +++ b/application-devel/tracing/lttng-c/trace.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +USERID=`id -u` +TSTAMP=`date +%Y%m%d-%H%M%S` +UDIR=$HOME +CURDIR=`pwd` + +PERF_VERSION="$(uname -r)" +PERF_VERSION="${PERF_VERSION%%-*}" +case "$PERF_VERSION" in + *.*.*) + PERF_VERSION="${PERF_VERSION%.*}" + ;; +esac + + +sudo modprobe usbmon + +tshark -F pcap -i eth0 -w ~/lttng-traces/network-$TSTAMP.pcap & +#sudo and -F pcap is not working atm sudo is needed for usbmon +#sudo tshark -F pcap -i usbmon0 -w ~/lttng-traces/usb-$TSTAMP.pcap & + +lttng create lttng-ust +lttng list --userspace +lttng enable-event --userspace hello_world:my_first_tracepoint +lttng start + +mkdir -p uprobe-traces +cd uprobe-traces +sudo perf probe -x $CURDIR/hellolttngust MYEVENT=$CURDIR/hellolttngust.c:8 +sudo perf probe -x $CURDIR/hellolttngust EVNAME=$CURDIR/hellolttngust.c:35 +sudo perf record -e probe_hellolttngust:MYEVENT -e probe_hellolttngust:EVNAME & +cd - + +mkdir -p kernel-traces +cd kernel-traces +sudo perf record -e sched:sched_switch & +cd - + +./hellolttngust huhu haha hihi + +sudo killall perf_$PERF_VERSION +killall tshark +#sudo killall tshark + +lttng stop +lttng destroy + +echo wait for writing perf data +wait + +cd uprobe-traces +sudo perf data convert --to-ctf=$UDIR/lttng-traces/perf-uprobes-$TSTAMP +sudo perf probe -d probe_hellolttngust:MYEVENT +sudo perf probe -d probe_hellolttngust:EVNAME +cd - + +cd kernel-traces +sudo perf data convert --to-ctf=$UDIR/lttng-traces/perf-kernel-$TSTAMP +cd - + +sudo chown -R $USERID $UDIR/lttng-traces/* |
