X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=plugins%2Fctf%2Fcommon%2Fnotif-iter%2Fnotif-iter.c;h=496f95a4222ebdc2e977d0fab866733e4ae3e0b4;hb=dc77b5215ef41c67486cf32bce85bfde0b415952;hp=5b27899c90da191712c6cfb1c493fa1e85849a71;hpb=1487a16a42ca7be6b85ef210644d9ac398d7c0dd;p=babeltrace.git diff --git a/plugins/ctf/common/notif-iter/notif-iter.c b/plugins/ctf/common/notif-iter/notif-iter.c index 5b27899c..496f95a4 100644 --- a/plugins/ctf/common/notif-iter/notif-iter.c +++ b/plugins/ctf/common/notif-iter/notif-iter.c @@ -47,7 +47,7 @@ #define PRINT_ERR_STREAM notit->err_stream #define PRINT_PREFIX "ctf-notif-iter" -#include "print.h" +#include "../print.h" #include "notif-iter.h" #include "../btr/btr.h" @@ -162,9 +162,6 @@ struct bt_ctf_notif_iter { struct bt_ctf_event_class *event_class; } meta; - /* Clock class priority map (owned by this) */ - struct bt_clock_class_priority_map *cc_prio_map; - /* Current packet (NULL if not created yet) */ struct bt_ctf_packet *packet; @@ -364,7 +361,7 @@ static inline enum bt_ctf_notif_iter_status notif_iter_status_from_m_status( enum bt_ctf_notif_iter_medium_status m_status) { - return m_status; + return (int) m_status; } static inline @@ -385,38 +382,12 @@ size_t packet_at(struct bt_ctf_notif_iter *notit) return notit->buf.packet_offset + notit->buf.at; } -static inline -size_t remaining_content_bits(struct bt_ctf_notif_iter *notit) -{ - if (notit->cur_content_size == -1) { - return -1; - } - - return notit->cur_content_size - packet_at(notit); -} - -static inline -size_t remaining_packet_bits(struct bt_ctf_notif_iter *notit) -{ - if (notit->cur_packet_size == -1) { - return -1; - } - - return notit->cur_packet_size - packet_at(notit); -} - static inline void buf_consume_bits(struct bt_ctf_notif_iter *notit, size_t incr) { notit->buf.at += incr; } -static inline -bool buf_has_enough_bits(struct bt_ctf_notif_iter *notit, size_t sz) -{ - return buf_available_bits(notit) >= sz; -} - static enum bt_ctf_notif_iter_status request_medium_bytes( struct bt_ctf_notif_iter *notit) @@ -1491,18 +1462,23 @@ end: static enum bt_ctf_btr_status update_clock(struct bt_ctf_notif_iter *notit, - struct bt_ctf_field_type *int_field_type, struct bt_ctf_field *int_field) { gboolean clock_class_found; uint64_t *clock_state; + struct bt_ctf_field_type *int_field_type = NULL; enum bt_ctf_btr_status ret = BT_CTF_BTR_STATUS_OK; - struct bt_ctf_clock_class *clock_class = - bt_ctf_field_type_integer_get_mapped_clock_class( - int_field_type); + struct bt_ctf_clock_class *clock_class = NULL; + int_field_type = bt_ctf_field_get_type(int_field); + if (unlikely(!int_field_type)) { + goto end; + } + + clock_class = bt_ctf_field_type_integer_get_mapped_clock_class( + int_field_type); if (likely(!clock_class)) { - goto end_no_clock; + goto end; } clock_class_found = g_hash_table_lookup_extended(notit->clock_states, @@ -1530,15 +1506,15 @@ enum bt_ctf_btr_status update_clock(struct bt_ctf_notif_iter *notit, /* Update the clock's state. */ update_clock_state(clock_state, int_field); end: + bt_put(int_field_type); bt_put(clock_class); -end_no_clock: return ret; } static enum bt_ctf_btr_status btr_unsigned_int_common(uint64_t value, struct bt_ctf_field_type *type, void *data, - struct bt_ctf_field **_field) + struct bt_ctf_field **out_int_field) { enum bt_ctf_btr_status status = BT_CTF_BTR_STATUS_OK; struct bt_ctf_field *field = NULL; @@ -1579,7 +1555,7 @@ enum bt_ctf_btr_status btr_unsigned_int_common(uint64_t value, ret = bt_ctf_field_unsigned_integer_set_value(int_field, value); assert(!ret); stack_top(notit->stack)->index++; - *_field = int_field; + *out_int_field = int_field; end: BT_PUT(field); @@ -1625,7 +1601,7 @@ enum bt_ctf_btr_status btr_unsigned_int_cb(uint64_t value, goto end; } - status = update_clock(notit, type, field); + status = update_clock(notit, field); BT_PUT(field); end: return status; @@ -1674,7 +1650,7 @@ enum bt_ctf_btr_status btr_signed_int_cb(int64_t value, ret = bt_ctf_field_signed_integer_set_value(int_field, value); assert(!ret); stack_top(notit->stack)->index++; - status = update_clock(notit, type, int_field); + status = update_clock(notit, int_field); end: BT_PUT(field); BT_PUT(int_field); @@ -2080,7 +2056,7 @@ struct bt_ctf_event *create_event(struct bt_ctf_notif_iter *notit) goto error; } - ret = bt_ctf_event_set_payload_field(event, + ret = bt_ctf_event_set_event_payload(event, notit->dscopes.event_payload); if (ret) { goto error; @@ -2188,6 +2164,7 @@ void notify_end_of_packet(struct bt_ctf_notif_iter *notit, static void notify_event(struct bt_ctf_notif_iter *notit, + struct bt_clock_class_priority_map *cc_prio_map, struct bt_notification **notification) { struct bt_ctf_event *event; @@ -2199,7 +2176,7 @@ void notify_event(struct bt_ctf_notif_iter *notit, goto end; } - ret = bt_notification_event_create(event, notit->cc_prio_map); + ret = bt_notification_event_create(event, cc_prio_map); if (!ret) { goto end; } @@ -2208,30 +2185,6 @@ end: BT_PUT(event); } -//FIXME: not used ? -static -void notify_eos(struct bt_ctf_notif_iter *notit, - struct bt_notification **notification) -{ - struct bt_ctf_stream *stream = NULL; - struct bt_notification *ret = NULL; - - /* Ask the user for the stream */ - stream = notit->medium.medops.get_stream(notit->meta.stream_class, - notit->medium.data); - if (!stream) { - goto end; - } - - ret = bt_notification_stream_end_create(stream); - if (!ret) { - goto end; - } - *notification = ret; -end: - BT_PUT(stream); -} - static int init_clock_states(GHashTable *clock_states, struct bt_ctf_trace *trace) { @@ -2246,7 +2199,7 @@ int init_clock_states(GHashTable *clock_states, struct bt_ctf_trace *trace) for (i = 0; i < clock_class_count; i++) { struct bt_ctf_clock_class *clock_class; - clock_class = bt_ctf_trace_get_clock_class(trace, i); + clock_class = bt_ctf_trace_get_clock_class_by_index(trace, i); if (!clock_class) { ret = -1; goto end; @@ -2307,7 +2260,6 @@ end: BT_HIDDEN struct bt_ctf_notif_iter *bt_ctf_notif_iter_create(struct bt_ctf_trace *trace, - struct bt_clock_class_priority_map *cc_prio_map, size_t max_request_sz, struct bt_ctf_notif_iter_medium_ops medops, void *data, FILE *err_stream) @@ -2332,7 +2284,6 @@ struct bt_ctf_notif_iter *bt_ctf_notif_iter_create(struct bt_ctf_trace *trace, }; assert(trace); - assert(cc_prio_map); assert(medops.request_bytes); assert(medops.get_stream); notit = g_new0(struct bt_ctf_notif_iter, 1); @@ -2351,7 +2302,6 @@ struct bt_ctf_notif_iter *bt_ctf_notif_iter_create(struct bt_ctf_trace *trace, PERR("Failed to initialize stream clock states\n"); goto error; } - notit->cc_prio_map = bt_get(cc_prio_map); notit->meta.trace = bt_get(trace); notit->medium.medops = medops; notit->medium.max_request_sz = max_request_sz; @@ -2395,7 +2345,6 @@ error: void bt_ctf_notif_iter_destroy(struct bt_ctf_notif_iter *notit) { - BT_PUT(notit->cc_prio_map); BT_PUT(notit->meta.trace); BT_PUT(notit->meta.stream_class); BT_PUT(notit->meta.event_class); @@ -2427,6 +2376,7 @@ void bt_ctf_notif_iter_destroy(struct bt_ctf_notif_iter *notit) enum bt_ctf_notif_iter_status bt_ctf_notif_iter_get_next_notification( struct bt_ctf_notif_iter *notit, + struct bt_clock_class_priority_map *cc_prio_map, struct bt_notification **notification) { enum bt_ctf_notif_iter_status status = BT_CTF_NOTIF_ITER_STATUS_OK; @@ -2456,7 +2406,7 @@ enum bt_ctf_notif_iter_status bt_ctf_notif_iter_get_next_notification( goto end; case STATE_EMIT_NOTIF_EVENT: PDBG("Emitting event notification\n"); - notify_event(notit, notification); + notify_event(notit, cc_prio_map, notification); if (!*notification) { status = BT_CTF_NOTIF_ITER_STATUS_ERROR; } @@ -2469,8 +2419,8 @@ enum bt_ctf_notif_iter_status bt_ctf_notif_iter_get_next_notification( bt_ctf_field_get_type( notit->cur_timestamp_end); - btr_status = update_clock(notit, field_type, - notit->cur_timestamp_end); + btr_status = update_clock(notit, + notit->cur_timestamp_end); BT_PUT(field_type); if (btr_status != BT_CTF_BTR_STATUS_OK) { status = BT_CTF_NOTIF_ITER_STATUS_ERROR;