barectf-tracepoint: add QEMU ARM target example
[barectf.git] / doc / examples / barectf-tracepoint / barectf-tracepoint.c
1 #include <stdio.h>
2 #include <stdint.h>
3 #include <stdlib.h>
4 #include <time.h>
5
6 #if defined(WITH_LTTNG_UST)
7 #include "barectf-tracepoint-lttng-ust.h"
8 #elif defined(WITH_QEMU_ARM_UART)
9 #include "barectf-tracepoint-qemu-arm-uart.h"
10 #else
11 #include "barectf-tracepoint-linux-fs.h"
12 #endif
13
14 enum state_t {
15 NEW,
16 TERMINATED,
17 READY,
18 RUNNING,
19 WAITING,
20 };
21
22 static void trace_stuff(int argc, char *argv[])
23 {
24 int i;
25 const char *str;
26
27 /* record 40000 events */
28 for (i = 0; i < 5000; ++i) {
29 str = argv[i % argc];
30 tracepoint(barectf_tp, simple_uint32, i * 1500);
31 tracepoint(barectf_tp, simple_int16, -i * 2);
32 tracepoint(barectf_tp, simple_float, (float) i / 1.23);
33 tracepoint(barectf_tp, simple_string, str);
34 tracepoint(barectf_tp, simple_enum, RUNNING);
35 tracepoint(barectf_tp, a_few_fields, -1, 301, -3.14159,
36 str, NEW);
37 tracepoint(barectf_tp, bit_packed_integers, 1, -1, 3,
38 -2, 2, 7, 23, -55, 232);
39 tracepoint(barectf_tp, simple_enum, TERMINATED);
40 }
41 }
42
43 #define NUM_STRINGS 5
44
45 static char *strings[] = {
46 "orange",
47 "mandarine",
48 "lemon",
49 "lime",
50 "grapefruit",
51 };
52
53 int main(int argc, char *argv[])
54 {
55 init_tracing();
56
57 if (argc <= 1) {
58 /* use static strings if there's nothing interesting in argv */
59 argc = NUM_STRINGS;
60 argv = strings;
61 }
62
63 trace_stuff(argc, argv);
64 fini_tracing();
65
66 return 0;
67 }
This page took 0.03217 seconds and 4 git commands to generate.