From fbc90342dade0eea8fc4f464bda7f63b6151802a Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 31 May 2023 15:59:08 -0400 Subject: [PATCH] lib: add bt_trace_class_get_graph_mip_version Add bt_trace_class_get_graph_mip_version, which returns the MIP version for the graph the trace class is in. This will be necessary for the Python bindings functions dealing with trace IR that need to change their behavior according to the MIP version. Right now, the MIP version can be obtained from a self component. But some Python functions (for instance _TraceClass.create_variant_field_class) only have a IR object to work with, and it's not possible to get the self component from there. Adding a function to get the self component from a trace class was considered, but it was deemed to complex because of object lifetime and refcount cycle issues. Philippe updated the documentation. Change-Id: Ie31be7d31baf1242bad3927021de7c949f281247 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/10155 Reviewed-by: Philippe Proulx Reviewed-on: https://review.lttng.org/c/babeltrace/+/12719 --- include/babeltrace2/trace-ir/trace-class.h | 25 ++++++++++++++++++++++ src/lib/trace-ir/trace-class.c | 8 +++++++ 2 files changed, 33 insertions(+) diff --git a/include/babeltrace2/trace-ir/trace-class.h b/include/babeltrace2/trace-ir/trace-class.h index 4a50b311..ac425a7f 100644 --- a/include/babeltrace2/trace-ir/trace-class.h +++ b/include/babeltrace2/trace-ir/trace-class.h @@ -73,6 +73,10 @@ Add to and remove a destruction listener from a trace class with bt_trace_class_add_destruction_listener() and bt_trace_class_remove_destruction_listener(). +Get the effective \bt_mip version of the trace processing \bt_graph +containing the \bt_comp from which a trace class was created with +bt_trace_class_get_graph_mip_version(). +

Properties

A trace class has the following properties: @@ -410,6 +414,27 @@ See bt_trace_class_borrow_user_attributes(). extern const bt_value *bt_trace_class_borrow_user_attributes_const( const bt_trace_class *trace_class) __BT_NOEXCEPT; +/*! +@brief + Returns the effective \bt_mip (MIP) version of the trace processing + \bt_graph containing the \bt_comp from which + \bt_p{trace_class} was created. + +@param[in] trace_class + Trace class of which to get the effective MIP version. + +@returns + Effective MIP version of \bt_p{trace_class}. + +@bt_pre_not_null{trace_class} + +@sa bt_self_component_get_graph_mip_version() — + Returns the effective MIP version of the trace processing + graph which contains a given component. +*/ +extern uint64_t bt_trace_class_get_graph_mip_version( + const bt_trace_class *trace_class) __BT_NOEXCEPT; + /*! @} */ /*! diff --git a/src/lib/trace-ir/trace-class.c b/src/lib/trace-ir/trace-class.c index 78824ed4..19045850 100644 --- a/src/lib/trace-ir/trace-class.c +++ b/src/lib/trace-ir/trace-class.c @@ -329,6 +329,14 @@ const struct bt_value *bt_trace_class_borrow_user_attributes_const( return trace_class->user_attributes; } +BT_EXPORT +uint64_t bt_trace_class_get_graph_mip_version( + const bt_trace_class *trace_class) +{ + BT_ASSERT_PRE_DEV_TC_NON_NULL(trace_class); + return trace_class->mip_version; +} + BT_EXPORT struct bt_value *bt_trace_class_borrow_user_attributes( struct bt_trace_class *trace_class) -- 2.34.1