X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fplugins%2Fctf%2Fcommon%2Fmetadata%2Fvisitor-generate-ir.c;h=22379aa9d4ee3cc1f4a2cb232684bdd5f51a5f59;hb=c0aa240b810498f8c168a97f9128407988d7ed9e;hp=7bad52667964e2a8c16355b69673c39137c4136d;hpb=9d2c9974426abd3f8d179cc1992558399219c93a;p=babeltrace.git diff --git a/src/plugins/ctf/common/metadata/visitor-generate-ir.c b/src/plugins/ctf/common/metadata/visitor-generate-ir.c index 7bad5266..22379aa9 100644 --- a/src/plugins/ctf/common/metadata/visitor-generate-ir.c +++ b/src/plugins/ctf/common/metadata/visitor-generate-ir.c @@ -698,59 +698,6 @@ int is_unary_string(struct bt_list_head *head) return ret; } -static -char *concatenate_unary_strings(struct bt_list_head *head) -{ - int i = 0; - GString *str; - struct ctf_node *node; - - str = g_string_new(NULL); - BT_ASSERT(str); - - bt_list_for_each_entry(node, head, siblings) { - char *src_string; - - if ( - node->type != NODE_UNARY_EXPRESSION || - node->u.unary_expression.type != UNARY_STRING || - !( - ( - node->u.unary_expression.link != - UNARY_LINK_UNKNOWN - ) ^ (i == 0) - ) - ) { - goto error; - } - - switch (node->u.unary_expression.link) { - case UNARY_DOTLINK: - g_string_append(str, "."); - break; - case UNARY_ARROWLINK: - g_string_append(str, "->"); - break; - case UNARY_DOTDOTDOT: - g_string_append(str, "..."); - break; - default: - break; - } - - src_string = node->u.unary_expression.u.string; - g_string_append(str, src_string); - i++; - } - - /* Destroys the container, returns the underlying string */ - return g_string_free(str, FALSE); - -error: - /* This always returns NULL */ - return g_string_free(str, TRUE); -} - static const char *get_map_clock_name_value(struct bt_list_head *head) { @@ -922,38 +869,11 @@ end: return ret; } -static int get_unary_uuid(struct ctx *ctx, struct bt_list_head *head, - uint8_t *uuid) + bt_uuid_t uuid) { - int i = 0; - int ret = 0; - struct ctf_node *node; - - bt_list_for_each_entry(node, head, siblings) { - int uexpr_type = node->u.unary_expression.type; - int uexpr_link = node->u.unary_expression.link; - const char *src_string; - - if (node->type != NODE_UNARY_EXPRESSION || - uexpr_type != UNARY_STRING || - uexpr_link != UNARY_LINK_UNKNOWN || - i != 0) { - ret = -EINVAL; - goto end; - } - - src_string = node->u.unary_expression.u.string; - ret = bt_uuid_from_str(src_string, uuid); - if (ret) { - _BT_COMP_LOGE_NODE(node, - "Cannot parse UUID: uuid=\"%s\"", src_string); - goto end; - } - } - -end: - return ret; + return ctf_ast_get_unary_uuid(head, uuid, ctx->log_cfg.log_level, + ctx->log_cfg.self_comp); } static @@ -1381,7 +1301,7 @@ int visit_field_class_declarator(struct ctx *ctx, { /* Lookup unsigned integer definition, create seq. */ struct ctf_field_class_sequence *seq_decl = NULL; - char *length_name = concatenate_unary_strings(length); + char *length_name = ctf_ast_concatenate_unary_strings(length); if (!length_name) { _BT_COMP_LOGE_NODE(node_field_class_declarator, @@ -2445,7 +2365,7 @@ int visit_integer_decl(struct ctx *ctx, } case UNARY_STRING: { - char *s_right = concatenate_unary_strings( + char *s_right = ctf_ast_concatenate_unary_strings( &expression->u.ctf_expression.right); if (!s_right) { _BT_COMP_LOGE_NODE(right, @@ -2512,7 +2432,7 @@ int visit_integer_decl(struct ctx *ctx, goto error; } - s_right = concatenate_unary_strings( + s_right = ctf_ast_concatenate_unary_strings( &expression->u.ctf_expression.right); if (!s_right) { _BT_COMP_LOGE_NODE(right, @@ -2564,7 +2484,7 @@ int visit_integer_decl(struct ctx *ctx, get_map_clock_name_value( &expression->u.ctf_expression.right); if (!clock_name) { - char *s_right = concatenate_unary_strings( + char *s_right = ctf_ast_concatenate_unary_strings( &expression->u.ctf_expression.right); if (!s_right) { @@ -2868,7 +2788,7 @@ int visit_string_decl(struct ctx *ctx, goto error; } - s_right = concatenate_unary_strings( + s_right = ctf_ast_concatenate_unary_strings( &expression->u.ctf_expression.right); if (!s_right) { _BT_COMP_LOGE_NODE(right, @@ -3068,7 +2988,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, break; case NODE_CTF_EXPRESSION: { - left = concatenate_unary_strings(&node->u.ctf_expression.left); + left = ctf_ast_concatenate_unary_strings(&node->u.ctf_expression.left); if (!left) { _BT_COMP_LOGE_NODE(node, "Cannot concatenate unary strings."); ret = -EINVAL; @@ -3259,7 +3179,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, goto error; } - right = concatenate_unary_strings( + right = ctf_ast_concatenate_unary_strings( &node->u.ctf_expression.right); if (!right) { _BT_COMP_LOGE_NODE(node, @@ -3315,7 +3235,7 @@ char *get_event_decl_name(struct ctx *ctx, struct ctf_node *node) continue; } - left = concatenate_unary_strings(&iter->u.ctf_expression.left); + left = ctf_ast_concatenate_unary_strings(&iter->u.ctf_expression.left); if (!left) { _BT_COMP_LOGE_NODE(iter, "Cannot concatenate unary strings."); @@ -3323,7 +3243,7 @@ char *get_event_decl_name(struct ctx *ctx, struct ctf_node *node) } if (strcmp(left, "name") == 0) { - name = concatenate_unary_strings( + name = ctf_ast_concatenate_unary_strings( &iter->u.ctf_expression.right); if (!name) { _BT_COMP_LOGE_NODE(iter, @@ -3628,7 +3548,7 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, break; case NODE_CTF_EXPRESSION: { - left = concatenate_unary_strings(&node->u.ctf_expression.left); + left = ctf_ast_concatenate_unary_strings(&node->u.ctf_expression.left); if (!left) { _BT_COMP_LOGE_NODE(node, "Cannot concatenate unary strings."); ret = -EINVAL; @@ -3904,7 +3824,7 @@ int visit_trace_decl_entry(struct ctx *ctx, struct ctf_node *node, int *set) break; case NODE_CTF_EXPRESSION: { - left = concatenate_unary_strings(&node->u.ctf_expression.left); + left = ctf_ast_concatenate_unary_strings(&node->u.ctf_expression.left); if (!left) { _BT_COMP_LOGE_NODE(node, "Cannot concatenate unary strings."); ret = -EINVAL; @@ -4122,7 +4042,7 @@ int visit_env(struct ctx *ctx, struct ctf_node *node) goto error; } - left = concatenate_unary_strings( + left = ctf_ast_concatenate_unary_strings( &entry_node->u.ctf_expression.left); if (!left) { _BT_COMP_LOGE_NODE(entry_node, @@ -4132,7 +4052,7 @@ int visit_env(struct ctx *ctx, struct ctf_node *node) } if (is_unary_string(right_head)) { - char *right = concatenate_unary_strings(right_head); + char *right = ctf_ast_concatenate_unary_strings(right_head); if (!right) { _BT_COMP_LOGE_NODE(entry_node, @@ -4207,7 +4127,7 @@ int set_trace_byte_order(struct ctx *ctx, struct ctf_node *trace_node) if (node->type == NODE_CTF_EXPRESSION) { struct ctf_node *right_node; - left = concatenate_unary_strings( + left = ctf_ast_concatenate_unary_strings( &node->u.ctf_expression.left); if (!left) { _BT_COMP_LOGE_NODE(node, @@ -4284,7 +4204,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, goto error; } - left = concatenate_unary_strings(&entry_node->u.ctf_expression.left); + left = ctf_ast_concatenate_unary_strings(&entry_node->u.ctf_expression.left); if (!left) { _BT_COMP_LOGE_NODE(entry_node, "Cannot concatenate unary strings."); ret = -EINVAL; @@ -4300,7 +4220,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, goto error; } - right = concatenate_unary_strings( + right = ctf_ast_concatenate_unary_strings( &entry_node->u.ctf_expression.right); if (!right) { _BT_COMP_LOGE_NODE(entry_node, @@ -4342,7 +4262,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node, goto error; } - right = concatenate_unary_strings( + right = ctf_ast_concatenate_unary_strings( &entry_node->u.ctf_expression.right); if (!right) { _BT_COMP_LOGE_NODE(entry_node, @@ -4503,6 +4423,17 @@ void calibrate_clock_class_offsets(int64_t *offset_seconds, } } +static +void apply_clock_class_is_absolute(struct ctx *ctx, + struct ctf_clock_class *clock) +{ + if (ctx->decoder_config.force_clock_class_origin_unix_epoch) { + clock->is_absolute = true; + } + + return; +} + static void apply_clock_class_offset(struct ctx *ctx, struct ctf_clock_class *clock) @@ -4630,6 +4561,7 @@ int visit_clock_decl(struct ctx *ctx, struct ctf_node *clock_node) clock->offset_seconds = offset_seconds; clock->offset_cycles = offset_cycles; apply_clock_class_offset(ctx, clock); + apply_clock_class_is_absolute(ctx, clock); g_ptr_array_add(ctx->ctf_tc->clock_classes, clock); clock = NULL;