Advertisement
jecluis

Untitled

Oct 10th, 2012
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. $ gcc -c -o mon_foo.o mon_foo.c -I.
  2. $ g++ -c -o sample.o sample.cc
  3. $ g++ -o sample mon_foo.o sample.o -ldl -llttng-ust
  4. sample.o:(__tracepoints+0x0): multiple definition of `__tracepoint_mon___monfoo'
  5. mon_foo.o:(__tracepoints+0x0): first defined here
  6. collect2: ld returned 1 exit status
  7.  
  8. mon_foo.h
  9. --- 8< ----
  10. #undef TRACEPOINT_PROVIDER
  11. #define TRACEPOINT_PROVIDER mon
  12.  
  13. #undef TRACEPOINT_INCLUDE_FILE
  14. #define TRACEPOINT_INCLUDE_FILE ./mon_foo.h
  15.  
  16. #if !defined(_MON_FOO_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
  17. #define _MON_FOO_H
  18.  
  19. #include <lttng/tracepoint.h>
  20.  
  21.  
  22.  
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif /*__cplusplus */
  26.  
  27. TRACEPOINT_EVENT(
  28. mon,
  29. monfoo,
  30. TP_ARGS(int, s),
  31. TP_FIELDS(
  32. ctf_integer(int, state, s)
  33. )
  34. )
  35.  
  36. #endif /* _MON_FOO_H */
  37.  
  38. #include <lttng/tracepoint-event.h>
  39.  
  40. #ifdef __cplusplus
  41. }
  42. #endif /*__cplusplus */
  43. --- 8< ---
  44.  
  45. mon_foo.c
  46. --- 8< ---
  47. #define TRACEPOINT_CREATE_PROBES
  48. /*
  49. * The header containing our TRACEPOINT_EVENTs.
  50. */
  51. #define TRACEPOINT_DEFINE
  52. #include "mon_foo.h"
  53. --- 8< ---
  54.  
  55. sample.cc
  56. --- 8< ---
  57. #include <unistd.h>
  58.  
  59. /*
  60. * We need to define TRACEPOINT_DEFINE in one C file in the program
  61. * before including provider headers.
  62. */
  63. #define TRACEPOINT_DEFINE
  64. #include "mon_foo.h"
  65.  
  66. int main(int argc, char **argv)
  67. {
  68. int i = 0;
  69.  
  70. for (i = 0; i < 100000; i++) {
  71.  
  72. tracepoint(mon, monfoo, i);
  73. usleep(1);
  74. }
  75. return 0;
  76. }
  77. --- 8< ---
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement