*/
__thread int bt_ctf_last_field_error = 0;
-const struct definition *bt_ctf_get_top_level_scope(const struct bt_ctf_event *event,
+const struct definition *bt_ctf_get_top_level_scope(const struct bt_ctf_event *ctf_event,
enum bt_ctf_scope scope)
{
struct definition *tmp = NULL;
+ struct ctf_event_definition *event = ctf_event->parent;
switch (scope) {
case BT_TRACE_PACKET_HEADER:
tmp = &event->stream->stream_event_context->p;
break;
case BT_EVENT_CONTEXT:
- if (!event->event)
- goto error;
- if (event->event->event_context)
- tmp = &event->event->event_context->p;
+ if (event->event_context)
+ tmp = &event->event_context->p;
break;
case BT_EVENT_FIELDS:
- if (!event->event)
- goto error;
- if (event->event->event_fields)
- tmp = &event->event->event_fields->p;
+ if (event->event_fields)
+ tmp = &event->event_fields->p;
break;
}
return tmp;
return NULL;
}
-const struct definition *bt_ctf_get_field(const struct bt_ctf_event *event,
+const struct definition *bt_ctf_get_field(const struct bt_ctf_event *ctf_event,
const struct definition *scope,
const char *field)
{
return NULL;
}
-const struct definition *bt_ctf_get_index(const struct bt_ctf_event *event,
+const struct definition *bt_ctf_get_index(const struct bt_ctf_event *ctf_event,
const struct definition *field,
unsigned int index)
{
return ret;
}
-const char *bt_ctf_event_name(const struct bt_ctf_event *event)
+const char *bt_ctf_event_name(const struct bt_ctf_event *ctf_event)
{
- struct ctf_event *event_class;
- struct ctf_stream_class *stream_class;
+ struct ctf_event_declaration *event_class;
+ struct ctf_stream_declaration *stream_class;
+ struct ctf_event_definition *event = ctf_event->parent;
if (!event)
return NULL;
return CTF_TYPE_UNKNOWN;
}
-int bt_ctf_get_field_list(const struct bt_ctf_event *event,
+int bt_ctf_get_field_list(const struct bt_ctf_event *ctf_event,
const struct definition *scope,
struct definition const * const **list,
unsigned int *count)
return -1;
}
-uint64_t bt_ctf_get_timestamp_raw(const struct bt_ctf_event *event)
+struct bt_context *bt_ctf_event_get_context(const struct bt_ctf_event *ctf_event)
{
+ struct bt_context *ret = NULL;
+ struct ctf_file_stream *cfs;
+ struct ctf_trace *trace;
+ struct ctf_event_definition *event = ctf_event->parent;
+
+ cfs = container_of(event->stream, struct ctf_file_stream,
+ parent);
+ trace = cfs->parent.stream_class->trace;
+ if (trace->ctx)
+ ret = trace->ctx;
+
+ return ret;
+}
+
+int bt_ctf_event_get_handle_id(const struct bt_ctf_event *ctf_event)
+{
+ int ret = -1;
+ struct ctf_file_stream *cfs;
+ struct ctf_trace *trace;
+ struct ctf_event_definition *event = ctf_event->parent;
+
+ cfs = container_of(event->stream, struct ctf_file_stream,
+ parent);
+ trace = cfs->parent.stream_class->trace;
+ if (trace->handle)
+ ret = trace->handle->id;
+
+ return ret;
+}
+
+uint64_t bt_ctf_get_timestamp_raw(const struct bt_ctf_event *ctf_event)
+{
+ struct ctf_event_definition *event = ctf_event->parent;
if (event && event->stream->has_timestamp)
return ctf_get_timestamp_raw(event->stream,
event->stream->timestamp);
return -1ULL;
}
-uint64_t bt_ctf_get_timestamp(const struct bt_ctf_event *event)
+uint64_t bt_ctf_get_timestamp(const struct bt_ctf_event *ctf_event)
{
+ struct ctf_event_definition *event = ctf_event->parent;
if (event && event->stream->has_timestamp)
return ctf_get_timestamp(event->stream,
event->stream->timestamp);
return ret;
}
+
+int bt_ctf_get_event_decl_list(int handle_id, struct bt_context *ctx,
+ struct bt_ctf_event_decl const * const **list,
+ unsigned int *count)
+{
+ struct bt_trace_handle *handle;
+ struct trace_descriptor *td;
+ struct ctf_trace *tin;
+
+ if (!ctx)
+ goto error;
+
+ handle = g_hash_table_lookup(ctx->trace_handles,
+ (gpointer) (unsigned long) handle_id);
+ if (!handle)
+ goto error;
+
+ td = handle->td;
+ tin = container_of(td, struct ctf_trace, parent);
+
+ *list = (struct bt_ctf_event_decl const* const*) tin->event_declarations->pdata;
+ *count = tin->event_declarations->len;
+ return 0;
+
+error:
+ return -1;
+}
+
+const char *bt_ctf_get_decl_event_name(const struct bt_ctf_event_decl *event)
+{
+ if (!event)
+ return NULL;
+ return g_quark_to_string(event->parent.name);
+}