Cleanup: tests: fix typos in sdt test app comments
[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
12#include <dlfcn.h>
13#include <fcntl.h>
14#include <stdbool.h>
15#include <stdint.h>
16#include <stdio.h>
17#include <sys/stat.h>
18#include <sys/types.h>
19
20#include <sys/sdt.h>
21
22#include "foobar_provider.h"
23#include "libfoo.h"
24#include "sema.h"
25
26int main(int argc, char *argv[])
27{
28 void *handle;
29 void (*bar_function)();
30
31 FOOBAR_TP1();
32 FOOBAR_TP2();
33 /*
a12fbf64
JG
34 * This SDT tracepoint has an argument. Argument extraction is not supported
35 * at the moment, but tracing of the tracepoint should work.
a9c2df2b
FD
36 */
37 FOOBAR_TP_WITH_ARG(42);
38
a12fbf64 39 /* Call a function containing an SDT tracepoint in shared object. */
a9c2df2b
FD
40 foo_function();
41
42 /*
a12fbf64 43 * Load a shared object and call a function containing an SDT
a9c2df2b
FD
44 * tracepoint
45 */
46 handle = dlopen("libbar.so", RTLD_LAZY);
47 if (!handle) {
48 fprintf(stderr, "Can't dlopen libbar.so");
49 return -1;
50 }
51 bar_function = (void (*)())dlsym(handle, "bar_function");
52 bar_function();
53 dlclose(handle);
54
a12fbf64 55 /* This tracepoint has 2 call sites in this binary. */
a9c2df2b
FD
56 FOOBAR_TP2();
57
58 /*
a12fbf64
JG
59 * This function is defined in libfoo and in libzzz. For a test, libzzz is
60 * LD_PRELOADed and should override this function.
a9c2df2b
FD
61 */
62 overridable_function();
63
64 /*
65 * This function is calling a SDT tracepoint that is guarded by a
66 * semaphore.
67 */
68 sema_function();
69 return 0;
70}
71
This page took 0.040341 seconds and 4 git commands to generate.