ros2_tracing/tracetools/src/tracetools.c

226 lines
4.2 KiB
C
Raw Normal View History

2019-06-18 09:10:05 +02:00
// 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.
2019-05-16 12:54:01 +02:00
#include "tracetools/tracetools.h"
#ifndef TRACETOOLS_DISABLED
2019-07-05 09:02:44 +02:00
#if defined(TRACETOOLS_LTTNG_ENABLED)
# include "tracetools/tp_call.h"
2019-05-20 15:17:00 +02:00
# define CONDITIONAL_TP(...) \
tracepoint(TRACEPOINT_PROVIDER, __VA_ARGS__)
2019-05-17 14:57:36 +02:00
#else
2019-05-20 15:17:00 +02:00
# define CONDITIONAL_TP(...)
2019-05-16 12:54:01 +02:00
#endif
2019-05-16 14:16:40 +02:00
bool ros_trace_compile_status()
{
2019-07-05 09:02:44 +02:00
#if defined(TRACETOOLS_LTTNG_ENABLED)
2019-05-16 14:16:40 +02:00
return true;
2019-05-16 12:54:01 +02:00
#else
2019-05-16 14:16:40 +02:00
return false;
2019-05-16 12:54:01 +02:00
#endif
}
#ifndef _WIN32
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wunused-parameter"
#else
# pragma warning(push)
# pragma warning(disable: 4100)
#endif
void TRACEPOINT(
rcl_init,
const void * context_handle)
2019-05-16 14:16:40 +02:00
{
2019-06-05 15:35:46 +02:00
CONDITIONAL_TP(
rcl_init,
context_handle,
tracetools_VERSION);
2019-05-16 12:54:01 +02:00
}
2019-05-16 13:36:59 +02:00
2019-05-17 14:57:36 +02:00
void TRACEPOINT(
rcl_node_init,
2019-05-20 13:58:06 +02:00
const void * node_handle,
const void * rmw_handle,
2019-05-17 14:57:36 +02:00
const char * node_name,
2019-05-20 13:58:06 +02:00
const char * node_namespace)
2019-05-16 14:16:40 +02:00
{
2019-06-05 15:35:46 +02:00
CONDITIONAL_TP(
rcl_node_init,
node_handle,
rmw_handle,
node_name,
node_namespace);
2019-05-16 13:36:59 +02:00
}
2019-05-17 14:57:36 +02:00
void TRACEPOINT(
rcl_publisher_init,
2019-05-20 13:58:06 +02:00
const void * publisher_handle,
const void * node_handle,
const void * rmw_publisher_handle,
const char * topic_name,
2019-06-17 10:13:55 +02:00
const size_t queue_depth)
2019-05-16 14:16:40 +02:00
{
2019-06-05 15:35:46 +02:00
CONDITIONAL_TP(
rcl_publisher_init,
publisher_handle,
node_handle,
2019-06-05 15:35:46 +02:00
rmw_publisher_handle,
topic_name,
2019-06-17 10:13:55 +02:00
queue_depth);
2019-05-16 13:36:59 +02:00
}
2019-05-17 14:57:36 +02:00
void TRACEPOINT(
rcl_subscription_init,
const void * subscription_handle,
const void * node_handle,
const void * rmw_subscription_handle,
const char * topic_name,
2019-06-17 10:13:55 +02:00
const size_t queue_depth)
2019-05-16 14:16:40 +02:00
{
2019-06-05 15:35:46 +02:00
CONDITIONAL_TP(
rcl_subscription_init,
subscription_handle,
node_handle,
2019-06-05 15:35:46 +02:00
rmw_subscription_handle,
topic_name,
2019-06-17 10:13:55 +02:00
queue_depth);
}
void TRACEPOINT(
rclcpp_subscription_init,
2019-06-05 15:35:46 +02:00
const void * subscription_handle,
const void * subscription)
{
CONDITIONAL_TP(
rclcpp_subscription_init,
subscription_handle,
subscription);
}
void TRACEPOINT(
rclcpp_subscription_callback_added,
const void * subscription,
2019-06-05 15:35:46 +02:00
const void * callback)
{
2019-06-05 15:35:46 +02:00
CONDITIONAL_TP(
rclcpp_subscription_callback_added,
subscription,
2019-06-05 15:35:46 +02:00
callback);
2019-05-16 13:36:59 +02:00
}
2019-05-17 09:05:34 +02:00
void TRACEPOINT(
rcl_service_init,
2019-05-20 13:58:06 +02:00
const void * service_handle,
const void * node_handle,
const void * rmw_service_handle,
const char * service_name)
{
2019-06-05 15:35:46 +02:00
CONDITIONAL_TP(
rcl_service_init,
service_handle,
node_handle,
2019-06-05 15:35:46 +02:00
rmw_service_handle,
service_name);
}
void TRACEPOINT(
rclcpp_service_callback_added,
2019-05-20 13:58:06 +02:00
const void * service_handle,
const void * callback)
{
2019-06-05 15:35:46 +02:00
CONDITIONAL_TP(
rclcpp_service_callback_added,
service_handle,
callback);
}
2019-05-28 14:15:46 +02:00
void TRACEPOINT(
rcl_client_init,
const void * client_handle,
const void * node_handle,
2019-05-28 14:15:46 +02:00
const void * rmw_client_handle,
const char * service_name)
{
2019-06-05 15:35:46 +02:00
CONDITIONAL_TP(
rcl_client_init,
client_handle,
node_handle,
2019-06-05 15:35:46 +02:00
rmw_client_handle,
service_name);
2019-05-28 14:15:46 +02:00
}
2019-05-28 13:13:53 +02:00
void TRACEPOINT(
rcl_timer_init,
const void * timer_handle,
2019-06-05 15:35:46 +02:00
int64_t period)
2019-05-28 13:13:53 +02:00
{
2019-06-05 15:35:46 +02:00
CONDITIONAL_TP(
rcl_timer_init,
timer_handle,
period);
2019-05-28 13:13:53 +02:00
}
void TRACEPOINT(
rclcpp_timer_callback_added,
const void * timer_handle,
const void * callback)
{
2019-06-05 15:35:46 +02:00
CONDITIONAL_TP(
rclcpp_timer_callback_added,
timer_handle,
callback);
2019-05-28 13:13:53 +02:00
}
void TRACEPOINT(
rclcpp_callback_register,
const void * callback,
const char * function_symbol)
2019-05-28 13:13:53 +02:00
{
2019-06-05 15:35:46 +02:00
CONDITIONAL_TP(
rclcpp_callback_register,
callback,
function_symbol);
2019-05-28 13:13:53 +02:00
}
void TRACEPOINT(
callback_start,
const void * callback,
const bool is_intra_process)
2019-05-28 13:13:53 +02:00
{
2019-06-05 15:35:46 +02:00
CONDITIONAL_TP(
callback_start,
callback,
(is_intra_process ? 1 : 0));
2019-05-28 13:13:53 +02:00
}
void TRACEPOINT(
callback_end,
const void * callback)
{
CONDITIONAL_TP(
callback_end,
callback);
}
#ifndef _WIN32
# pragma GCC diagnostic pop
#else
# pragma warning(pop)
#endif
#endif // TRACETOOLS_DISABLED