Clean-up: run format-cpp on the tree
[lttng-tools.git] / tests / utils / testapp / userspace-probe-sdt-binary / userspace-probe-sdt-binary.c
1 /*
2 * Copyright (C) 2017 Francis Deslauriers <francis.deslauriers@efficios.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-or-later
5 *
6 */
7
8 #ifndef _GNU_SOURCE
9 #define _GNU_SOURCE
10 #endif
11
12 #include "foobar_provider.h"
13 #include "libfoo.h"
14 #include "sema.h"
15
16 #include <dlfcn.h>
17 #include <fcntl.h>
18 #include <stdbool.h>
19 #include <stdint.h>
20 #include <stdio.h>
21 #include <sys/sdt.h>
22 #include <sys/stat.h>
23 #include <sys/types.h>
24
25 int main(int argc, char *argv[])
26 {
27 void *handle;
28 void (*bar_function)();
29
30 FOOBAR_TP1();
31 FOOBAR_TP2();
32 /*
33 * This SDT tracepoint has an argument. Argument extraction is not supported
34 * at the moment, but tracing of the tracepoint should work.
35 */
36 FOOBAR_TP_WITH_ARG(42);
37
38 /* Call a function containing an SDT tracepoint in shared object. */
39 foo_function();
40
41 /*
42 * Load a shared object and call a function containing an SDT
43 * tracepoint
44 */
45 handle = dlopen("libbar.so", RTLD_LAZY);
46 if (!handle) {
47 fprintf(stderr, "Can't dlopen libbar.so");
48 return -1;
49 }
50 bar_function = (void (*)()) dlsym(handle, "bar_function");
51 bar_function();
52 dlclose(handle);
53
54 /* This tracepoint has 2 call sites in this binary. */
55 FOOBAR_TP2();
56
57 /*
58 * This function is defined in libfoo and in libzzz. For a test, libzzz is
59 * LD_PRELOADed and should override this function.
60 */
61 overridable_function();
62
63 /*
64 * This function is calling a SDT tracepoint that is guarded by a
65 * semaphore.
66 */
67 sema_function();
68 return 0;
69 }
This page took 0.030228 seconds and 4 git commands to generate.