Re-structure callback registration tracepoint

This commit is contained in:
Christophe Bedard 2019-05-28 16:35:47 +02:00
parent cee1327930
commit 372f0296c0
3 changed files with 18 additions and 14 deletions

View file

@ -157,8 +157,8 @@ void TRACEPOINT(
*/
void TRACEPOINT(
rclcpp_callback_register,
const void * handle,
const void * callback);
const void * callback,
const void * function_target);
#ifdef __cplusplus
}

View file

@ -224,11 +224,11 @@ TRACEPOINT_EVENT(
ros2,
rclcpp_callback_register,
TP_ARGS(
const void *, handle_arg,
const char *, callback_arg
const void *, callback_arg,
const char *, symbol_arg
),
TP_FIELDS(
ctf_integer_hex(const void *, handle, handle_arg)
ctf_string(callback, callback_arg)
ctf_integer_hex(const void *, callback, callback_arg)
ctf_string(symbol, symbol_arg)
)
)

View file

@ -12,6 +12,10 @@
const char * get_symbol(const void * function_ptr) {
#if defined(WITH_LTTNG) && !defined(_WIN32)
// If it's actually a lambda
if (NULL == function_ptr) {
return "";
}
char ** symbols = backtrace_symbols(&function_ptr, 1);
const char * result = symbols[0];
free(symbols);
@ -166,8 +170,8 @@ void TRACEPOINT(
void TRACEPOINT(
rclcpp_callback_register,
const void * handle,
const void * callback)
const void * callback,
const void * function_target)
{
CONDITIONAL_TP(ros2, rclcpp_callback_register, handle, get_symbol(callback));
CONDITIONAL_TP(ros2, rclcpp_callback_register, callback, get_symbol(function_target));
}