]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
lttng: build the tracepoint provider lib from .c files in repo 11196/head
authorKefu Chai <kchai@redhat.com>
Thu, 22 Sep 2016 02:40:17 +0000 (10:40 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 22 Sep 2016 13:24:02 +0000 (21:24 +0800)
we should not have `TRACEPOINT_DEFINE` deinfed in both the application
we are tracing and the tracing provider library.

* tracing/*.c: reference the header file with path
* README.md: add instructions to add .c file
* CMakeLists.c:
  - compile the .c file in repo, not the one generated by
    lttng-gen-tp
  - no need to mark the generated header file as GENEREATED,
    they are marked so by default (they are listed in OUTPUT)
  - do not generate .c file anymore, they are not used.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/tracing/CMakeLists.txt
src/tracing/README.md
src/tracing/librados.c
src/tracing/librbd.c
src/tracing/objectstore.c
src/tracing/oprequest.c
src/tracing/osd.c
src/tracing/pg.c

index 8cde4fbc0344545baf874870c5463ffe5912967b..c434e62f595c74c0c576f507a88e2a4a39f8c28f 100644 (file)
@@ -2,22 +2,20 @@
 # the source files include the tracing headers like
 # #include "tracing/oprequest.h". so better put them into
 # ${PROJECT_BINARY_DIR}/include, where acconfig.h is also located
-set(header_dir ${CMAKE_BINARY_DIR}/include/tracing)
+set(working_dir ${CMAKE_BINARY_DIR}/include)
+set(header_dir ${working_dir}/tracing)
 file(MAKE_DIRECTORY ${header_dir})
 
 file(GLOB tps "*.tp")
 foreach(tp ${tps})
   get_filename_component(name ${tp} NAME_WE)
   set(header ${header_dir}/${name}.h)
-  set(src ${header_dir}/${name}.c)
   add_custom_command(
-    OUTPUT ${header} ${src}
-    COMMAND ${LTTNG_GEN_TP} ${tp} -o tracing/${name}.h -o tracing/${name}.c
+    OUTPUT ${header}
+    COMMAND ${LTTNG_GEN_TP} ${tp} -o tracing/${name}.h
     DEPENDS ${tp}
-    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/include
-    COMMENT "generating ${header} ${src}")
-  set_source_files_properties(${header} ${src}
-    PROPERTIES GENERATED TRUE)
+    WORKING_DIRECTORY ${working_dir}
+    COMMENT "generating ${header}")
   add_custom_target(
     ${name}-tp
     DEPENDS ${header})
@@ -28,11 +26,8 @@ function(add_tracing_library name tracings version)
     get_filename_component(tp ${tp_file} NAME_WE)
     list(APPEND hdrs
       ${header_dir}/${tp}.h)
-    list(APPEND srcs
-      ${header_dir}/${tp}.h
-      ${header_dir}/${tp}.c)
   endforeach()
-  add_library(${name} SHARED ${srcs})
+  add_library(${name} SHARED ${hdrs} ${tp}.c)
   target_link_libraries(${name} ${LTTNGUST_LIBRARIES} ${CMAKE_DL_LIBS})
   string(REGEX MATCH "^[0-9]+" soversion ${version})
   set_target_properties(${name} PROPERTIES
index 15f1ac60a4dc0ca27a51ed1be89373d909e0a744..dea1d20a2c5fe492a08988b026aacb8435fa656c 100644 (file)
@@ -13,12 +13,17 @@ Then install as normal
     apt-get install lttng-tools liblttng-ust-dev
 
 Add/Update Provider
-================
+===================
 
 ## Create tracepoint definition file
 
 Add tracepoint definitions for the provider into a `.tp` file. Documentation
 on defining a tracepoint can be found in `man lttng-ust`. By convention files
 are named according to the logical sub-system they correspond to (e.g.
-`mutex.tp`, `pg.tp`). Place the `.tp` file into the `src/tracing` directory
+`mutex.tp`, `pg.tp`). And add a C source file to be compiled into the tracepoint
+provider shared object, in which `TRACEPOINT_DEFINE` should be defined. See
+[LTTng document](http://lttng.org/docs/#doc-dynamic-linking) for details.
+Place the `.tp` and the `.c` files into the `src/tracing` directory
 and modify the CMake file `src/tracing/CMakeLists.txt` accordingly.
+
+
index 5b8d4d66a446faf566f5cfdfc234c819cfde17f2..ae25f3e3b0e8c01a16ade3de6b8c9dbeb4e4dfa2 100644 (file)
@@ -3,4 +3,4 @@
 /*
  * The header containing our TRACEPOINT_EVENTs.
  */
-#include "librados.h"
+#include "tracing/librados.h"
index 6e5977c4650b857eec8cdb27f1eb9e0e4595817d..c70bf8ef903c23160a2a2f544b48f2df5840f420 100644 (file)
@@ -3,4 +3,4 @@
 /*
  * The header containing our TRACEPOINT_EVENTs.
  */
-#include "librbd.h"
+#include "tracing/librbd.h"
index 21bbf271ac153ea7ae0ed26e2b38057212b7fd9e..c1ec0eb138467fc1bc53f025324f65e616756419 100644 (file)
@@ -3,4 +3,4 @@
 /*
  * The header containing our TRACEPOINT_EVENTs.
  */
-#include "objectstore.h"
+#include "tracing/objectstore.h"
index 02f1fc53d0527fed2e26c3d04a6573e6712f6749..1daa37f8335b47ff9ee416786169431e1a9f1ff9 100644 (file)
@@ -3,4 +3,4 @@
 /*
  * The header containing our TRACEPOINT_EVENTs.
  */
-#include "oprequest.h"
+#include "tracing/oprequest.h"
index ff70ddfff8739955537e9ccd7ce266dd12e3e022..5f6781491f0fbb02e211541475fccd262fb4e3d0 100644 (file)
@@ -3,4 +3,4 @@
 /*
  * The header containing our TRACEPOINT_EVENTs.
  */
-#include "osd.h"
+#include "tracing/osd.h"
index 661ebb7729bcacf059c33e43bad84029ab0c6aa3..1373ed5e4c1d142d668939de58abfa87dc82c060 100644 (file)
@@ -3,4 +3,4 @@
 /*
  * The header containing our TRACEPOINT_EVENTs.
  */
-#include "pg.h"
+#include "tracing/pg.h"