#define BT_LOG_TAG "RESOLVE"
#include <babeltrace/lib-logging-internal.h>
-#include <babeltrace/ctf-ir/event.h>
#include <babeltrace/ctf-ir/stream-class.h>
#include <babeltrace/ctf-ir/resolve-internal.h>
#include <babeltrace/ctf-ir/field-types.h>
#include <babeltrace/ctf-ir/field-path.h>
#include <babeltrace/ctf-ir/field-path-internal.h>
-#include <babeltrace/ctf-ir/event-internal.h>
#include <babeltrace/ref.h>
#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/values.h>
#include <babeltrace/types.h>
+#include <babeltrace/assert-internal.h>
#include <limits.h>
#include <inttypes.h>
#include <stdlib.h>
/* TSDL dynamic scope prefixes as defined in CTF Section 7.3.2 */
static const char * const absolute_path_prefixes[] = {
- [BT_SCOPE_ENV] = "env.",
- [BT_SCOPE_TRACE_PACKET_HEADER] = "trace.packet.header.",
+ [BT_SCOPE_ENV] = "env.",
+ [BT_SCOPE_TRACE_PACKET_HEADER] = "trace.packet.header.",
[BT_SCOPE_STREAM_PACKET_CONTEXT] = "stream.packet.context.",
- [BT_SCOPE_STREAM_EVENT_HEADER] = "stream.event.header.",
- [BT_SCOPE_STREAM_EVENT_CONTEXT] = "stream.event.context.",
+ [BT_SCOPE_STREAM_EVENT_HEADER] = "stream.event.header.",
+ [BT_SCOPE_STREAM_EVENT_CONTEXT] = "stream.event.context.",
[BT_SCOPE_EVENT_CONTEXT] = "event.context.",
- [BT_SCOPE_EVENT_FIELDS] = "event.fields.",
+ [BT_SCOPE_EVENT_FIELDS] = "event.fields.",
};
/* Number of path tokens used for the absolute prefixes */
struct bt_field_type *get_type_from_ctx(struct resolve_context *ctx,
enum bt_scope scope)
{
- assert(scope >= BT_SCOPE_TRACE_PACKET_HEADER &&
+ BT_ASSERT(scope >= BT_SCOPE_TRACE_PACKET_HEADER &&
scope <= BT_SCOPE_EVENT_FIELDS);
return ctx->scopes[scope - BT_SCOPE_TRACE_PACKET_HEADER];
BT_LOGV("Prefix does not match: trying the next one: "
"path=\"%s\", path-prefix=\"%s\", scope=%s",
pathstr, absolute_path_prefixes[scope],
- bt_scope_string(scope));
+ bt_common_scope_string(scope));
continue;
}
ret = scope;
BT_LOGV("Found root scope from absolute path: "
"path=\"%s\", scope=%s", pathstr,
- bt_scope_string(scope));
+ bt_common_scope_string(scope));
goto end;
}
g_array_append_val(field_path->indexes, child_index);
/* Get child field type */
- child_type = bt_field_type_get_field_at_index(type,
+ child_type = bt_field_type_borrow_field_at_index(type,
child_index);
if (!child_type) {
BT_LOGW("Cannot get child field type: "
}
/* Move child type to current type */
+ bt_get(child_type);
BT_MOVE(type, child_type);
}
/* Error: root type is not available */
BT_LOGW("Root field type is not available: "
"root-scope=%s",
- bt_scope_string(field_path->root));
+ bt_common_scope_string(field_path->root));
ret = -1;
goto end;
}
bt_field_path_clear(field_path);
BT_LOGV("Looking into potential root scope: scope=%s",
- bt_scope_string(field_path->root));
+ bt_common_scope_string(field_path->root));
root_type = get_type_from_ctx(ctx, field_path->root);
if (!root_type) {
field_path->root--;
/* Relative path: start with current root scope */
field_path->root = ctx->root_scope;
BT_LOGV("Detected relative path: starting with current root scope: "
- "scope=%s", bt_scope_string(field_path->root));
+ "scope=%s", bt_common_scope_string(field_path->root));
ret = relative_ptokens_to_field_path(ptokens, field_path, ctx);
if (ret) {
BT_LOGW("Cannot get relative field path of path string: "
"path=\"%s\", start-scope=%s, end-scope=%s",
- pathstr, bt_scope_string(ctx->root_scope),
- bt_scope_string(field_path->root));
+ pathstr, bt_common_scope_string(ctx->root_scope),
+ bt_common_scope_string(field_path->root));
goto end;
}
} else if (root_scope == BT_SCOPE_ENV) {
/* Absolute path: use found root scope */
field_path->root = root_scope;
BT_LOGV("Detected absolute path: using root scope: "
- "scope=%s", bt_scope_string(field_path->root));
+ "scope=%s", bt_common_scope_string(field_path->root));
ret = absolute_ptokens_to_field_path(ptokens, field_path, ctx);
if (ret) {
BT_LOGW("Cannot get absolute field path of path string: "
"path=\"%s\", root-scope=%s",
- pathstr, bt_scope_string(root_scope));
+ pathstr, bt_common_scope_string(root_scope));
goto end;
}
}
if (!type) {
/* Error: root type is not available */
BT_LOGW("Root field type is not available: root-scope=%s",
- bt_scope_string(field_path->root));
+ bt_common_scope_string(field_path->root));
goto error;
}
g_array_index(field_path->indexes, int, i);
/* Get child field type */
- child_type = bt_field_type_get_field_at_index(type,
+ child_type = bt_field_type_borrow_field_at_index(type,
child_index);
if (!child_type) {
BT_LOGW("Cannot get field type: "
}
/* Move child type to current type */
+ bt_get(child_type);
BT_MOVE(type, child_type);
}
/*
* Start from both roots and find the first mismatch.
*/
- assert(field_path1->root == field_path2->root);
+ BT_ASSERT(field_path1->root == field_path2->root);
field_path1_len = field_path1->indexes->len;
field_path2_len = field_path2->indexes->len;
if (target_field_path->root > ctx_field_path->root) {
BT_LOGW("Target field type is located after source field type: "
"target-root=%s, source-root=%s",
- bt_scope_string(target_field_path->root),
- bt_scope_string(ctx_field_path->root));
+ bt_common_scope_string(target_field_path->root),
+ bt_common_scope_string(ctx_field_path->root));
ret = -1;
goto end;
}
BT_LOGW("Variant field type's tag field type is not an enumeration field type: "
"tag-ft-addr=%p, tag-ft-id=%s",
target_type,
- bt_field_type_id_string(target_type_id));
+ bt_common_field_type_id_string(target_type_id));
ret = -1;
goto end;
}
BT_LOGW("Sequence field type's length field type is not an unsigned integer field type: "
"length-ft-addr=%p, length-ft-id=%s",
target_type,
- bt_field_type_id_string(target_type_id));
+ bt_common_field_type_id_string(target_type_id));
ret = -1;
goto end;
}
for (f_index = 0; f_index < field_count; f_index++) {
struct bt_field_type *child_type =
- bt_field_type_get_field_at_index(type,
+ bt_field_type_borrow_field_at_index(type,
f_index);
if (!child_type) {
"index=%" PRId64 ", count=%" PRId64,
type, child_type, f_index, field_count);
ret = resolve_type(child_type, ctx);
- BT_PUT(child_type);
if (ret) {
goto end;
}
{
int ret;
- assert(type_stack_size(ctx->type_stack) == 0);
+ BT_ASSERT(type_stack_size(ctx->type_stack) == 0);
ctx->root_scope = root_scope;
ret = resolve_type(get_type_from_ctx(ctx, root_scope), ctx);
ctx->root_scope = BT_SCOPE_UNKNOWN;