X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=plugins%2Ftext%2Fdmesg%2Fdmesg.c;h=0edc2e6133dd7d0f4bcf42c705ed18ea48ea04bb;hb=da91b29ad2964b85601e25843f1dca92f6c97406;hp=86dec73633d1fcf08c6c2281d1d30663ae1e0b44;hpb=44c440bc5fe8219cc17d1b786d91fd83c4c9860a;p=babeltrace.git diff --git a/plugins/text/dmesg/dmesg.c b/plugins/text/dmesg/dmesg.c index 86dec736..0edc2e61 100644 --- a/plugins/text/dmesg/dmesg.c +++ b/plugins/text/dmesg/dmesg.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -77,27 +78,27 @@ struct dmesg_component { }; static -struct bt_field_type *create_event_payload_ft(void) +struct bt_field_class *create_event_payload_fc(void) { - struct bt_field_type *root_ft = NULL; - struct bt_field_type *ft = NULL; + struct bt_field_class *root_fc = NULL; + struct bt_field_class *fc = NULL; int ret; - root_ft = bt_field_type_structure_create(); - if (!root_ft) { - BT_LOGE_STR("Cannot create an empty structure field type object."); + root_fc = bt_field_class_structure_create(); + if (!root_fc) { + BT_LOGE_STR("Cannot create an empty structure field class object."); goto error; } - ft = bt_field_type_string_create(); - if (!ft) { - BT_LOGE_STR("Cannot create a string field type object."); + fc = bt_field_class_string_create(); + if (!fc) { + BT_LOGE_STR("Cannot create a string field class object."); goto error; } - ret = bt_field_type_structure_append_member(root_ft, "str", ft); + ret = bt_field_class_structure_append_member(root_fc, "str", fc); if (ret) { - BT_LOGE("Cannot add `str` member to structure field type: " + BT_LOGE("Cannot add `str` member to structure field class: " "ret=%d", ret); goto error; } @@ -105,17 +106,17 @@ struct bt_field_type *create_event_payload_ft(void) goto end; error: - BT_PUT(root_ft); + BT_OBJECT_PUT_REF_AND_RESET(root_fc); end: - bt_put(ft); - return root_ft; + bt_object_put_ref(fc); + return root_fc; } static int create_meta(struct dmesg_component *dmesg_comp, bool has_ts) { - struct bt_field_type *ft = NULL; + struct bt_field_class *fc = NULL; const char *trace_name = NULL; gchar *basename = NULL; int ret = 0; @@ -180,15 +181,15 @@ int create_meta(struct dmesg_component *dmesg_comp, bool has_ts) goto error; } - ft = create_event_payload_ft(); - if (!ft) { - BT_LOGE_STR("Cannot create event payload field type."); + fc = create_event_payload_fc(); + if (!fc) { + BT_LOGE_STR("Cannot create event payload field class."); goto error; } - ret = bt_event_class_set_payload_field_type(dmesg_comp->event_class, ft); + ret = bt_event_class_set_payload_field_class(dmesg_comp->event_class, fc); if (ret) { - BT_LOGE_STR("Cannot set event class's event payload field type."); + BT_LOGE_STR("Cannot set event class's event payload field class."); goto error; } @@ -198,7 +199,7 @@ error: ret = -1; end: - bt_put(ft); + bt_object_put_ref(fc); if (basename) { g_free(basename); @@ -210,18 +211,18 @@ end: static int handle_params(struct dmesg_component *dmesg_comp, struct bt_value *params) { - struct bt_value *read_from_stdin = NULL; struct bt_value *no_timestamp = NULL; struct bt_value *path = NULL; const char *path_str; int ret = 0; - no_timestamp = bt_value_map_get(params, "no-extract-timestamp"); + no_timestamp = bt_value_map_borrow_entry_value(params, + "no-extract-timestamp"); if (no_timestamp) { if (!bt_value_is_bool(no_timestamp)) { BT_LOGE("Expecting a boolean value for the `no-extract-timestamp` parameter: " "type=%s", - bt_value_type_string( + bt_common_value_type_string( bt_value_get_type(no_timestamp))); goto error; } @@ -231,7 +232,7 @@ int handle_params(struct dmesg_component *dmesg_comp, struct bt_value *params) BT_ASSERT(ret == 0); } - path = bt_value_map_get(params, "path"); + path = bt_value_map_borrow_entry_value(params, "path"); if (path) { if (dmesg_comp->params.read_from_stdin) { BT_LOGE_STR("Cannot specify both `read-from-stdin` and `path` parameters."); @@ -241,7 +242,7 @@ int handle_params(struct dmesg_component *dmesg_comp, struct bt_value *params) if (!bt_value_is_string(path)) { BT_LOGE("Expecting a string value for the `path` parameter: " "type=%s", - bt_value_type_string( + bt_common_value_type_string( bt_value_get_type(path))); goto error; } @@ -259,9 +260,6 @@ error: ret = -1; end: - bt_put(read_from_stdin); - bt_put(path); - bt_put(no_timestamp); return ret; } @@ -342,13 +340,13 @@ void destroy_dmesg_component(struct dmesg_component *dmesg_comp) g_string_free(dmesg_comp->params.path, TRUE); } - bt_put(dmesg_comp->packet); - bt_put(dmesg_comp->trace); - bt_put(dmesg_comp->stream_class); - bt_put(dmesg_comp->event_class); - bt_put(dmesg_comp->stream); - bt_put(dmesg_comp->clock_class); - bt_put(dmesg_comp->cc_prio_map); + bt_object_put_ref(dmesg_comp->packet); + bt_object_put_ref(dmesg_comp->trace); + bt_object_put_ref(dmesg_comp->stream_class); + bt_object_put_ref(dmesg_comp->event_class); + bt_object_put_ref(dmesg_comp->stream); + bt_object_put_ref(dmesg_comp->clock_class); + bt_object_put_ref(dmesg_comp->cc_prio_map); g_free(dmesg_comp); } @@ -488,7 +486,7 @@ struct bt_notification *create_init_event_notif_from_line( skip_ts: /* * At this point, we know if the stream class's event header - * field type should have a timestamp or not, so we can lazily + * field class should have a timestamp or not, so we can lazily * create the metadata, stream, and packet objects. */ ret = try_create_meta_stream_packet(dmesg_comp, has_timestamp); @@ -515,7 +513,7 @@ skip_ts: goto end; error: - BT_PUT(notif); + BT_OBJECT_PUT_REF_AND_RESET(notif); end: return notif; @@ -594,7 +592,7 @@ struct bt_notification *create_notif_from_line( goto end; error: - BT_PUT(notif); + BT_OBJECT_PUT_REF_AND_RESET(notif); end: return notif; @@ -613,7 +611,7 @@ void destroy_dmesg_notif_iter(struct dmesg_notif_iter *dmesg_notif_iter) } } - bt_put(dmesg_notif_iter->tmp_event_notif); + bt_object_put_ref(dmesg_notif_iter->tmp_event_notif); free(dmesg_notif_iter->linebuf); g_free(dmesg_notif_iter); } @@ -667,7 +665,7 @@ error: } end: - bt_put(priv_comp); + bt_object_put_ref(priv_comp); return status; }