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/hellolttngust.c | |
| 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/hellolttngust.c')
| -rw-r--r-- | application-devel/tracing/lttng-c/hellolttngust.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/application-devel/tracing/lttng-c/hellolttngust.c b/application-devel/tracing/lttng-c/hellolttngust.c new file mode 100644 index 0000000..11c8bd7 --- /dev/null +++ b/application-devel/tracing/lttng-c/hellolttngust.c @@ -0,0 +1,42 @@ +#include <stdio.h> +#include "hello-tp.h" + +int main(int argc, char *argv[]) +{ + int x; + + puts("Hello, World!\nPress Enter to continue..."); + + /* + * The following getchar() call is only placed here for the purpose + * of this demonstration, to pause the application in order for + * you to have time to list its tracepoints. It is not + * needed otherwise. + */ + getchar(); + + /* + * A tracepoint() call. + * + * Arguments, as defined in hello-tp.h: + * + * 1. Tracepoint provider name (required) + * 2. Tracepoint name (required) + * 3. my_integer_arg (first user-defined argument) + * 4. my_string_arg (second user-defined argument) + * + * Notice the tracepoint provider and tracepoint names are + * NOT strings: they are in fact parts of variables that the + * macros in hello-tp.h create. + */ + tracepoint(hello_world, my_first_tracepoint, 23, "hi there!"); + + for (x = 0; x < argc; ++x) { + tracepoint(hello_world, my_first_tracepoint, x, argv[x]); + } + + puts("Quitting now!"); + tracepoint(hello_world, my_first_tracepoint, x * x, "x^2"); + + return 0; +} |
