Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ gcc -c -o mon_foo.o mon_foo.c -I.
- $ g++ -c -o sample.o sample.cc
- $ g++ -o sample mon_foo.o sample.o -ldl -llttng-ust
- sample.o:(__tracepoints+0x0): multiple definition of `__tracepoint_mon___monfoo'
- mon_foo.o:(__tracepoints+0x0): first defined here
- collect2: ld returned 1 exit status
- mon_foo.h
- --- 8< ----
- #undef TRACEPOINT_PROVIDER
- #define TRACEPOINT_PROVIDER mon
- #undef TRACEPOINT_INCLUDE_FILE
- #define TRACEPOINT_INCLUDE_FILE ./mon_foo.h
- #if !defined(_MON_FOO_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
- #define _MON_FOO_H
- #include <lttng/tracepoint.h>
- #ifdef __cplusplus
- extern "C" {
- #endif /*__cplusplus */
- TRACEPOINT_EVENT(
- mon,
- monfoo,
- TP_ARGS(int, s),
- TP_FIELDS(
- ctf_integer(int, state, s)
- )
- )
- #endif /* _MON_FOO_H */
- #include <lttng/tracepoint-event.h>
- #ifdef __cplusplus
- }
- #endif /*__cplusplus */
- --- 8< ---
- mon_foo.c
- --- 8< ---
- #define TRACEPOINT_CREATE_PROBES
- /*
- * The header containing our TRACEPOINT_EVENTs.
- */
- #define TRACEPOINT_DEFINE
- #include "mon_foo.h"
- --- 8< ---
- sample.cc
- --- 8< ---
- #include <unistd.h>
- /*
- * We need to define TRACEPOINT_DEFINE in one C file in the program
- * before including provider headers.
- */
- #define TRACEPOINT_DEFINE
- #include "mon_foo.h"
- int main(int argc, char **argv)
- {
- int i = 0;
- for (i = 0; i < 100000; i++) {
- tracepoint(mon, monfoo, i);
- usleep(1);
- }
- return 0;
- }
- --- 8< ---
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement