Clean-up: run format-cpp on the tree
[lttng-tools.git] / tests / utils / testapp / userspace-probe-sdt-binary / userspace-probe-sdt-binary.c
CommitLineData
a9c2df2b 1/*
9d16b343 2 * Copyright (C) 2017 Francis Deslauriers <francis.deslauriers@efficios.com>
a9c2df2b 3 *
9d16b343 4 * SPDX-License-Identifier: LGPL-2.1-or-later
a9c2df2b 5 *
a9c2df2b 6 */
9d16b343 7
a9c2df2b
FD
8#ifndef _GNU_SOURCE
9#define _GNU_SOURCE
10#endif
11
28f23191
JG
12#include "foobar_provider.h"
13#include "libfoo.h"
14#include "sema.h"
15
a9c2df2b
FD
16#include <dlfcn.h>
17#include <fcntl.h>
18#include <stdbool.h>
19#include <stdint.h>
20#include <stdio.h>
28f23191 21#include <sys/sdt.h>
a9c2df2b
FD
22#include <sys/stat.h>
23#include <sys/types.h>
24
a9c2df2b
FD
25int main(int argc, char *argv[])
26{
27 void *handle;
28 void (*bar_function)();
29
30 FOOBAR_TP1();
31 FOOBAR_TP2();
32 /*
a12fbf64
JG
33 * This SDT tracepoint has an argument. Argument extraction is not supported
34 * at the moment, but tracing of the tracepoint should work.
a9c2df2b
FD
35 */
36 FOOBAR_TP_WITH_ARG(42);
37
a12fbf64 38 /* Call a function containing an SDT tracepoint in shared object. */
a9c2df2b
FD
39 foo_function();
40
41 /*
a12fbf64 42 * Load a shared object and call a function containing an SDT
a9c2df2b
FD
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 }
28f23191 50 bar_function = (void (*)()) dlsym(handle, "bar_function");
a9c2df2b
FD
51 bar_function();
52 dlclose(handle);
53
a12fbf64 54 /* This tracepoint has 2 call sites in this binary. */
a9c2df2b
FD
55 FOOBAR_TP2();
56
57 /*
a12fbf64
JG
58 * This function is defined in libfoo and in libzzz. For a test, libzzz is
59 * LD_PRELOADed and should override this function.
a9c2df2b
FD
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.04309 seconds and 4 git commands to generate.