summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
9dd3365)
This is to make the plugin name available when having a component class
object in an upcoming error reporting API.
We don't keep the `bt_plugin` object itself because it's a component
class's owner, and a component class can outlive its containing plugin:
only the shared object data is kept alive in that case.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I9cfbac32d88a6e7edac238b5a63b232695613b8c
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1523
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
+ if (class->plugin_name) {
+ g_string_free(class->plugin_name, TRUE);
+ class->plugin_name = NULL;
+ }
+
if (class->destroy_listeners) {
g_array_free(class->destroy_listeners, TRUE);
class->destroy_listeners = NULL;
if (class->destroy_listeners) {
g_array_free(class->destroy_listeners, TRUE);
class->destroy_listeners = NULL;
+ class->plugin_name = g_string_new(NULL);
+ if (!class->plugin_name) {
+ BT_LOGE_STR("Failed to allocate a GString.");
+ goto error;
+ }
+
class->destroy_listeners = g_array_new(FALSE, TRUE,
sizeof(struct bt_component_class_destroy_listener));
if (!class->destroy_listeners) {
class->destroy_listeners = g_array_new(FALSE, TRUE,
sizeof(struct bt_component_class_destroy_listener));
if (!class->destroy_listeners) {
GString *name;
GString *description;
GString *help;
GString *name;
GString *description;
GString *help;
/* Array of struct bt_component_class_destroy_listener */
GArray *destroy_listeners;
/* Array of struct bt_component_class_destroy_listener */
GArray *destroy_listeners;
+ /* Set component class's original plugin name */
+ BT_ASSERT(comp_class->plugin_name);
+ BT_ASSERT(plugin->info.name);
+ g_string_assign(comp_class->plugin_name, plugin->info.name->str);
+
/* Add new component class */
bt_object_get_ref(comp_class);
g_ptr_array_add(comp_classes, comp_class);
/* Add new component class */
bt_object_get_ref(comp_class);
g_ptr_array_add(comp_classes, comp_class);