__thread int bt_ctf_last_field_error = 0;
const struct bt_definition *bt_ctf_get_top_level_scope(const struct bt_ctf_event *ctf_event,
- enum bt_ctf_scope scope)
+ enum ctf_scope scope)
{
const struct bt_definition *tmp = NULL;
const struct ctf_event_definition *event;
goto error;
if (def_sequence->elems->pdata) {
*list = (struct bt_definition const* const*) def_sequence->elems->pdata;
- *count = def_sequence->elems->len;
+ *count = (unsigned int) def_sequence->length->value._unsigned;
goto end;
} else {
goto error;
return ret;
}
-uint64_t bt_ctf_get_timestamp(const struct bt_ctf_event *ctf_event)
+int bt_ctf_get_timestamp(const struct bt_ctf_event *ctf_event, int64_t *timestamp)
{
const struct ctf_event_definition *event;
- if (!ctf_event)
- return -1ULL;
+ if (!ctf_event || !timestamp)
+ return -1;
event = ctf_event->parent;
if (event && event->stream->has_timestamp)
- return event->stream->real_timestamp;
+ *timestamp = event->stream->real_timestamp;
else
- return -1ULL;
+ return -1;
+ return 0;
}
uint64_t bt_ctf_get_cycles(const struct bt_ctf_event *ctf_event)
g_array_unref(array);
bt_ctf_field_set_error(-ENOENT);
return NULL;
- }
+ }
/* Return first string. Arbitrary choice. */
ret = g_quark_to_string(g_array_index(array, GQuark, 0));
g_array_unref(array);
return ret;
}
+const struct bt_definition *bt_ctf_get_variant(const struct bt_definition *field)
+{
+ const struct bt_definition *ret = NULL;
+
+ if (field && bt_ctf_field_type(
+ bt_ctf_get_decl_from_def(field)) == CTF_TYPE_VARIANT) {
+ struct definition_variant *variant = container_of(field,
+ struct definition_variant, p);
+
+ ret = bt_variant_get_current_field(variant);
+ } else {
+ bt_ctf_field_set_error(-EINVAL);
+ }
+
+ return ret;
+}
+
+uint64_t bt_ctf_get_struct_field_count(const struct bt_definition *field)
+{
+ uint64_t ret = -1;
+ const struct bt_declaration *declaration =
+ bt_ctf_get_decl_from_def(field);
+
+ if (field && bt_ctf_field_type(declaration) == CTF_TYPE_STRUCT) {
+ const struct declaration_struct *struct_declaration =
+ container_of(declaration, struct declaration_struct, p);
+
+ ret = bt_struct_declaration_len(struct_declaration);
+ } else {
+ bt_ctf_field_set_error(-EINVAL);
+ }
+
+ return ret;
+}
+
+const struct bt_definition *bt_ctf_get_struct_field_index(
+ const struct bt_definition *field, uint64_t i)
+{
+ const struct bt_definition *ret = NULL;
+
+ if (field && bt_ctf_field_type(
+ bt_ctf_get_decl_from_def(field)) == CTF_TYPE_STRUCT &&
+ i < bt_ctf_get_struct_field_count(field)) {
+ const struct definition_struct *structure = container_of(
+ field, struct definition_struct, p);
+
+ ret = bt_struct_definition_get_field_from_index(structure, i);
+ }
+
+ if (!ret) {
+ bt_ctf_field_set_error(-EINVAL);
+ }
+
+ return ret;
+}
+
int bt_ctf_get_event_decl_list(int handle_id, struct bt_context *ctx,
struct bt_ctf_event_decl * const **list,
unsigned int *count)
goto error;
handle = g_hash_table_lookup(ctx->trace_handles,
- (gpointer) (unsigned long) handle_id);
+ GUINT_TO_POINTER(handle_id));
if (!handle)
goto error;
return g_quark_to_string(event->parent.name);
}
+uint64_t bt_ctf_get_decl_event_id(const struct bt_ctf_event_decl *event)
+{
+ if (!event)
+ return (uint64_t)(-1);
+
+ return event->parent.id;
+}
+
int bt_ctf_get_decl_fields(struct bt_ctf_event_decl *event_decl,
- enum bt_ctf_scope scope,
+ enum ctf_scope scope,
struct bt_ctf_field_decl const * const **list,
unsigned int *count)
{