From 40092071e95fa0c4c58f7ea85889e237c8572ed2 Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Fri, 28 Feb 2020 17:37:47 -0500 Subject: [PATCH 1/3] Use '#ifdef' instead of '#if defined()` Signed-off-by: Christophe Bedard --- tracetools/src/tracetools.c | 4 ++-- tracetools/src/utils.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tracetools/src/tracetools.c b/tracetools/src/tracetools.c index 4ea04da..4b3781e 100644 --- a/tracetools/src/tracetools.c +++ b/tracetools/src/tracetools.c @@ -16,7 +16,7 @@ #ifndef TRACETOOLS_DISABLED -#if defined(TRACETOOLS_LTTNG_ENABLED) +#ifdef TRACETOOLS_LTTNG_ENABLED # include "tracetools/tp_call.h" # define CONDITIONAL_TP(...) \ tracepoint(TRACEPOINT_PROVIDER, __VA_ARGS__) @@ -26,7 +26,7 @@ bool ros_trace_compile_status() { -#if defined(TRACETOOLS_LTTNG_ENABLED) +#ifdef TRACETOOLS_LTTNG_ENABLED return true; #else return false; diff --git a/tracetools/src/utils.cpp b/tracetools/src/utils.cpp index 352f0a2..ef2e9ad 100644 --- a/tracetools/src/utils.cpp +++ b/tracetools/src/utils.cpp @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#if defined(TRACETOOLS_LTTNG_ENABLED) +#ifdef TRACETOOLS_LTTNG_ENABLED #include #include #endif @@ -20,7 +20,7 @@ const char * _demangle_symbol(const char * mangled) { -#if defined(TRACETOOLS_LTTNG_ENABLED) +#ifdef TRACETOOLS_LTTNG_ENABLED char * demangled = nullptr; int status; demangled = abi::__cxa_demangle(mangled, NULL, 0, &status); @@ -35,7 +35,7 @@ const char * _demangle_symbol(const char * mangled) const char * _get_symbol_funcptr(void * funcptr) { -#if defined(TRACETOOLS_LTTNG_ENABLED) +#ifdef TRACETOOLS_LTTNG_ENABLED Dl_info info; if (dladdr(funcptr, &info) == 0) { return SYMBOL_UNKNOWN; From c6b7a645e32d74743db9400364d5e53aa559b494 Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Fri, 28 Feb 2020 17:45:57 -0500 Subject: [PATCH 2/3] Move TRACETOOLS_LTTNG_ENABLED definition to config.h.in Signed-off-by: Christophe Bedard --- tracetools/CMakeLists.txt | 15 ++++++++------- tracetools/include/tracetools/config.h.in | 1 + tracetools/src/utils.cpp | 2 ++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/tracetools/CMakeLists.txt b/tracetools/CMakeLists.txt index c12e6ae..dd0df40 100644 --- a/tracetools/CMakeLists.txt +++ b/tracetools/CMakeLists.txt @@ -22,18 +22,20 @@ endif() option(TRACETOOLS_DISABLED "Explicitly disable support for tracing with LTTng" ${DISABLED_DEFAULT}) if(NOT TRACETOOLS_DISABLED) - # Set TRACING_ENABLED if we can find lttng-ust + # Set TRACETOOLS_LTTNG_ENABLED if we can find lttng-ust find_package(PkgConfig) if(PkgConfig_FOUND) pkg_check_modules(LTTNG lttng-ust) if(LTTNG_FOUND) - set(TRACING_ENABLED TRUE) + set(TRACETOOLS_LTTNG_ENABLED TRUE) message("LTTng found: tracing enabled") endif() endif() endif() # store configuration variables for runtime use +# TRACETOOLS_DISABLED +# TRACETOOLS_LTTNG_ENABLED configure_file(include/${PROJECT_NAME}/config.h.in include/${PROJECT_NAME}/config.h) # add both source and output include, to capture config.h @@ -44,7 +46,7 @@ set(SOURCES src/tracetools.c src/utils.cpp ) -if(TRACING_ENABLED) +if(TRACETOOLS_LTTNG_ENABLED) list(APPEND SOURCES include/tracetools/tp_call.h src/tp_call.c @@ -52,8 +54,7 @@ if(TRACING_ENABLED) endif() add_library(${PROJECT_NAME} ${SOURCES}) -if(TRACING_ENABLED) - target_compile_definitions(${PROJECT_NAME} PUBLIC TRACETOOLS_LTTNG_ENABLED) +if(TRACETOOLS_LTTNG_ENABLED) target_link_libraries(${PROJECT_NAME} ${LTTNG_LIBRARIES}) endif() if(WIN32) @@ -95,7 +96,7 @@ install( ) ament_export_include_directories(include) -if(TRACING_ENABLED) +if(TRACETOOLS_LTTNG_ENABLED) ament_export_libraries(${PROJECT_NAME} ${LTTNG_LIBRARIES}) else() ament_export_libraries(${PROJECT_NAME}) @@ -109,7 +110,7 @@ if(BUILD_TESTING) ament_lint_auto_find_test_dependencies() # Only build tracetools utils tests if LTTng is enabled and found - if(TRACING_ENABLED) + if(TRACETOOLS_LTTNG_ENABLED) ament_add_gtest(test_utils test/test_utils.cpp) if(TARGET test_utils) target_link_libraries(test_utils ${PROJECT_NAME} -rdynamic) diff --git a/tracetools/include/tracetools/config.h.in b/tracetools/include/tracetools/config.h.in index d1bfdf7..23e5141 100644 --- a/tracetools/include/tracetools/config.h.in +++ b/tracetools/include/tracetools/config.h.in @@ -16,5 +16,6 @@ #define TRACETOOLS__CONFIG_H_ #cmakedefine TRACETOOLS_DISABLED +#cmakedefine TRACETOOLS_LTTNG_ENABLED #endif // TRACETOOLS__CONFIG_H_ diff --git a/tracetools/src/utils.cpp b/tracetools/src/utils.cpp index ef2e9ad..8622476 100644 --- a/tracetools/src/utils.cpp +++ b/tracetools/src/utils.cpp @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "tracetools/config.h" + #ifdef TRACETOOLS_LTTNG_ENABLED #include #include From 484efb17cc040b731c4caf07a7f93ec8cb3805b4 Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Sat, 29 Feb 2020 14:18:18 -0500 Subject: [PATCH 3/3] Remove mention of LTTng for TRACETOOLS_DISABLED description Signed-off-by: Christophe Bedard --- tracetools/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tracetools/CMakeLists.txt b/tracetools/CMakeLists.txt index dd0df40..50ebc2d 100644 --- a/tracetools/CMakeLists.txt +++ b/tracetools/CMakeLists.txt @@ -19,7 +19,7 @@ if(WIN32) else() set(DISABLED_DEFAULT OFF) endif() -option(TRACETOOLS_DISABLED "Explicitly disable support for tracing with LTTng" ${DISABLED_DEFAULT}) +option(TRACETOOLS_DISABLED "Explicitly disable support for tracing" ${DISABLED_DEFAULT}) if(NOT TRACETOOLS_DISABLED) # Set TRACETOOLS_LTTNG_ENABLED if we can find lttng-ust