* associated to a stream class.
*/
if (!stream_class) {
- BT_LOGW("Event class is not part of a stream class: "
- "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_class));
+ BT_LOGW_STR("Event class is not part of a stream 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);
/* Validate the trace (if any), the stream class, and the event class */
trace = bt_ctf_stream_class_get_trace(stream_class);
if (trace) {
- BT_LOGD("Event's class is part of a trace: "
- "event-class-name=\"%s\", event-class-id=%" PRId64,
- bt_ctf_event_class_get_name(event_class),
- bt_ctf_event_class_get_id(event_class));
+ BT_LOGD_STR("Event's class is part of a trace.");
packet_header_type = bt_ctf_trace_get_packet_header_type(trace);
trace_valid = trace->valid;
assert(trace_valid);
* This means something went wrong during the validation
* process, not that the objects are invalid.
*/
- BT_LOGE("Failed to validate 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_class));
+ BT_LOGE("Failed to validate event and parents: ret=%d", ret);
goto error;
}
if ((validation_output.valid_flags & validation_flags) !=
validation_flags) {
/* Invalid trace/stream class/event class */
- BT_LOGE("Invalid trace, stream class, or event class: "
- "event-addr=%p, event-class-name=\"%s\", "
- "event-class-id=%" PRId64 ", valid-flags=0x%x",
- event, bt_ctf_event_class_get_name(event->event_class),
- bt_ctf_event_class_get_id(event_class),
- validation_output.valid_flags);
+ BT_LOGW("Invalid trace, stream class, or event class: "
+ "valid-flags=0x%x", validation_output.valid_flags);
goto error;
}
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) {
}
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) {
}
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) {
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;
}
}
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;
* Ensure the provided header's type matches the one registered to the
* stream class.
*/
- field_type = bt_ctf_field_get_type(header);
- if (bt_ctf_field_type_compare(field_type,
- stream_class->event_header_type)) {
- BT_LOGW("Invalid parameter: header field type is different from the expected field type: "
- "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));
- ret = -1;
- goto end;
+ if (header) {
+ field_type = bt_ctf_field_get_type(header);
+ if (bt_ctf_field_type_compare(field_type,
+ stream_class->event_header_type)) {
+ BT_LOGW("Invalid parameter: header field type is different from the expected field type: "
+ "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));
+ ret = -1;
+ goto end;
+ }
+ } else {
+ if (stream_class->event_header_type) {
+ BT_LOGW("Invalid parameter: setting no event header but event header field type is not NULL: "
+ "event-addr=%p, event-class-name=\"%s\", "
+ "event-class-id=%" PRId64 ", "
+ "event-header-ft-addr=%p",
+ event,
+ bt_ctf_event_class_get_name(event->event_class),
+ bt_ctf_event_class_get_id(event->event_class),
+ stream_class->event_header_type);
+ ret = -1;
+ goto end;
+ }
}
bt_put(event->event_header);
goto end;
}
- field_type = bt_ctf_field_get_type(context);
- if (bt_ctf_field_type_compare(field_type,
- event->event_class->context)) {
- BT_LOGW("Invalid parameter: context field type is different from the expected field type: "
- "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));
- ret = -1;
- goto end;
+ if (context) {
+ field_type = bt_ctf_field_get_type(context);
+
+ if (bt_ctf_field_type_compare(field_type,
+ event->event_class->context)) {
+ BT_LOGW("Invalid parameter: context field type is different from the expected field type: "
+ "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));
+ ret = -1;
+ goto end;
+ }
+ } else {
+ if (event->event_class->context) {
+ BT_LOGW("Invalid parameter: setting no event context but event context field type is not NULL: "
+ "event-addr=%p, event-class-name=\"%s\", "
+ "event-class-id=%" PRId64 ", "
+ "event-context-ft-addr=%p",
+ event,
+ bt_ctf_event_class_get_name(event->event_class),
+ bt_ctf_event_class_get_id(event->event_class),
+ event->event_class->context);
+ ret = -1;
+ goto end;
+ }
}
bt_put(event->context_payload);
*/
assert(stream_class);
- field_type = bt_ctf_field_get_type(stream_event_context);
- if (bt_ctf_field_type_compare(field_type,
- stream_class->event_context_type)) {
- BT_LOGW("Invalid parameter: stream event context field type is different from the expected field type: "
- "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));
- ret = -1;
- goto end;
+ if (stream_event_context) {
+ field_type = bt_ctf_field_get_type(stream_event_context);
+ if (bt_ctf_field_type_compare(field_type,
+ stream_class->event_context_type)) {
+ BT_LOGW("Invalid parameter: stream event context field type is different from the expected field type: "
+ "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));
+ ret = -1;
+ goto end;
+ }
+ } else {
+ if (stream_class->event_context_type) {
+ BT_LOGW("Invalid parameter: setting no stream event context but stream event context field type is not NULL: "
+ "event-addr=%p, event-class-name=\"%s\", "
+ "event-class-id=%" PRId64 ", "
+ "stream-event-context-ft-addr=%p",
+ event,
+ bt_ctf_event_class_get_name(event->event_class),
+ bt_ctf_event_class_get_id(event->event_class),
+ stream_class->event_context_type);
+ ret = -1;
+ goto end;
+ }
}
bt_get(stream_event_context);
bt_put(event->event_class);
}
g_hash_table_destroy(event->clock_values);
+ BT_LOGD_STR("Putting event's header field.");
bt_put(event->event_header);
+ BT_LOGD_STR("Putting event's stream event context field.");
bt_put(event->stream_event_context);
+ BT_LOGD_STR("Putting event's context field.");
bt_put(event->context_payload);
+ BT_LOGD_STR("Putting event's payload field.");
bt_put(event->fields_payload);
+ BT_LOGD_STR("Putting event's packet.");
bt_put(event->packet);
g_free(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);
assert(event);
assert(pos);
- BT_LOGD("Serializing event: "
- "event-addr=%p, event-class-name=\"%s\", "
- "event-class-id=%" PRId64 ", pos-addr=%p, "
- "native-bo=%s",
- event, bt_ctf_event_class_get_name(event->event_class),
- bt_ctf_event_class_get_id(event->event_class),
- pos, bt_ctf_field_type_byte_order_string(native_byte_order));
-
+ BT_LOGV_STR("Serializing event's context field.");
if (event->context_payload) {
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,
}
}
+ BT_LOGV_STR("Serializing event's payload field.");
if (event->fields_payload) {
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,
event, bt_ctf_event_class_get_name(event->event_class),
bt_ctf_event_class_get_id(event->event_class));
bt_ctf_packet_freeze(event->packet);
+ BT_LOGD_STR("Freezing event's header field.");
bt_ctf_field_freeze(event->event_header);
+ BT_LOGD_STR("Freezing event's stream event context field.");
bt_ctf_field_freeze(event->stream_event_context);
+ BT_LOGD_STR("Freezing event's context field.");
bt_ctf_field_freeze(event->context_payload);
+ BT_LOGD_STR("Freezing event's payload field.");
bt_ctf_field_freeze(event->fields_payload);
event->frozen = 1;
}