#define BT_LOG_TAG "PLUGIN-CTF-METADATA-META-RESOLVE"
#include "logging.h"
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/common-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/common-internal.h>
#include <glib.h>
#include <stdint.h>
#include <string.h>
} scopes;
/* Root scope being visited */
- enum bt_scope root_scope;
+ enum ctf_scope root_scope;
field_class_stack *field_class_stack;
struct ctf_field_class *cur_fc;
};
/* TSDL dynamic scope prefixes as defined in CTF Section 7.3.2 */
static const char * const absolute_path_prefixes[] = {
- [BT_SCOPE_PACKET_HEADER] = "trace.packet.header.",
- [BT_SCOPE_PACKET_CONTEXT] = "stream.packet.context.",
- [BT_SCOPE_EVENT_HEADER] = "stream.event.header.",
- [BT_SCOPE_EVENT_COMMON_CONTEXT] = "stream.event.context.",
- [BT_SCOPE_EVENT_SPECIFIC_CONTEXT] = "event.context.",
- [BT_SCOPE_EVENT_PAYLOAD] = "event.fields.",
+ [CTF_SCOPE_PACKET_HEADER] = "trace.packet.header.",
+ [CTF_SCOPE_PACKET_CONTEXT] = "stream.packet.context.",
+ [CTF_SCOPE_EVENT_HEADER] = "stream.event.header.",
+ [CTF_SCOPE_EVENT_COMMON_CONTEXT] = "stream.event.context.",
+ [CTF_SCOPE_EVENT_SPECIFIC_CONTEXT] = "event.context.",
+ [CTF_SCOPE_EVENT_PAYLOAD] = "event.fields.",
};
/* Number of path tokens used for the absolute prefixes */
static const uint64_t absolute_path_prefix_ptoken_counts[] = {
- [BT_SCOPE_PACKET_HEADER] = 3,
- [BT_SCOPE_PACKET_CONTEXT] = 3,
- [BT_SCOPE_EVENT_HEADER] = 3,
- [BT_SCOPE_EVENT_COMMON_CONTEXT] = 3,
- [BT_SCOPE_EVENT_SPECIFIC_CONTEXT] = 2,
- [BT_SCOPE_EVENT_PAYLOAD] = 2,
+ [CTF_SCOPE_PACKET_HEADER] = 3,
+ [CTF_SCOPE_PACKET_CONTEXT] = 3,
+ [CTF_SCOPE_EVENT_HEADER] = 3,
+ [CTF_SCOPE_EVENT_COMMON_CONTEXT] = 3,
+ [CTF_SCOPE_EVENT_SPECIFIC_CONTEXT] = 2,
+ [CTF_SCOPE_EVENT_PAYLOAD] = 2,
};
static
*/
static
struct ctf_field_class *borrow_class_from_ctx(struct resolve_context *ctx,
- enum bt_scope scope)
+ enum ctf_scope scope)
{
switch (scope) {
- case BT_SCOPE_PACKET_HEADER:
+ case CTF_SCOPE_PACKET_HEADER:
return ctx->scopes.packet_header;
- case BT_SCOPE_PACKET_CONTEXT:
+ case CTF_SCOPE_PACKET_CONTEXT:
return ctx->scopes.packet_context;
- case BT_SCOPE_EVENT_HEADER:
+ case CTF_SCOPE_EVENT_HEADER:
return ctx->scopes.event_header;
- case BT_SCOPE_EVENT_COMMON_CONTEXT:
+ case CTF_SCOPE_EVENT_COMMON_CONTEXT:
return ctx->scopes.event_common_context;
- case BT_SCOPE_EVENT_SPECIFIC_CONTEXT:
+ case CTF_SCOPE_EVENT_SPECIFIC_CONTEXT:
return ctx->scopes.event_spec_context;
- case BT_SCOPE_EVENT_PAYLOAD:
+ case CTF_SCOPE_EVENT_PAYLOAD:
return ctx->scopes.event_payload;
default:
abort();
* is found to be relative.
*/
static
-enum bt_scope get_root_scope_from_absolute_pathstr(const char *pathstr)
+enum ctf_scope get_root_scope_from_absolute_pathstr(const char *pathstr)
{
- enum bt_scope scope;
- enum bt_scope ret = -1;
+ enum ctf_scope scope;
+ enum ctf_scope ret = -1;
const size_t prefixes_count = sizeof(absolute_path_prefixes) /
sizeof(*absolute_path_prefixes);
- for (scope = BT_SCOPE_PACKET_HEADER; scope < BT_SCOPE_PACKET_HEADER +
+ for (scope = CTF_SCOPE_PACKET_HEADER; scope < CTF_SCOPE_PACKET_HEADER +
prefixes_count; scope++) {
/*
* Chech if path string starts with a known absolute
BT_LOGV("Prefix does not match: trying the next one: "
"path=\"%s\", path-prefix=\"%s\", scope=%s",
pathstr, absolute_path_prefixes[scope],
- bt_common_scope_string(scope));
+ ctf_scope_string(scope));
continue;
}
ret = scope;
BT_LOGV("Found root scope from absolute path: "
"path=\"%s\", scope=%s", pathstr,
- bt_common_scope_string(scope));
+ ctf_scope_string(scope));
goto end;
}
* object.
*/
switch (field_path->root) {
- case BT_SCOPE_PACKET_HEADER:
+ case CTF_SCOPE_PACKET_HEADER:
if (ctx->tc->is_translated) {
BT_LOGE("Trace class is already translated: "
"root-scope=%s",
- bt_common_scope_string(field_path->root));
+ ctf_scope_string(field_path->root));
ret = -1;
goto end;
}
break;
- case BT_SCOPE_PACKET_CONTEXT:
- case BT_SCOPE_EVENT_HEADER:
- case BT_SCOPE_EVENT_COMMON_CONTEXT:
+ case CTF_SCOPE_PACKET_CONTEXT:
+ case CTF_SCOPE_EVENT_HEADER:
+ case CTF_SCOPE_EVENT_COMMON_CONTEXT:
if (!ctx->sc) {
BT_LOGE("No current stream class: "
"root-scope=%s",
- bt_common_scope_string(field_path->root));
+ ctf_scope_string(field_path->root));
ret = -1;
goto end;
}
if (ctx->sc->is_translated) {
BT_LOGE("Stream class is already translated: "
"root-scope=%s",
- bt_common_scope_string(field_path->root));
+ ctf_scope_string(field_path->root));
ret = -1;
goto end;
}
break;
- case BT_SCOPE_EVENT_SPECIFIC_CONTEXT:
- case BT_SCOPE_EVENT_PAYLOAD:
+ case CTF_SCOPE_EVENT_SPECIFIC_CONTEXT:
+ case CTF_SCOPE_EVENT_PAYLOAD:
if (!ctx->ec) {
BT_LOGE("No current event class: "
"root-scope=%s",
- bt_common_scope_string(field_path->root));
+ ctf_scope_string(field_path->root));
ret = -1;
goto end;
}
if (ctx->ec->is_translated) {
BT_LOGE("Event class is already translated: "
"root-scope=%s",
- bt_common_scope_string(field_path->root));
+ ctf_scope_string(field_path->root));
ret = -1;
goto end;
}
/* Error: root class is not available */
BT_LOGE("Root field class is not available: "
"root-scope=%s",
- bt_common_scope_string(field_path->root));
+ ctf_scope_string(field_path->root));
ret = -1;
goto end;
}
struct ctf_field_path *field_path, struct resolve_context *ctx)
{
int ret = 0;
- enum bt_scope root_scope;
+ enum ctf_scope root_scope;
GList *ptokens = NULL;
/* Convert path string to path tokens */
/* 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_common_scope_string(field_path->root));
+ "scope=%s", ctf_scope_string(field_path->root));
ret = relative_ptokens_to_field_path(ptokens, field_path, ctx);
if (ret) {
BT_LOGE("Cannot get relative field path of path string: "
"path=\"%s\", start-scope=%s, end-scope=%s",
- pathstr, bt_common_scope_string(ctx->root_scope),
- bt_common_scope_string(field_path->root));
+ pathstr, ctf_scope_string(ctx->root_scope),
+ ctf_scope_string(field_path->root));
goto end;
}
} else {
/* Absolute path: use found root scope */
field_path->root = root_scope;
BT_LOGV("Detected absolute path: using root scope: "
- "scope=%s", bt_common_scope_string(field_path->root));
+ "scope=%s", ctf_scope_string(field_path->root));
ret = absolute_ptokens_to_field_path(ptokens, field_path, ctx);
if (ret) {
BT_LOGE("Cannot get absolute field path of path string: "
"path=\"%s\", root-scope=%s",
- pathstr, bt_common_scope_string(root_scope));
+ pathstr, ctf_scope_string(root_scope));
goto end;
}
}
if (!fc) {
/* Error: root class is not available */
BT_LOGE("Root field class is not available: root-scope=%s",
- bt_common_scope_string(field_path->root));
+ ctf_scope_string(field_path->root));
goto end;
}
if (target_field_path->root > ctx_field_path.root) {
BT_LOGE("Target field class is located after source field class: "
"target-root=%s, source-root=%s",
- bt_common_scope_string(target_field_path->root),
- bt_common_scope_string(ctx_field_path.root));
+ ctf_scope_string(target_field_path->root),
+ ctf_scope_string(ctx_field_path.root));
ret = -1;
goto end;
}
* Resolves the root field class corresponding to the scope `root_scope`.
*/
static
-int resolve_root_class(enum bt_scope root_scope, struct resolve_context *ctx)
+int resolve_root_class(enum ctf_scope root_scope, struct resolve_context *ctx)
{
int ret;
ctx->ec = ec;
ctx->scopes.event_spec_context = ec->spec_context_fc;
- ret = resolve_root_class(BT_SCOPE_EVENT_COMMON_CONTEXT, ctx);
+ ret = resolve_root_class(CTF_SCOPE_EVENT_COMMON_CONTEXT, ctx);
if (ret) {
BT_LOGE("Cannot resolve event specific context field class: "
"ret=%d", ret);
}
ctx->scopes.event_payload = ec->payload_fc;
- ret = resolve_root_class(BT_SCOPE_EVENT_PAYLOAD, ctx);
+ ret = resolve_root_class(CTF_SCOPE_EVENT_PAYLOAD, ctx);
if (ret) {
BT_LOGE("Cannot resolve event payload field class: "
"ret=%d", ret);
if (!sc->is_translated) {
ctx->scopes.packet_context = sc->packet_context_fc;
- ret = resolve_root_class(BT_SCOPE_PACKET_CONTEXT, ctx);
+ ret = resolve_root_class(CTF_SCOPE_PACKET_CONTEXT, ctx);
if (ret) {
BT_LOGE("Cannot resolve packet context field class: "
"ret=%d", ret);
}
ctx->scopes.event_header = sc->event_header_fc;
- ret = resolve_root_class(BT_SCOPE_EVENT_HEADER, ctx);
+ ret = resolve_root_class(CTF_SCOPE_EVENT_HEADER, ctx);
if (ret) {
BT_LOGE("Cannot resolve event header field class: "
"ret=%d", ret);
}
ctx->scopes.event_common_context = sc->event_common_context_fc;
- ret = resolve_root_class(BT_SCOPE_EVENT_SPECIFIC_CONTEXT, ctx);
+ ret = resolve_root_class(CTF_SCOPE_EVENT_SPECIFIC_CONTEXT, ctx);
if (ret) {
BT_LOGE("Cannot resolve event common context field class: "
"ret=%d", ret);
.event_spec_context = NULL,
.event_payload = NULL,
},
- .root_scope = BT_SCOPE_PACKET_HEADER,
+ .root_scope = CTF_SCOPE_PACKET_HEADER,
.cur_fc = NULL,
};
if (!tc->is_translated) {
ctx.scopes.packet_header = tc->packet_header_fc;
- ret = resolve_root_class(BT_SCOPE_PACKET_HEADER, &ctx);
+ ret = resolve_root_class(CTF_SCOPE_PACKET_HEADER, &ctx);
if (ret) {
BT_LOGE("Cannot resolve packet header field class: "
"ret=%d", ret);