Add trigger on event rule matches application example
[lttng-tools.git] / doc / examples / trigger-condition-event-matches / instrumented-app.c
diff --git a/doc/examples/trigger-condition-event-matches/instrumented-app.c b/doc/examples/trigger-condition-event-matches/instrumented-app.c
new file mode 100644 (file)
index 0000000..dce6e57
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ */
+
+#include "tracepoint-trigger-example.h"
+
+#include <lttng/tracepoint.h>
+#include <stdio.h>
+#include <sys/time.h>
+#include <time.h>
+#include <unistd.h>
+
+int main(int argc, char **argv)
+{
+       uint64_t i;
+
+       for (i = 0; i < UINT64_MAX; i++) {
+               char time_str[64];
+               struct timeval tv;
+               time_t the_time;
+
+               gettimeofday(&tv, NULL);
+               the_time = tv.tv_sec;
+
+               strftime(time_str, sizeof(time_str), "[%m-%d-%Y] %T",
+                               localtime(&the_time));
+               printf("%s.%ld - Tracing event \"trigger_example:my_event\"\n",
+                               time_str, tv.tv_usec);
+
+               tracepoint(trigger_example, my_event, i);
+               sleep(2);
+       }
+       return 0;
+}
This page took 0.023479 seconds and 4 git commands to generate.