X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=lib%2Fctf-ir%2Fevent.c;h=62fc4328cb1081c972f13eb5616c30b1c18cf590;hb=c057dea051159b06050ab5d6b640dfb7e1654ba7;hp=db3c446a87903534ce52fbb34bfc76ff402f8fed;hpb=ffffc5262b746805569c0bc946ad3c48443f02f8;p=babeltrace.git diff --git a/lib/ctf-ir/event.c b/lib/ctf-ir/event.c index db3c446a..62fc4328 100644 --- a/lib/ctf-ir/event.c +++ b/lib/ctf-ir/event.c @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include #include #include @@ -98,9 +100,6 @@ struct bt_ctf_event *bt_ctf_event_create(struct bt_ctf_event_class *event_class) goto error; } - /* A stream class should always have an existing event header type */ - assert(stream_class->event_header_type); - /* The event class was frozen when added to its stream class */ assert(event_class->frozen); @@ -145,7 +144,7 @@ struct bt_ctf_event *bt_ctf_event_create(struct bt_ctf_event_class *event_class) if ((validation_output.valid_flags & validation_flags) != validation_flags) { /* Invalid trace/stream class/event class */ - BT_LOGE("Invalid trace, stream class, or event class: " + BT_LOGW("Invalid trace, stream class, or event class: " "valid-flags=0x%x", validation_output.valid_flags); goto error; } @@ -174,14 +173,21 @@ struct bt_ctf_event *bt_ctf_event_create(struct bt_ctf_event_class *event_class) event->event_class = bt_get(event_class); event->clock_values = g_hash_table_new_full(g_direct_hash, g_direct_equal, bt_put, bt_put); - event_header = - bt_ctf_field_create(validation_output.event_header_type); - if (!event_header) { - BT_LOGE_STR("Cannot create initial event header field object."); - goto error; + + if (validation_output.event_header_type) { + BT_LOGD("Creating initial event header field: ft-addr=%p", + validation_output.event_header_type); + event_header = + bt_ctf_field_create(validation_output.event_header_type); + if (!event_header) { + BT_LOGE_STR("Cannot create initial event header field object."); + goto error; + } } if (validation_output.stream_event_ctx_type) { + BT_LOGD("Creating initial stream event context field: ft-addr=%p", + validation_output.stream_event_ctx_type); stream_event_context = bt_ctf_field_create( validation_output.stream_event_ctx_type); if (!stream_event_context) { @@ -191,6 +197,8 @@ struct bt_ctf_event *bt_ctf_event_create(struct bt_ctf_event_class *event_class) } if (validation_output.event_context_type) { + BT_LOGD("Creating initial event context field: ft-addr=%p", + validation_output.event_context_type); event_context = bt_ctf_field_create( validation_output.event_context_type); if (!event_context) { @@ -200,6 +208,8 @@ struct bt_ctf_event *bt_ctf_event_create(struct bt_ctf_event_class *event_class) } if (validation_output.event_payload_type) { + BT_LOGD("Creating initial event payload field: ft-addr=%p", + validation_output.event_payload_type); event_payload = bt_ctf_field_create( validation_output.event_payload_type); if (!event_payload) { @@ -276,8 +286,7 @@ struct bt_ctf_event_class *bt_ctf_event_get_class(struct bt_ctf_event *event) goto end; } - event_class = event ? bt_get(bt_ctf_event_borrow_event_class(event)) : - NULL; + event_class = bt_get(bt_ctf_event_borrow_event_class(event)); end: return event_class; } @@ -332,8 +341,8 @@ int bt_ctf_event_set_payload(struct bt_ctf_event *event, } if (name) { - ret = bt_ctf_field_structure_set_field(event->fields_payload, - name, payload); + ret = bt_ctf_field_structure_set_field_by_name( + event->fields_payload, name, payload); } else { struct bt_ctf_field_type *payload_type; @@ -860,14 +869,16 @@ int bt_ctf_event_validate(struct bt_ctf_event *event) struct bt_ctf_stream_class *stream_class = NULL; assert(event); - ret = bt_ctf_field_validate(event->event_header); - if (ret) { - BT_LOGD("Invalid event's header field: " - "event-addr=%p, event-class-name=\"%s\", " - "event-class-id=%" PRId64, - event, bt_ctf_event_class_get_name(event->event_class), - bt_ctf_event_class_get_id(event->event_class)); - goto end; + if (event->event_header) { + ret = bt_ctf_field_validate(event->event_header); + if (ret) { + BT_LOGD("Invalid event's header field: " + "event-addr=%p, event-class-name=\"%s\", " + "event-class-id=%" PRId64, + event, bt_ctf_event_class_get_name(event->event_class), + bt_ctf_event_class_get_id(event->event_class)); + goto end; + } } stream_class = bt_ctf_event_class_get_stream_class(event->event_class); @@ -929,7 +940,7 @@ int bt_ctf_event_serialize(struct bt_ctf_event *event, ret = bt_ctf_field_serialize(event->context_payload, pos, native_byte_order); if (ret) { - BT_LOGE("Cannot serialize event's context field: " + BT_LOGW("Cannot serialize event's context field: " "event-addr=%p, event-class-name=\"%s\", " "event-class-id=%" PRId64, event, @@ -944,7 +955,7 @@ int bt_ctf_event_serialize(struct bt_ctf_event *event, ret = bt_ctf_field_serialize(event->fields_payload, pos, native_byte_order); if (ret) { - BT_LOGE("Cannot serialize event's payload field: " + BT_LOGW("Cannot serialize event's payload field: " "event-addr=%p, event-class-name=\"%s\", " "event-class-id=%" PRId64, event,