X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=formats%2Fctf%2Fmetadata%2Fctf-visitor-generate-io-struct.c;h=ea8148b257953320431154df55d82bf80eb718f9;hp=52e0cf3f9140a6bcf44b405fc4a461f2ad76ecfa;hb=32cfb8adf760170061946d1f802677fb02f6dc96;hpb=4716614abaa127d6d6722c845a413495d9cb2b6f diff --git a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c index 52e0cf3f..ea8148b2 100644 --- a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c +++ b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "ctf-scanner.h" #include "ctf-parser.h" #include "ctf-ast.h" @@ -39,6 +40,13 @@ #define _bt_list_first_entry(ptr, type, member) \ bt_list_entry((ptr)->next, type, member) +struct last_enum_value { + union { + int64_t s; + uint64_t u; + } u; +}; + int opt_clock_force_correlate; static @@ -932,7 +940,8 @@ error: static int ctf_enumerator_list_visit(FILE *fd, int depth, struct ctf_node *enumerator, - struct declaration_enum *enum_declaration) + struct declaration_enum *enum_declaration, + struct last_enum_value *last) { GQuark q; struct ctf_node *iter; @@ -968,8 +977,11 @@ int ctf_enumerator_list_visit(FILE *fd, int depth, } nr_vals++; } - if (nr_vals == 1) + if (nr_vals == 0) + start = last->u.s; + if (nr_vals <= 1) end = start; + last->u.s = end + 1; enum_signed_insert(enum_declaration, start, end, q); } else { uint64_t start, end; @@ -1005,8 +1017,11 @@ int ctf_enumerator_list_visit(FILE *fd, int depth, } nr_vals++; } - if (nr_vals == 1) + if (nr_vals == 0) + start = last->u.u; + if (nr_vals <= 1) end = start; + last->u.u = end + 1; enum_unsigned_insert(enum_declaration, start, end, q); } return 0; @@ -1024,6 +1039,7 @@ struct declaration *ctf_declaration_enum_visit(FILE *fd, int depth, struct declaration *declaration; struct declaration_enum *enum_declaration; struct declaration_integer *integer_declaration; + struct last_enum_value last_value; struct ctf_node *iter; GQuark dummy_id; int ret; @@ -1075,8 +1091,14 @@ struct declaration *ctf_declaration_enum_visit(FILE *fd, int depth, integer_declaration = container_of(declaration, struct declaration_integer, p); enum_declaration = enum_declaration_new(integer_declaration); declaration_unref(&integer_declaration->p); /* leave ref to enum */ + if (enum_declaration->integer_declaration->signedness) { + last_value.u.s = 0; + } else { + last_value.u.u = 0; + } bt_list_for_each_entry(iter, enumerator_list, siblings) { - ret = ctf_enumerator_list_visit(fd, depth + 1, iter, enum_declaration); + ret = ctf_enumerator_list_visit(fd, depth + 1, iter, enum_declaration, + &last_value); if (ret) goto error; } @@ -1742,8 +1764,10 @@ int ctf_event_visit(FILE *fd, int depth, struct ctf_node *node, int ret = 0; struct ctf_node *iter; struct ctf_event_declaration *event; + struct bt_ctf_event_decl *event_decl; - event = g_new0(struct ctf_event_declaration, 1); + event_decl = g_new0(struct bt_ctf_event_decl, 1); + event = &event_decl->parent; event->declaration_scope = new_declaration_scope(parent_declaration_scope); event->loglevel = -1; bt_list_for_each_entry(iter, &node->u.event.declaration_list, siblings) { @@ -1787,6 +1811,7 @@ int ctf_event_visit(FILE *fd, int depth, struct ctf_node *node, g_hash_table_insert(event->stream->event_quark_to_id, (gpointer) (unsigned long) event->name, &event->id); + g_ptr_array_add(trace->event_declarations, event_decl); return 0; error: @@ -1795,7 +1820,7 @@ error: if (event->context_decl) declaration_unref(&event->context_decl->p); free_declaration_scope(event->declaration_scope); - g_free(event); + g_free(event_decl); return ret; } @@ -2128,6 +2153,7 @@ int ctf_trace_visit(FILE *fd, int depth, struct ctf_node *node, struct ctf_trace return -EEXIST; trace->declaration_scope = new_declaration_scope(trace->root_declaration_scope); trace->streams = g_ptr_array_new(); + trace->event_declarations = g_ptr_array_new(); bt_list_for_each_entry(iter, &node->u.trace.declaration_list, siblings) { ret = ctf_trace_declaration_visit(fd, depth + 1, iter, trace); if (ret) @@ -2143,11 +2169,6 @@ int ctf_trace_visit(FILE *fd, int depth, struct ctf_node *node, struct ctf_trace fprintf(fd, "[error] %s: missing minor field in trace declaration\n", __func__); goto error; } - if (!CTF_TRACE_FIELD_IS_SET(trace, uuid)) { - ret = -EPERM; - fprintf(fd, "[error] %s: missing uuid field in trace declaration\n", __func__); - goto error; - } if (!CTF_TRACE_FIELD_IS_SET(trace, byte_order)) { ret = -EPERM; fprintf(fd, "[error] %s: missing byte_order field in trace declaration\n", __func__); @@ -2171,6 +2192,7 @@ error: trace->packet_header_decl = NULL; } g_ptr_array_free(trace->streams, TRUE); + g_ptr_array_free(trace->event_declarations, TRUE); free_declaration_scope(trace->declaration_scope); trace->declaration_scope = NULL; return ret; @@ -2338,7 +2360,7 @@ int ctf_clock_visit(FILE *fd, int depth, struct ctf_node *node, struct ctf_trace } if (!CTF_CLOCK_FIELD_IS_SET(clock, name)) { ret = -EPERM; - fprintf(fd, "[error] %s: missing namefield in clock declaration\n", __func__); + fprintf(fd, "[error] %s: missing name field in clock declaration\n", __func__); goto error; } if (g_hash_table_size(trace->clocks) > 0) { @@ -2436,6 +2458,21 @@ int ctf_env_declaration_visit(FILE *fd, int depth, struct ctf_node *node, strncpy(env->procname, right, TRACER_ENV_LEN); env->procname[TRACER_ENV_LEN - 1] = '\0'; printf_verbose("env.procname = \"%s\"\n", env->procname); + } else if (!strcmp(left, "hostname")) { + char *right; + + if (env->hostname[0]) { + fprintf(fd, "[warning] %s: duplicated env hostname\n", __func__); + goto error; /* ret is 0, so not an actual error, just warn. */ + } + right = concatenate_unary_strings(&node->u.ctf_expression.right); + if (!right) { + fprintf(fd, "[warning] %s: unexpected unary expression for env hostname\n", __func__); + goto error; /* ret is 0, so not an actual error, just warn. */ + } + strncpy(env->hostname, right, TRACER_ENV_LEN); + env->hostname[TRACER_ENV_LEN - 1] = '\0'; + printf_verbose("env.hostname = \"%s\"\n", env->hostname); } else if (!strcmp(left, "domain")) { char *right; @@ -2540,6 +2577,7 @@ int ctf_env_visit(FILE *fd, int depth, struct ctf_node *node, struct ctf_trace * trace->env.vpid = -1; trace->env.procname[0] = '\0'; + trace->env.hostname[0] = '\0'; trace->env.domain[0] = '\0'; trace->env.sysname[0] = '\0'; trace->env.release[0] = '\0';