X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=plugins%2Fctf%2Fcommon%2Fnotif-iter%2Fnotif-iter.c;h=3d377d356305960c42fa8ec54ef80193d53ba653;hb=b19ff26f04df428047676dd736bd7cc9473906fe;hp=b7be219f0de02cb1f768d091d050a6c8547db411;hpb=4049342bb92bed5552ef3878eb39d18a387cd21e;p=babeltrace.git diff --git a/plugins/ctf/common/notif-iter/notif-iter.c b/plugins/ctf/common/notif-iter/notif-iter.c index b7be219f..3d377d35 100644 --- a/plugins/ctf/common/notif-iter/notif-iter.c +++ b/plugins/ctf/common/notif-iter/notif-iter.c @@ -56,7 +56,7 @@ struct stack_entry { * * Field is borrowed. */ - struct bt_field *base; + bt_field *base; /* Index of next field to set */ size_t index; @@ -103,7 +103,7 @@ struct bt_notif_iter { struct stack *stack; /* Current notification iterator to create notifications (weak) */ - struct bt_self_notification_iterator *notif_iter; + bt_self_notification_iterator *notif_iter; /* * Current dynamic scope field pointer. @@ -111,7 +111,7 @@ struct bt_notif_iter { * This is set by read_dscope_begin_state() and contains the * value of one of the pointers in `dscopes` below. */ - struct bt_field *cur_dscope_field; + bt_field *cur_dscope_field; /* * True if we're done filling a string field from a text @@ -127,34 +127,34 @@ struct bt_notif_iter { } meta; /* Current packet header field wrapper (NULL if not created yet) */ - struct bt_packet_header_field *packet_header_field; + bt_packet_header_field *packet_header_field; /* Current packet header field wrapper (NULL if not created yet) */ - struct bt_packet_context_field *packet_context_field; + bt_packet_context_field *packet_context_field; /* Current event header field (NULL if not created yet) */ - struct bt_event_header_field *event_header_field; + bt_event_header_field *event_header_field; /* Current packet (NULL if not created yet) */ - struct bt_packet *packet; + bt_packet *packet; /* Current stream (NULL if not set yet) */ - struct bt_stream *stream; + bt_stream *stream; /* Current event (NULL if not created yet) */ - struct bt_event *event; + bt_event *event; /* Current event notification (NULL if not created yet) */ - struct bt_private_notification *event_notif; + bt_notification *event_notif; /* Database of current dynamic scopes */ struct { - struct bt_field *trace_packet_header; - struct bt_field *stream_packet_context; - struct bt_field *event_header; - struct bt_field *event_common_context; - struct bt_field *event_spec_context; - struct bt_field *event_payload; + bt_field *trace_packet_header; + bt_field *stream_packet_context; + bt_field *event_header; + bt_field *event_common_context; + bt_field *event_spec_context; + bt_field *event_payload; } dscopes; /* Current state */ @@ -325,7 +325,7 @@ void stack_destroy(struct stack *stack) } static -void stack_push(struct stack *stack, struct bt_field *base) +void stack_push(struct stack *stack, bt_field *base) { struct stack_entry *entry; @@ -520,7 +520,7 @@ enum bt_notif_iter_status read_dscope_begin_state( struct bt_notif_iter *notit, struct ctf_field_class *dscope_fc, enum state done_state, enum state continue_state, - struct bt_field *dscope_field) + bt_field *dscope_field) { enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK; enum bt_bfcr_status bfcr_status; @@ -661,7 +661,7 @@ enum bt_notif_iter_status read_packet_header_begin_state( goto end; } - /* Packet header class is common to the whole trace. */ + /* Packet header class is common to the whole trace class. */ packet_header_fc = notit->meta.tc->packet_header_fc; if (!packet_header_fc) { notit->state = STATE_AFTER_TRACE_PACKET_HEADER; @@ -672,8 +672,8 @@ enum bt_notif_iter_status read_packet_header_begin_state( if (packet_header_fc->in_ir) { /* - * Create free packet header field from trace. This - * field is going to be moved to the packet once we + * Create free packet header field from trace class. + * This field is going to be moved to the packet once we * create it. We cannot create the packet now because: * * 1. A packet is created from a stream. @@ -685,7 +685,7 @@ enum bt_notif_iter_status read_packet_header_begin_state( bt_packet_header_field_create( notit->meta.tc->ir_tc); if (!notit->packet_header_field) { - BT_LOGE_STR("Cannot create packet header field wrapper from trace."); + BT_LOGE_STR("Cannot create packet header field wrapper from trace class."); ret = BT_NOTIF_ITER_STATUS_ERROR; goto end; } @@ -700,20 +700,17 @@ enum bt_notif_iter_status read_packet_header_begin_state( notit->cur_event_class_id = -1; notit->cur_data_stream_id = -1; BT_LOGV("Decoding packet header field:" - "notit-addr=%p, trace-addr=%p, trace-name=\"%s\", fc-addr=%p", - notit, notit->meta.tc, - notit->meta.tc->name->str, packet_header_fc); + "notit-addr=%p, trace-class-addr=%p, fc-addr=%p", + notit, notit->meta.tc, packet_header_fc); ret = read_dscope_begin_state(notit, packet_header_fc, STATE_AFTER_TRACE_PACKET_HEADER, STATE_DSCOPE_TRACE_PACKET_HEADER_CONTINUE, notit->dscopes.trace_packet_header); if (ret < 0) { BT_LOGW("Cannot decode packet header field: " - "notit-addr=%p, trace-addr=%p, " - "trace-name=\"%s\", fc-addr=%p", - notit, notit->meta.tc, - notit->meta.tc->name->str, - packet_header_fc); + "notit-addr=%p, trace-class-addr=%p, " + "fc-addr=%p", + notit, notit->meta.tc, packet_header_fc); } end: @@ -742,8 +739,7 @@ enum bt_notif_iter_status set_current_stream_class(struct bt_notif_iter *notit) if (notit->meta.tc->stream_classes->len != 1) { BT_LOGW("Need exactly one stream class since there's " "no stream class ID field: " - "notit-addr=%p, trace-name=\"%s\"", - notit, notit->meta.tc->name->str); + "notit-addr=%p", notit); status = BT_NOTIF_ITER_STATUS_ERROR; goto end; } @@ -755,11 +751,10 @@ enum bt_notif_iter_status set_current_stream_class(struct bt_notif_iter *notit) new_stream_class = ctf_trace_class_borrow_stream_class_by_id( notit->meta.tc, notit->cur_stream_class_id); if (!new_stream_class) { - BT_LOGW("No stream class with ID of stream class ID to use in trace: " + BT_LOGW("No stream class with ID of stream class ID to use in trace class: " "notit-addr=%p, stream-class-id=%" PRIu64 ", " - "trace-addr=%p, trace-name=\"%s\"", - notit, notit->cur_stream_class_id, notit->meta.tc, - notit->meta.tc->name->str); + "trace-class-addr=%p", + notit, notit->cur_stream_class_id, notit->meta.tc); status = BT_NOTIF_ITER_STATUS_ERROR; goto end; } @@ -771,13 +766,12 @@ enum bt_notif_iter_status set_current_stream_class(struct bt_notif_iter *notit) "prev-stream-class-id=%" PRId64 ", " "next-stream-class-addr=%p, " "next-stream-class-id=%" PRId64 ", " - "trace-addr=%p, trace-name=\"%s\"", + "trace-addr=%p", notit, notit->meta.sc, notit->meta.sc->id, new_stream_class, new_stream_class->id, - notit->meta.tc, - notit->meta.tc->name->str); + notit->meta.tc); status = BT_NOTIF_ITER_STATUS_ERROR; goto end; } @@ -798,7 +792,7 @@ static inline enum bt_notif_iter_status set_current_stream(struct bt_notif_iter *notit) { enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK; - struct bt_stream *stream = NULL; + bt_stream *stream = NULL; BT_LOGV("Calling user function (get stream): notit-addr=%p, " "stream-class-addr=%p, stream-class-id=%" PRId64, @@ -807,7 +801,7 @@ enum bt_notif_iter_status set_current_stream(struct bt_notif_iter *notit) stream = notit->medium.medops.borrow_stream( notit->meta.sc->ir_sc, notit->cur_data_stream_id, notit->medium.data); - bt_object_get_ref(stream); + bt_stream_get_ref(stream); BT_LOGV("User function returned: stream-addr=%p", stream); if (!stream) { BT_LOGW_STR("User function failed to return a stream object " @@ -823,10 +817,10 @@ enum bt_notif_iter_status set_current_stream(struct bt_notif_iter *notit) goto end; } - BT_OBJECT_MOVE_REF(notit->stream, stream); + BT_STREAM_MOVE_REF(notit->stream, stream); end: - bt_object_put_ref(stream); + bt_stream_put_ref(stream); return status; } @@ -834,7 +828,7 @@ static inline enum bt_notif_iter_status set_current_packet(struct bt_notif_iter *notit) { enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK; - struct bt_packet *packet = NULL; + bt_packet *packet = NULL; BT_LOGV("Creating packet for packet notification: " "notit-addr=%p", notit); @@ -861,11 +855,11 @@ enum bt_notif_iter_status set_current_packet(struct bt_notif_iter *notit) goto end; error: - BT_OBJECT_PUT_REF_AND_RESET(packet); + BT_PACKET_PUT_REF_AND_RESET(packet); status = BT_NOTIF_ITER_STATUS_ERROR; end: - BT_OBJECT_MOVE_REF(notit->packet, packet); + BT_PACKET_MOVE_REF(notit->packet, packet); return status; } @@ -1099,7 +1093,7 @@ enum bt_notif_iter_status read_event_header_begin_state( bt_event_header_field_create( notit->meta.sc->ir_sc); if (!notit->event_header_field) { - BT_LOGE_STR("Cannot create event header field wrapper from trace."); + BT_LOGE_STR("Cannot create event header field wrapper from trace class."); status = BT_NOTIF_ITER_STATUS_ERROR; goto end; } @@ -1157,8 +1151,7 @@ enum bt_notif_iter_status set_current_event_class(struct bt_notif_iter *notit) if (notit->meta.sc->event_classes->len != 1) { BT_LOGW("Need exactly one event class since there's " "no event class ID field: " - "notit-addr=%p, trace-name=\"%s\"", - notit, notit->meta.tc->name->str); + "notit-addr=%p", notit); status = BT_NOTIF_ITER_STATUS_ERROR; goto end; } @@ -1173,9 +1166,9 @@ enum bt_notif_iter_status set_current_event_class(struct bt_notif_iter *notit) BT_LOGW("No event class with ID of event class ID to use in stream class: " "notit-addr=%p, stream-class-id=%" PRIu64 ", " "event-class-id=%" PRIu64 ", " - "trace-addr=%p, trace-name=\"%s\"", + "trace-class-addr=%p", notit, notit->meta.sc->id, notit->cur_event_class_id, - notit->meta.tc, notit->meta.tc->name->str); + notit->meta.tc); status = BT_NOTIF_ITER_STATUS_ERROR; goto end; } @@ -1197,7 +1190,7 @@ enum bt_notif_iter_status set_current_event_notification( struct bt_notif_iter *notit) { enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK; - struct bt_private_notification *notif = NULL; + bt_notification *notif = NULL; BT_ASSERT(notit->meta.ec); BT_ASSERT(notit->packet); @@ -1207,7 +1200,7 @@ enum bt_notif_iter_status set_current_event_notification( notit->meta.ec->name->str, notit->packet); BT_ASSERT(notit->notif_iter); - notif = bt_private_notification_event_create(notit->notif_iter, + notif = bt_notification_event_create(notit->notif_iter, notit->meta.ec->ir_ec, notit->packet); if (!notif) { BT_LOGE("Cannot create event notification: " @@ -1222,11 +1215,11 @@ enum bt_notif_iter_status set_current_event_notification( goto end; error: - BT_OBJECT_PUT_REF_AND_RESET(notif); + BT_NOTIFICATION_PUT_REF_AND_RESET(notif); status = BT_NOTIF_ITER_STATUS_ERROR; end: - BT_OBJECT_MOVE_REF(notit->event_notif, notif); + BT_NOTIFICATION_MOVE_REF(notit->event_notif, notif); return status; } @@ -1246,7 +1239,7 @@ enum bt_notif_iter_status after_event_header_state( goto end; } - notit->event = bt_private_notification_event_borrow_event( + notit->event = bt_notification_event_borrow_event( notit->event_notif); BT_ASSERT(notit->event); @@ -1578,9 +1571,9 @@ void bt_notif_iter_reset(struct bt_notif_iter *notit) stack_clear(notit->stack); notit->meta.sc = NULL; notit->meta.ec = NULL; - BT_OBJECT_PUT_REF_AND_RESET(notit->packet); - BT_OBJECT_PUT_REF_AND_RESET(notit->stream); - BT_OBJECT_PUT_REF_AND_RESET(notit->event_notif); + BT_PACKET_PUT_REF_AND_RESET(notit->packet); + BT_STREAM_PUT_REF_AND_RESET(notit->stream); + BT_NOTIFICATION_PUT_REF_AND_RESET(notit->event_notif); release_all_dscopes(notit); notit->cur_dscope_field = NULL; @@ -1635,8 +1628,8 @@ int bt_notif_iter_switch_packet(struct bt_notif_iter *notit) notit->cur_packet_offset); stack_clear(notit->stack); notit->meta.ec = NULL; - BT_OBJECT_PUT_REF_AND_RESET(notit->packet); - BT_OBJECT_PUT_REF_AND_RESET(notit->event_notif); + BT_PACKET_PUT_REF_AND_RESET(notit->packet); + BT_NOTIFICATION_PUT_REF_AND_RESET(notit->event_notif); release_all_dscopes(notit); notit->cur_dscope_field = NULL; @@ -1678,11 +1671,11 @@ end: } static -struct bt_field *borrow_next_field(struct bt_notif_iter *notit) +bt_field *borrow_next_field(struct bt_notif_iter *notit) { - struct bt_field *next_field = NULL; - struct bt_field *base_field; - const struct bt_field_class *base_fc; + bt_field *next_field = NULL; + bt_field *base_field; + const bt_field_class *base_fc; size_t index; BT_ASSERT(!stack_empty(notit->stack)); @@ -1771,7 +1764,7 @@ enum bt_bfcr_status bfcr_unsigned_int_cb(uint64_t value, { struct bt_notif_iter *notit = data; enum bt_bfcr_status status = BT_BFCR_STATUS_OK; - struct bt_field *field = NULL; + bt_field *field = NULL; struct ctf_field_class_int *int_fc = (void *) fc; BT_LOGV("Unsigned integer function called from BFCR: " @@ -1859,7 +1852,7 @@ enum bt_bfcr_status bfcr_unsigned_int_char_cb(uint64_t value, int ret; struct bt_notif_iter *notit = data; enum bt_bfcr_status status = BT_BFCR_STATUS_OK; - struct bt_field *string_field = NULL; + bt_field *string_field = NULL; struct ctf_field_class_int *int_fc = (void *) fc; char str[2] = {'\0', '\0'}; @@ -1908,7 +1901,7 @@ enum bt_bfcr_status bfcr_signed_int_cb(int64_t value, struct ctf_field_class *fc, void *data) { enum bt_bfcr_status status = BT_BFCR_STATUS_OK; - struct bt_field *field = NULL; + bt_field *field = NULL; struct bt_notif_iter *notit = data; struct ctf_field_class_int *int_fc = (void *) fc; @@ -1946,7 +1939,7 @@ enum bt_bfcr_status bfcr_floating_point_cb(double value, struct ctf_field_class *fc, void *data) { enum bt_bfcr_status status = BT_BFCR_STATUS_OK; - struct bt_field *field = NULL; + bt_field *field = NULL; struct bt_notif_iter *notit = data; BT_LOGV("Floating point number function called from BFCR: " @@ -1968,7 +1961,7 @@ static enum bt_bfcr_status bfcr_string_begin_cb( struct ctf_field_class *fc, void *data) { - struct bt_field *field = NULL; + bt_field *field = NULL; struct bt_notif_iter *notit = data; int ret; @@ -2000,7 +1993,7 @@ enum bt_bfcr_status bfcr_string_cb(const char *value, size_t len, struct ctf_field_class *fc, void *data) { enum bt_bfcr_status status = BT_BFCR_STATUS_OK; - struct bt_field *field = NULL; + bt_field *field = NULL; struct bt_notif_iter *notit = data; int ret; @@ -2051,7 +2044,7 @@ enum bt_bfcr_status bfcr_compound_begin_cb( struct ctf_field_class *fc, void *data) { struct bt_notif_iter *notit = data; - struct bt_field *field; + bt_field *field; BT_LOGV("Compound (beginning) function called from BFCR: " "notit-addr=%p, bfcr-addr=%p, fc-addr=%p, " @@ -2151,7 +2144,7 @@ end: static int64_t bfcr_get_sequence_length_cb(struct ctf_field_class *fc, void *data) { - struct bt_field *seq_field; + bt_field *seq_field; struct bt_notif_iter *notit = data; struct ctf_field_class_sequence *seq_fc = (void *) fc; int64_t length = -1; @@ -2231,7 +2224,7 @@ struct ctf_field_class *bfcr_borrow_variant_selected_field_class_cb( var_fc, (uint64_t) option_index); if (selected_option->fc->in_ir) { - struct bt_field *var_field = stack_top(notit->stack)->base; + bt_field *var_field = stack_top(notit->stack)->base; ret = bt_field_variant_select_option_field( var_field, option_index); @@ -2253,10 +2246,10 @@ end: static void set_event_default_clock_value(struct bt_notif_iter *notit) { - struct bt_event *event = - bt_private_notification_event_borrow_event( + bt_event *event = + bt_notification_event_borrow_event( notit->event_notif); - struct bt_stream_class *sc = notit->meta.sc->ir_sc; + bt_stream_class *sc = notit->meta.sc->ir_sc; BT_ASSERT(event); @@ -2268,20 +2261,20 @@ void set_event_default_clock_value(struct bt_notif_iter *notit) static void notify_new_stream(struct bt_notif_iter *notit, - struct bt_private_notification **notification) + bt_notification **notification) { enum bt_notif_iter_status status; - struct bt_private_notification *ret = NULL; + bt_notification *ret = NULL; status = set_current_stream(notit); if (status != BT_NOTIF_ITER_STATUS_OK) { - BT_OBJECT_PUT_REF_AND_RESET(ret); + BT_NOTIFICATION_PUT_REF_AND_RESET(ret); goto end; } BT_ASSERT(notit->stream); BT_ASSERT(notit->notif_iter); - ret = bt_private_notification_stream_begin_create(notit->notif_iter, + ret = bt_notification_stream_beginning_create(notit->notif_iter, notit->stream); if (!ret) { BT_LOGE("Cannot create stream beginning notification: " @@ -2296,9 +2289,9 @@ end: static void notify_end_of_stream(struct bt_notif_iter *notit, - struct bt_private_notification **notification) + bt_notification **notification) { - struct bt_private_notification *ret; + bt_notification *ret; if (!notit->stream) { BT_LOGE("Cannot create stream for stream notification: " @@ -2307,7 +2300,7 @@ void notify_end_of_stream(struct bt_notif_iter *notit, } BT_ASSERT(notit->notif_iter); - ret = bt_private_notification_stream_end_create(notit->notif_iter, + ret = bt_notification_stream_end_create(notit->notif_iter, notit->stream); if (!ret) { BT_LOGE("Cannot create stream beginning notification: " @@ -2320,12 +2313,12 @@ void notify_end_of_stream(struct bt_notif_iter *notit, static void notify_new_packet(struct bt_notif_iter *notit, - struct bt_private_notification **notification) + bt_notification **notification) { int ret; enum bt_notif_iter_status status; - struct bt_private_notification *notif = NULL; - const struct bt_stream_class *sc; + bt_notification *notif = NULL; + const bt_stream_class *sc; status = set_current_packet(notit); if (status != BT_NOTIF_ITER_STATUS_OK) { @@ -2399,7 +2392,7 @@ void notify_new_packet(struct bt_notif_iter *notit, } BT_ASSERT(notit->notif_iter); - notif = bt_private_notification_packet_begin_create(notit->notif_iter, + notif = bt_notification_packet_beginning_create(notit->notif_iter, notit->packet); if (!notif) { BT_LOGE("Cannot create packet beginning notification: " @@ -2416,9 +2409,9 @@ end: static void notify_end_of_packet(struct bt_notif_iter *notit, - struct bt_private_notification **notification) + bt_notification **notification) { - struct bt_private_notification *notif; + bt_notification *notif; if (!notit->packet) { return; @@ -2430,7 +2423,7 @@ void notify_end_of_packet(struct bt_notif_iter *notit, } BT_ASSERT(notit->notif_iter); - notif = bt_private_notification_packet_end_create(notit->notif_iter, + notif = bt_notification_packet_end_create(notit->notif_iter, notit->packet); if (!notif) { BT_LOGE("Cannot create packet end notification: " @@ -2440,7 +2433,7 @@ void notify_end_of_packet(struct bt_notif_iter *notit, } - BT_OBJECT_PUT_REF_AND_RESET(notit->packet); + BT_PACKET_PUT_REF_AND_RESET(notit->packet); *notification = notif; } @@ -2471,8 +2464,8 @@ struct bt_notif_iter *bt_notif_iter_create(struct ctf_trace_class *tc, BT_ASSERT(medops.request_bytes); BT_ASSERT(medops.borrow_stream); BT_LOGD("Creating CTF plugin notification iterator: " - "trace-addr=%p, trace-name=\"%s\", max-request-size=%zu, " - "data=%p", tc, tc->name->str, max_request_sz, data); + "trace-addr=%p, max-request-size=%zu, " + "data=%p", tc, max_request_sz, data); notit = g_new0(struct bt_notif_iter, 1); if (!notit) { BT_LOGE_STR("Failed to allocate one CTF plugin notification iterator."); @@ -2499,10 +2492,9 @@ struct bt_notif_iter *bt_notif_iter_create(struct ctf_trace_class *tc, bt_notif_iter_reset(notit); BT_LOGD("Created CTF plugin notification iterator: " - "trace-addr=%p, trace-name=\"%s\", max-request-size=%zu, " + "trace-addr=%p, max-request-size=%zu, " "data=%p, notit-addr=%p", - tc, tc->name->str, max_request_sz, data, - notit); + tc, max_request_sz, data, notit); notit->cur_packet_offset = 0; end: @@ -2516,8 +2508,8 @@ error: void bt_notif_iter_destroy(struct bt_notif_iter *notit) { - BT_OBJECT_PUT_REF_AND_RESET(notit->packet); - BT_OBJECT_PUT_REF_AND_RESET(notit->stream); + BT_PACKET_PUT_REF_AND_RESET(notit->packet); + BT_STREAM_PUT_REF_AND_RESET(notit->stream); release_all_dscopes(notit); BT_LOGD("Destroying CTF plugin notification iterator: addr=%p", notit); @@ -2541,8 +2533,8 @@ void bt_notif_iter_destroy(struct bt_notif_iter *notit) enum bt_notif_iter_status bt_notif_iter_get_next_notification( struct bt_notif_iter *notit, - struct bt_self_notification_iterator *notif_iter, - struct bt_private_notification **notification) + bt_self_notification_iterator *notif_iter, + bt_notification **notification) { enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK; @@ -2644,8 +2636,8 @@ end: BT_HIDDEN enum bt_notif_iter_status bt_notif_iter_borrow_packet_header_context_fields( struct bt_notif_iter *notit, - struct bt_field **packet_header_field, - struct bt_field **packet_context_field) + bt_field **packet_header_field, + bt_field **packet_context_field) { int ret; enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK;