Resolve "Add option to compile out LTTng entirely"

This commit is contained in:
Ingo Lütkebohle 2019-07-30 14:27:36 +00:00 committed by Christophe Bedard
parent 9d3ed4aa6b
commit 7b15e17cd2
6 changed files with 74 additions and 28 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.vscode

View file

@ -25,7 +25,11 @@ if(NOT TRACETOOLS_DISABLED)
endif()
endif()
include_directories(include)
# store configuration variables for runtime use
configure_file(include/${PROJECT_NAME}/config.h.in include/${PROJECT_NAME}/config.h)
# add both source and output include, to capture config.h
include_directories(include ${PROJECT_BINARY_DIR}/include)
# Status checking tool
add_executable(status
@ -66,6 +70,10 @@ install(
DIRECTORY include/
DESTINATION include
)
install(
FILES ${PROJECT_BINARY_DIR}/include/${PROJECT_NAME}/config.h
DESTINATION include/${PROJECT_NAME}
)
install(
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}_export

View file

@ -0,0 +1,20 @@
// Copyright 2019 Robert Bosch GmbH
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef TRACETOOLS__CONFIG_H_
#define TRACETOOLS__CONFIG_H_
#cmakedefine TRACETOOLS_DISABLED
#endif // TRACETOOLS__CONFIG_H_

View file

@ -18,9 +18,17 @@
#include <stdint.h>
#include <string.h>
#include <stdbool.h>
#include "tracetools/config.h"
#define TRACEPOINT(event_name, ...) \
#ifndef TRACETOOLS_DISABLED
# define TRACEPOINT(event_name, ...) \
(ros_trace_ ## event_name)(__VA_ARGS__)
# define DECLARE_TRACEPOINT(event_name, ...) \
void(ros_trace_ ## event_name)(__VA_ARGS__);
#else
# define TRACEPOINT(event_name, ...)
# define DECLARE_TRACEPOINT(event_name, ...)
#endif
#ifdef __cplusplus
extern "C"
@ -35,116 +43,116 @@ bool ros_trace_compile_status();
/**
* tp: rcl_init
*/
void TRACEPOINT(
DECLARE_TRACEPOINT(
rcl_init,
const void * context_handle);
const void * context_handle)
/**
* tp: rcl_node_init
*/
void TRACEPOINT(
DECLARE_TRACEPOINT(
rcl_node_init,
const void * node_handle,
const void * rmw_handle,
const char * node_name,
const char * node_namespace);
const char * node_namespace)
/**
* tp: rcl_publisher_init
*/
void TRACEPOINT(
DECLARE_TRACEPOINT(
rcl_publisher_init,
const void * publisher_handle,
const void * node_handle,
const void * rmw_publisher_handle,
const char * topic_name,
const size_t queue_depth);
const size_t queue_depth)
/**
* tp: rcl_subscription_init
*/
void TRACEPOINT(
DECLARE_TRACEPOINT(
rcl_subscription_init,
const void * subscription_handle,
const void * node_handle,
const void * rmw_subscription_handle,
const char * topic_name,
const size_t queue_depth);
const size_t queue_depth)
/**
* tp: rclcpp_subscription_callback_added
*/
void TRACEPOINT(
DECLARE_TRACEPOINT(
rclcpp_subscription_callback_added,
const void * subscription_handle,
const void * callback);
const void * callback)
/**
* tp: rcl_service_init
*/
void TRACEPOINT(
DECLARE_TRACEPOINT(
rcl_service_init,
const void * service_handle,
const void * node_handle,
const void * rmw_service_handle,
const char * service_name);
const char * service_name)
/**
* tp: rclcpp_service_callback_added
*/
void TRACEPOINT(
DECLARE_TRACEPOINT(
rclcpp_service_callback_added,
const void * service_handle,
const void * callback);
const void * callback)
/**
* tp: rcl_client_init
*/
void TRACEPOINT(
DECLARE_TRACEPOINT(
rcl_client_init,
const void * client_handle,
const void * node_handle,
const void * rmw_client_handle,
const char * service_name);
const char * service_name)
/**
* tp: rcl_timer_init
*/
void TRACEPOINT(
DECLARE_TRACEPOINT(
rcl_timer_init,
const void * timer_handle,
int64_t period);
int64_t period)
/**
* tp: rclcpp_timer_callback_added
*/
void TRACEPOINT(
DECLARE_TRACEPOINT(
rclcpp_timer_callback_added,
const void * timer_handle,
const void * callback);
const void * callback)
/**
* tp: rclcpp_callback_register
*/
void TRACEPOINT(
DECLARE_TRACEPOINT(
rclcpp_callback_register,
const void * callback,
const char * function_symbol);
const char * function_symbol)
/**
* tp: callback_start
*/
void TRACEPOINT(
DECLARE_TRACEPOINT(
callback_start,
const void * callback,
const bool is_intra_process);
const bool is_intra_process)
/**
* tp: callback_end
*/
void TRACEPOINT(
DECLARE_TRACEPOINT(
callback_end,
const void * callback);
const void * callback)
#ifdef __cplusplus
}

View file

@ -17,6 +17,7 @@
int main()
{
#ifndef TRACETOOLS_DISABLED
printf("Tracing ");
if (ros_trace_compile_status()) {
printf("enabled\n");
@ -25,4 +26,8 @@ int main()
printf("disabled\n");
return 1;
}
#else
printf("Tracing disabled through configuration\n");
return 1;
#endif
}

View file

@ -14,6 +14,8 @@
#include "tracetools/tracetools.h"
#ifndef TRACETOOLS_DISABLED
#if defined(TRACETOOLS_LTTNG_ENABLED)
# include "tracetools/tp_call.h"
# define CONDITIONAL_TP(...) \
@ -216,3 +218,5 @@ void TRACEPOINT(
#ifndef _WIN32
# pragma GCC diagnostic pop
#endif
#endif // TRACETOOLS_DISABLED