Skip to content

Commit

Permalink
jazzy support
Browse files Browse the repository at this point in the history
  • Loading branch information
miyakoshi-dev committed Oct 24, 2024
1 parent 2227f05 commit 676f373
Show file tree
Hide file tree
Showing 9 changed files with 324 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CARET_trace/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ find_package(rmw_fastrtps_shared_cpp REQUIRED)
find_package(LTTngUST REQUIRED)
find_package(caret_msgs REQUIRED)

set(ENV_VAR_VALUE $ENV{ROS_DISTRO})
if(ENV_VAR_VALUE STREQUAL "jazzy")
add_compile_definitions(ROS_DISTRO_JAZZY)
endif()

add_library(caret SHARED
src/ros_trace_points.cpp
src/hooked_trace_points.cpp
Expand Down
56 changes: 56 additions & 0 deletions CARET_trace/include/caret_trace/data_container.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ class DataContainer : public DataContainerInterface
using ConstructStaticExecutor =
ContainerTraits<const void *, const void *, const char *, int64_t>;

/// @brief ContainerTraits for callback_group_to_executor_entity_collector trace points.
using CallbackGroupToExecutorEntityCollector =
ContainerTraits<const void *, const void *, int64_t>;

/// @brief ContainerTraits for executor_entity_collector_to_executor trace points.
using ExecutorEntityCollectorToExecutor =
ContainerTraits<const void *, const void *, int64_t>;

/// @brief ContainerTraits for rcl_init trace points.
using RclInit = ContainerTraits<const void *, int64_t>;

Expand Down Expand Up @@ -145,6 +153,10 @@ class DataContainer : public DataContainerInterface
/// @param callback_group_add_timer Data instance for callback_group_add_timer trace point.
/// @param construct_executor Data instance for construct_executor trace point.
/// @param construct_static_executor Data instance for construct_static_executor trace point.
/// @param callback_group_to_executor_entity_collector Data instance for
/// callback_group_to_executor_entity_collector trace point.
/// @param executor_entity_collector_to_executor Data instance for
/// executor_entity_collector_to_executor trace point.
/// @param rcl_client_init Data instance for rcl_client_init trace point.
/// @param rcl_init Data instance for rcl_init trace point.
/// @param rcl_node_init Data instance for rcl_node_init trace point.
Expand All @@ -170,6 +182,10 @@ class DataContainer : public DataContainerInterface
std::shared_ptr<CallbackGroupAddTimer::KeysT> callback_group_add_timer,
std::shared_ptr<ConstructExecutor::KeysT> construct_executor,
std::shared_ptr<ConstructStaticExecutor::KeysT> construct_static_executor,
#ifdef ROS_DISTRO_JAZZY
std::shared_ptr<CallbackGroupToExecutorEntityCollector::KeysT> callback_group_to_executor_entity_collector,
std::shared_ptr<ExecutorEntityCollectorToExecutor::KeysT> executor_entity_collector_to_executor,
#endif
std::shared_ptr<RclClientInit::KeysT> rcl_client_init, std::shared_ptr<RclInit::KeysT> rcl_init,
std::shared_ptr<RclNodeInit::KeysT> rcl_node_init,
std::shared_ptr<RclPublisherInit::KeysT> rcl_publisher_init,
Expand Down Expand Up @@ -281,6 +297,28 @@ class DataContainer : public DataContainerInterface
return construct_static_executor_->store(args...);
}

/// @brief Store data for callback_group_to_executor_entity_collector trace points.
/// @tparam ...Args Data types to be stored.
/// @param ...args Data to be stored.
/// @return True, data was stored to pending set.
/// @return False, data was stored to set.
template <typename... Args>
bool store_callback_group_to_executor_entity_collector(Args... args)
{
return callback_group_to_executor_entity_collector_->store(args...);
}

/// @brief Store data for executor_entity_collector_to_executor trace points.
/// @tparam ...Args Data types to be stored.
/// @param ...args Data to be stored.
/// @return True, data was stored to pending set.
/// @return False, data was stored to set.
template <typename... Args>
bool store_executor_entity_collector_to_executor(Args... args)
{
return executor_entity_collector_to_executor_->store(args...);
}

/// @brief Store data for rcl_node_init trace points.
/// @tparam ...Args Data types to be stored.
/// @param ...args Data to be stored.
Expand Down Expand Up @@ -500,6 +538,14 @@ class DataContainer : public DataContainerInterface
/// @param record recording function.
void assign_construct_static_executor(ConstructStaticExecutor::StdFuncT record);

/// @brief Assign recording function for callback_group_to_executor_entity_collector trace points.
/// @param record recording function.
void assign_callback_group_to_executor_entity_collector(CallbackGroupToExecutorEntityCollector::StdFuncT record);

/// @brief Assign recording function for executor_entity_collector_to_executor trace points.
/// @param record recording function.
void assign_executor_entity_collector_to_executor(ExecutorEntityCollectorToExecutor::StdFuncT record);

/// @brief Assign recording function for rcl_client_init trace points.
/// @param record recording function.
void assign_rcl_client_init(RclClientInit::StdFuncT record);
Expand Down Expand Up @@ -609,6 +655,14 @@ class DataContainer : public DataContainerInterface
/// @return True if function is assigned, false otherwise.
bool is_assigned_construct_static_executor() const;

/// @brief Check whether recording function for callback_group_to_executor_entity_collector trace point is assigned.
/// @return True if function is assigned, false otherwise.
bool is_assigned_callback_group_to_executor_entity_collector() const;

/// @brief Check whether recording function for executor_entity_collector_to_executor trace point is assigned.
/// @return True if function is assigned, false otherwise.
bool is_assigned_executor_entity_collector_to_executor() const;

/// @brief Check whether recording function for rcl_client_init trace point is assigned.
/// @return True if function is assigned, false otherwise.
bool is_assigned_rcl_client_init() const;
Expand Down Expand Up @@ -697,6 +751,8 @@ class DataContainer : public DataContainerInterface
std::shared_ptr<CallbackGroupAddTimer::KeysT> callback_group_add_timer_;
std::shared_ptr<ConstructExecutor::KeysT> construct_executor_;
std::shared_ptr<ConstructStaticExecutor::KeysT> construct_static_executor_;
std::shared_ptr<CallbackGroupToExecutorEntityCollector::KeysT> callback_group_to_executor_entity_collector_;
std::shared_ptr<ExecutorEntityCollectorToExecutor::KeysT> executor_entity_collector_to_executor_;
std::shared_ptr<RclClientInit::KeysT> rcl_client_init_;
std::shared_ptr<RclInit::KeysT> rcl_init_;
std::shared_ptr<RclNodeInit::KeysT> rcl_node_init_;
Expand Down
47 changes: 47 additions & 0 deletions CARET_trace/include/caret_trace/tp.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ TRACEPOINT_EVENT(
)
)

#ifdef ROS_DISTRO_JAZZY
TRACEPOINT_EVENT(
TRACEPOINT_PROVIDER,
dds_write,
TP_ARGS(
const void *, rmw_publisher_handle_arg,
const void *, message_arg,
int64_t, init_timestamp_arg
),
TP_FIELDS(
ctf_integer_hex(const void *, rmw_publisher_handle, rmw_publisher_handle_arg)
ctf_integer_hex(const void *, message, message_arg)
ctf_integer(const int64_t, init_timestamp, init_timestamp_arg)
)
)
#else
TRACEPOINT_EVENT(
TRACEPOINT_PROVIDER,
dds_write,
Expand All @@ -53,6 +69,7 @@ TRACEPOINT_EVENT(
ctf_integer_hex(const void *, message, message_arg)
)
)
#endif

TRACEPOINT_EVENT(
TRACEPOINT_PROVIDER,
Expand Down Expand Up @@ -93,6 +110,36 @@ TRACEPOINT_EVENT(
)
)

TRACEPOINT_EVENT(
TRACEPOINT_PROVIDER,
callback_group_to_executor_entity_collector,
TP_ARGS(
const void *, executor_entities_collector_addr_arg,
const void *, callback_group_addr_arg,
int64_t, init_timestamp_arg
),
TP_FIELDS(
ctf_integer_hex(const void *, executor_entities_collector_addr, executor_entities_collector_addr_arg)
ctf_integer_hex(const void *, callback_group_addr, callback_group_addr_arg)
ctf_integer(const int64_t, init_timestamp, init_timestamp_arg)
)
)

TRACEPOINT_EVENT(
TRACEPOINT_PROVIDER,
executor_entity_collector_to_executor,
TP_ARGS(
const void *, executor_addr_arg,
const void *, executor_entities_collector_addr_arg,
int64_t, init_timestamp_arg
),
TP_FIELDS(
ctf_integer_hex(const void *, executor_addr, executor_addr_arg)
ctf_integer_hex(const void *, executor_entities_collector_addr, executor_entities_collector_addr_arg)
ctf_integer(const int64_t, init_timestamp, init_timestamp_arg)
)
)

TRACEPOINT_EVENT(
TRACEPOINT_PROVIDER,
construct_executor,
Expand Down
48 changes: 48 additions & 0 deletions CARET_trace/src/data_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ DataContainer::DataContainer()
std::make_shared<CallbackGroupAddTimer::KeysT>("callback_group_add_timer"),
std::make_shared<ConstructExecutor::KeysT>("construct_executor"),
std::make_shared<ConstructStaticExecutor::KeysT>("construct_static_executor"),
#ifdef ROS_DISTRO_JAZZY
std::make_shared<CallbackGroupToExecutorEntityCollector::KeysT>("callback_group_to_executor_entity_collector"),
std::make_shared<ExecutorEntityCollectorToExecutor::KeysT>("executor_entity_collector_to_executor"),
#endif
std::make_shared<RclClientInit::KeysT>("rcl_client_init"),
std::make_shared<RclInit::KeysT>("rcl_init"),
std::make_shared<RclNodeInit::KeysT>("rcl_node_init"),
Expand Down Expand Up @@ -66,6 +70,10 @@ DataContainer::DataContainer(
std::shared_ptr<CallbackGroupAddTimer::KeysT> callback_group_add_timer,
std::shared_ptr<ConstructExecutor::KeysT> construct_executor,
std::shared_ptr<ConstructStaticExecutor::KeysT> construct_static_executor,
#ifdef ROS_DISTRO_JAZZY
std::shared_ptr<CallbackGroupToExecutorEntityCollector::KeysT> callback_group_to_executor_entity_collector,
std::shared_ptr<ExecutorEntityCollectorToExecutor::KeysT> executor_entity_collector_to_executor,
#endif
std::shared_ptr<RclClientInit::KeysT> rcl_client_init, std::shared_ptr<RclInit::KeysT> rcl_init,
std::shared_ptr<RclNodeInit::KeysT> rcl_node_init,
std::shared_ptr<RclPublisherInit::KeysT> rcl_publisher_init,
Expand All @@ -90,6 +98,10 @@ DataContainer::DataContainer(
callback_group_add_timer_(callback_group_add_timer),
construct_executor_(construct_executor),
construct_static_executor_(construct_static_executor),
#ifdef ROS_DISTRO_JAZZY
callback_group_to_executor_entity_collector_(callback_group_to_executor_entity_collector),
executor_entity_collector_to_executor_(executor_entity_collector_to_executor),
#endif
rcl_client_init_(rcl_client_init),
rcl_init_(rcl_init),
rcl_node_init_(rcl_node_init),
Expand Down Expand Up @@ -134,6 +146,14 @@ DataContainer::DataContainer(
if (construct_static_executor_) {
recordable_data.emplace_back(construct_static_executor_);
}
#ifdef ROS_DISTRO_JAZZY
if (callback_group_to_executor_entity_collector_) {
recordable_data.emplace_back(callback_group_to_executor_entity_collector_);
}
if (executor_entity_collector_to_executor_) {
recordable_data.emplace_back(executor_entity_collector_to_executor_);
}
#endif
if (rcl_client_init_) {
recordable_data.emplace_back(rcl_client_init_);
}
Expand Down Expand Up @@ -273,6 +293,20 @@ void DataContainer::assign_construct_static_executor(ConstructStaticExecutor::St
construct_static_executor_->assign(record);
}

#ifdef ROS_DISTRO_JAZZY
void DataContainer::assign_callback_group_to_executor_entity_collector(CallbackGroupToExecutorEntityCollector::StdFuncT record)
{
assert(callback_group_to_executor_entity_collector_.get() != nullptr);
callback_group_to_executor_entity_collector_->assign(record);
}

void DataContainer::assign_executor_entity_collector_to_executor(ExecutorEntityCollectorToExecutor::StdFuncT record)
{
assert(executor_entity_collector_to_executor_.get() != nullptr);
executor_entity_collector_to_executor_->assign(record);
}
#endif

void DataContainer::assign_rcl_client_init(RclClientInit::StdFuncT record)
{
assert(rcl_client_init_.get() != nullptr);
Expand Down Expand Up @@ -432,6 +466,20 @@ bool DataContainer::is_assigned_construct_static_executor() const
return callback_group_add_client_->is_assigned();
}

#ifdef ROS_DISTRO_JAZZY
bool DataContainer::is_assigned_callback_group_to_executor_entity_collector() const
{
assert(callback_group_to_executor_entity_collector_.get() != nullptr);
return callback_group_to_executor_entity_collector_->is_assigned();
}

bool DataContainer::is_assigned_executor_entity_collector_to_executor() const
{
assert(executor_entity_collector_to_executor_.get() != nullptr);
return executor_entity_collector_to_executor_->is_assigned();
}
#endif

bool DataContainer::is_assigned_rcl_client_init() const
{
assert(rcl_client_init_.get() != nullptr);
Expand Down
Loading

0 comments on commit 676f373

Please sign in to comment.