Program Listing for File tracetools.h

Return to documentation for file (include/tracetools/tracetools.h)

// Copyright 2019 Robert Bosch GmbH
// Copyright 2020 Christophe Bedard
//
// 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__TRACETOOLS_H_
#define TRACETOOLS__TRACETOOLS_H_

#include <stdint.h>
#include <string.h>
#include <stdbool.h>

#include "tracetools/config.h"
#include "tracetools/visibility_control.h"

#ifndef TRACETOOLS_DISABLED
#  define _GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, NAME, ...) NAME

// *INDENT-OFF*
#  define _TRACEPOINT_NOARGS(event_name) \
  (ros_trace_ ## event_name)()
#  define _TRACEPOINT_ARGS(event_name, ...) \
  (ros_trace_ ## event_name)(__VA_ARGS__)
#  define _DO_TRACEPOINT_NOARGS(event_name) \
  (ros_trace_do_ ## event_name)()
#  define _DO_TRACEPOINT_ARGS(event_name, ...) \
  (ros_trace_do_ ## event_name)(__VA_ARGS__)
#  define _DECLARE_TRACEPOINT_NOARGS(event_name) \
  TRACETOOLS_PUBLIC void ros_trace_ ## event_name(); \
  TRACETOOLS_PUBLIC bool ros_trace_enabled_ ## event_name(); \
  TRACETOOLS_PUBLIC void ros_trace_do_ ## event_name();
#  define _DECLARE_TRACEPOINT_ARGS(event_name, ...) \
  TRACETOOLS_PUBLIC void ros_trace_ ## event_name(__VA_ARGS__); \
  TRACETOOLS_PUBLIC bool ros_trace_enabled_ ## event_name(); \
  TRACETOOLS_PUBLIC void ros_trace_do_ ## event_name(__VA_ARGS__);

#  define _GET_MACRO_TRACEPOINT(...) \
  _GET_MACRO( \
    __VA_ARGS__, \
    _TRACEPOINT_ARGS, _TRACEPOINT_ARGS, _TRACEPOINT_ARGS, _TRACEPOINT_ARGS, _TRACEPOINT_ARGS, \
    _TRACEPOINT_ARGS, _TRACEPOINT_ARGS, _TRACEPOINT_ARGS, _TRACEPOINT_ARGS, _TRACEPOINT_NOARGS, \
    shoud_not_be_called_without_any_arguments)
#  define _GET_MACRO_DO_TRACEPOINT(...) \
  _GET_MACRO( \
    __VA_ARGS__, \
    _DO_TRACEPOINT_ARGS, _DO_TRACEPOINT_ARGS, _DO_TRACEPOINT_ARGS, _DO_TRACEPOINT_ARGS, \
    _DO_TRACEPOINT_ARGS, _DO_TRACEPOINT_ARGS, _DO_TRACEPOINT_ARGS, _DO_TRACEPOINT_ARGS, \
    _DO_TRACEPOINT_ARGS, _DO_TRACEPOINT_NOARGS, shoud_not_be_called_without_any_arguments)
#  define _GET_MACRO_DECLARE_TRACEPOINT(...) \
  _GET_MACRO( \
    __VA_ARGS__, \
    _DECLARE_TRACEPOINT_ARGS, _DECLARE_TRACEPOINT_ARGS, _DECLARE_TRACEPOINT_ARGS, \
    _DECLARE_TRACEPOINT_ARGS, _DECLARE_TRACEPOINT_ARGS, _DECLARE_TRACEPOINT_ARGS, \
    _DECLARE_TRACEPOINT_ARGS, _DECLARE_TRACEPOINT_ARGS, _DECLARE_TRACEPOINT_ARGS, \
    _DECLARE_TRACEPOINT_NOARGS, shoud_not_be_called_without_any_arguments)
#  define _DECLARE_TRACEPOINT(...) \
  _GET_MACRO_DECLARE_TRACEPOINT(__VA_ARGS__)(__VA_ARGS__)


#  define TRACETOOLS_TRACEPOINT(...) \
  _GET_MACRO_TRACEPOINT(__VA_ARGS__)(__VA_ARGS__)

#  define TRACETOOLS_TRACEPOINT_ENABLED(event_name) \
  ros_trace_enabled_ ## event_name()

#  define TRACETOOLS_DO_TRACEPOINT(...) \
  _GET_MACRO_DO_TRACEPOINT(__VA_ARGS__)(__VA_ARGS__)
#else
#  define TRACETOOLS_TRACEPOINT(...) ((void) (0))
#  define TRACETOOLS_TRACEPOINT_ENABLED(event_name) false
#  define TRACETOOLS_DO_TRACEPOINT(...) ((void) (0))
#  define _DECLARE_TRACEPOINT(...)
#endif  // TRACETOOLS_DISABLED
// *INDENT-ON*

#ifdef __cplusplus
extern "C"
{
#endif


TRACETOOLS_PUBLIC bool ros_trace_compile_status(void);


_DECLARE_TRACEPOINT(
  rcl_init,
  const void * context_handle)


_DECLARE_TRACEPOINT(
  rcl_node_init,
  const void * node_handle,
  const void * rmw_handle,
  const char * node_name,
  const char * node_namespace)


_DECLARE_TRACEPOINT(
  rmw_publisher_init,
  const void * rmw_publisher_handle,
  const uint8_t * gid)


_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)


_DECLARE_TRACEPOINT(
  rclcpp_publish,
  const void * publisher_handle,
  const void * message)


_DECLARE_TRACEPOINT(
  rclcpp_intra_publish,
  const void * publisher_handle,
  const void * message)


_DECLARE_TRACEPOINT(
  rcl_publish,
  const void * publisher_handle,
  const void * message)


_DECLARE_TRACEPOINT(
  rmw_publish,
  const void * rmw_publisher_handle,
  const void * message,
  int64_t timestamp)


_DECLARE_TRACEPOINT(
  rmw_subscription_init,
  const void * rmw_subscription_handle,
  const uint8_t * gid)


_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)


_DECLARE_TRACEPOINT(
  rclcpp_subscription_init,
  const void * subscription_handle,
  const void * subscription)


_DECLARE_TRACEPOINT(
  rclcpp_subscription_callback_added,
  const void * subscription,
  const void * callback)


_DECLARE_TRACEPOINT(
  rmw_take,
  const void * rmw_subscription_handle,
  const void * message,
  int64_t source_timestamp,
  const bool taken)


_DECLARE_TRACEPOINT(
  rcl_take,
  const void * message)


_DECLARE_TRACEPOINT(
  rclcpp_take,
  const void * message)


_DECLARE_TRACEPOINT(
  rcl_service_init,
  const void * service_handle,
  const void * node_handle,
  const void * rmw_service_handle,
  const char * service_name)


_DECLARE_TRACEPOINT(
  rclcpp_service_callback_added,
  const void * service_handle,
  const void * callback)


_DECLARE_TRACEPOINT(
  rcl_client_init,
  const void * client_handle,
  const void * node_handle,
  const void * rmw_client_handle,
  const char * service_name)


_DECLARE_TRACEPOINT(
  rcl_timer_init,
  const void * timer_handle,
  int64_t period)


_DECLARE_TRACEPOINT(
  rclcpp_timer_callback_added,
  const void * timer_handle,
  const void * callback)


_DECLARE_TRACEPOINT(
  rclcpp_timer_link_node,
  const void * timer_handle,
  const void * node_handle)


_DECLARE_TRACEPOINT(
  rclcpp_callback_register,
  const void * callback,
  const char * function_symbol)


_DECLARE_TRACEPOINT(
  callback_start,
  const void * callback,
  const bool is_intra_process)


_DECLARE_TRACEPOINT(
  callback_end,
  const void * callback)


_DECLARE_TRACEPOINT(
  rcl_lifecycle_state_machine_init,
  const void * node_handle,
  const void * state_machine)


_DECLARE_TRACEPOINT(
  rcl_lifecycle_transition,
  const void * state_machine,
  const char * start_label,
  const char * goal_label)


_DECLARE_TRACEPOINT(
  rclcpp_executor_get_next_ready)


_DECLARE_TRACEPOINT(
  rclcpp_executor_wait_for_work,
  const int64_t timeout)


_DECLARE_TRACEPOINT(
  rclcpp_executor_execute,
  const void * handle)


_DECLARE_TRACEPOINT(
  rclcpp_ipb_to_subscription,
  const void * ipb,
  const void * subscription)


_DECLARE_TRACEPOINT(
  rclcpp_buffer_to_ipb,
  const void * buffer,
  const void * ipb)


_DECLARE_TRACEPOINT(
  rclcpp_construct_ring_buffer,
  const void * buffer,
  const uint64_t capacity)


_DECLARE_TRACEPOINT(
  rclcpp_ring_buffer_enqueue,
  const void * buffer,
  const uint64_t index,
  const uint64_t size,
  const bool overwritten)


_DECLARE_TRACEPOINT(
  rclcpp_ring_buffer_dequeue,
  const void * buffer,
  const uint64_t index,
  const uint64_t size)


_DECLARE_TRACEPOINT(
  rclcpp_ring_buffer_clear,
  const void * buffer)

#ifdef __cplusplus
}
#endif

#endif  // TRACETOOLS__TRACETOOLS_H_