#define __tp_stringify(x) __tp_stringify1(x)
#undef TRACEPOINT_EVENT_INSTANCE
-#define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \
- _DEFINE_TRACEPOINT(_provider, _name)
+#define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args)
#undef TRACEPOINT_EVENT
#define TRACEPOINT_EVENT(_provider, _name, _args, _fields) \
#include <urcu-bp.h>
#include <tracepoint-types.h>
#include <urcu/compiler.h>
+#include <dlfcn.h> /* for dlopen */
#ifdef __cplusplus
extern "C" {
{ \
struct tracepoint_probe *__tp_probe; \
\
+ if (!rcu_read_lock_bp) \
+ return; \
rcu_read_lock_bp(); \
- __tp_probe = rcu_dereference(__tracepoint_##provider##___##name.probes); \
+ __tp_probe = rcu_dereference_bp(__tracepoint_##provider##___##name.probes); \
if (caa_unlikely(!__tp_probe)) \
goto end; \
do { \
__tracepoint_probe_unregister(name, func, data); \
}
+extern int __tracepoint_probe_register(const char *name, void *func, void *data);
+extern int __tracepoint_probe_unregister(const char *name, void *func, void *data);
+
+#ifdef TRACEPOINT_DEFINE
+
/*
* Note: to allow PIC code, we need to allow the linker to update the pointers
* in the __tracepoints_ptrs section.
__attribute__((used, section("__tracepoints_ptrs"))) = \
&__tracepoint_##provider##___##name;
-extern int __tracepoint_probe_register(const char *name, void *func, void *data);
-extern int __tracepoint_probe_unregister(const char *name, void *func, void *data);
-extern int tracepoint_register_lib(struct tracepoint * const *tracepoints_start,
+static int (*tracepoint_register_lib)(struct tracepoint * const *tracepoints_start,
int tracepoints_count);
-extern int tracepoint_unregister_lib(struct tracepoint * const *tracepoints_start);
+static int (*tracepoint_unregister_lib)(struct tracepoint * const *tracepoints_start);
+static void *liblttngust_handle;
/*
* These weak symbols, the constructor, and destructor take care of
{
if (__tracepoint_registered++)
return;
+
+ liblttngust_handle = dlopen("liblttng-ust.so", RTLD_NOW | RTLD_GLOBAL);
+ if (!liblttngust_handle)
+ return;
+ tracepoint_register_lib = dlsym(liblttngust_handle,
+ "tracepoint_register_lib");
+ tracepoint_unregister_lib = dlsym(liblttngust_handle,
+ "tracepoint_unregister_lib");
tracepoint_register_lib(__start___tracepoints_ptrs,
__stop___tracepoints_ptrs -
__start___tracepoints_ptrs);
static void __attribute__((destructor)) __tracepoints__destroy(void)
{
+ int ret;
if (--__tracepoint_registered)
return;
- tracepoint_unregister_lib(__start___tracepoints_ptrs);
+ if (tracepoint_unregister_lib)
+ tracepoint_unregister_lib(__start___tracepoints_ptrs);
+ if (liblttngust_handle) {
+ tracepoint_unregister_lib = NULL;
+ tracepoint_register_lib = NULL;
+ ret = dlclose(liblttngust_handle);
+ assert(!ret);
+ }
}
+#else /* TRACEPOINT_DEFINE */
+
+#define _DEFINE_TRACEPOINT(provider, name)
+
+#endif /* #else TRACEPOINT_DEFINE */
+
#ifdef __cplusplus
}
#endif
*/
#define TRACEPOINT_EVENT(provider, name, args, fields) \
- _DECLARE_TRACEPOINT(provider, name, _TP_PARAMS(args))
+ _DECLARE_TRACEPOINT(provider, name, _TP_PARAMS(args)) \
+ _DEFINE_TRACEPOINT(provider, name)
#define TRACEPOINT_EVENT_CLASS(provider, name, args, fields)
#define TRACEPOINT_EVENT_INSTANCE(provider, _template, name, args) \
- _DECLARE_TRACEPOINT(provider, name, _TP_PARAMS(args))
+ _DECLARE_TRACEPOINT(provider, name, _TP_PARAMS(args)) \
+ _DEFINE_TRACEPOINT(provider, name)
#endif /* #ifndef TRACEPOINT_EVENT */
* Dual LGPL v2.1/GPL v2 license.
*/
-/*
- * Create LTTng tracepoint probes.
- */
+#define TRACEPOINT_DEFINE
#define TRACEPOINT_CREATE_PROBES
-
#include "lttng-probe-ust.h"
AM_CPPFLAGS = -I$(top_srcdir)/include
+lib_LTLIBRARIES = liblttng-ust-provider-ust-tests-demo.la \
+ liblttng-ust-provider-ust-tests-demo3.la
+
+#contains ust_tests_demo.h and ust_tests_demo2.h provider probes
+liblttng_ust_provider_ust_tests_demo_la_SOURCES = \
+ tp.c ust_tests_demo.h \
+ tp2.c ust_tests_demo2.h
+liblttng_ust_provider_ust_tests_demo_la_LIBADD = \
+ $(top_builddir)/liblttng-ust/liblttng-ust.la
+
+#contains ust_tests_demo3.h provider probes
+liblttng_ust_provider_ust_tests_demo3_la_SOURCES = \
+ tp3.c ust_tests_demo3.h
+liblttng_ust_provider_ust_tests_demo3_la_LIBADD = \
+ $(top_builddir)/liblttng-ust/liblttng-ust.la
+
noinst_PROGRAMS = demo
-demo_SOURCES = demo.c tp.c ust_tests_demo.h
-demo_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la
+demo_SOURCES = demo.c ust_tests_demo.h
-This is a hello world application used to test the LTTng userspace tracer.
+This is a demo application used to test the LTTng userspace tracer.
+
+demo-trace shell script preloads the provider shared objects before
+executing the demo. Executing "demo" without the shell wrapper will not
+provide any tracing support. This ensures the demo binary can be
+distributed on distros without depending on having liblttng-ust.so in
+place. Note: the "demo" program must be compiled with "-ldl".
#include <string.h>
#include <arpa/inet.h>
+#define TRACEPOINT_DEFINE
#include "ust_tests_demo.h"
+#include "ust_tests_demo2.h"
+#include "ust_tests_demo3.h"
int main(int argc, char **argv)
{
tracepoint(ust_tests_demo, starting, 123);
for (i = 0; i < 5; i++) {
netint = htonl(i);
- tracepoint(ust_tests_demo, loop, i, netint, values,
+ tracepoint(ust_tests_demo2, loop, i, netint, values,
text, strlen(text), dbl, flt);
}
tracepoint(ust_tests_demo, done, 456);
+ tracepoint(ust_tests_demo3, done, 42);
fprintf(stderr, " done.\n");
return 0;
}
tp_loglevel(debug, 2)
)
-TRACEPOINT_EVENT(ust_tests_demo, loop,
- TP_ARGS(int, anint, int, netint, long *, values,
- char *, text, size_t, textlen,
- double, doublearg, float, floatarg),
- TP_FIELDS(
- ctf_integer(int, intfield, anint)
- ctf_integer_hex(int, intfield2, anint)
- ctf_integer(long, longfield, anint)
- ctf_integer_network(int, netintfield, netint)
- ctf_integer_network_hex(int, netintfieldhex, netint)
- ctf_array(long, arrfield1, values, 3)
- ctf_array_text(char, arrfield2, text, 10)
- ctf_sequence(char, seqfield1, text,
- size_t, textlen)
- ctf_sequence_text(char, seqfield2, text,
- size_t, textlen)
- ctf_string(stringfield, text)
- ctf_float(float, floatfield, floatarg)
- ctf_float(double, doublefield, doublearg)
- )
-)
-TRACEPOINT_LOGLEVEL(ust_tests_demo, loop, debug)
-
TRACEPOINT_EVENT(ust_tests_demo, starting,
TP_ARGS(int, value),
TP_FIELDS(
#include <sys/types.h>
#include <stdlib.h>
+#define TRACEPOINT_DEFINE
#define TRACEPOINT_CREATE_PROBES
#include "ust_tests_fork.h"
#include <stdio.h>
#include <unistd.h>
+#define TRACEPOINT_DEFINE
#define TRACEPOINT_CREATE_PROBES
#include "ust_tests_fork.h"
#include <string.h>
#include <arpa/inet.h>
+#define TRACEPOINT_DEFINE
#include "ust_tests_hello.h"
void inthandler(int sig)