Handle model.emf.uri event info
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 20 Sep 2012 16:37:09 +0000 (12:37 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 20 Sep 2012 16:37:09 +0000 (12:37 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
converter/babeltrace.c
formats/ctf-text/ctf-text.c
formats/ctf/metadata/ctf-visitor-generate-io-struct.c
include/babeltrace/babeltrace-internal.h
include/babeltrace/ctf-ir/metadata.h

index b8caa6a0bba2c55b8f312d38eaa282d1e4cc508a..dc8b4a700bbb450331e6cb6366b4e8152a8d486d 100644 (file)
@@ -134,7 +134,7 @@ static void usage(FILE *fp)
        fprintf(fp, "                                        (default: payload,context)\n");
        fprintf(fp, "  -f, --fields name1<,name2,...> Print additional fields:\n");
        fprintf(fp, "                                     all, trace, trace:hostname, trace:domain,\n");
-       fprintf(fp, "                                     trace:procname, trace:vpid, loglevel.\n");
+       fprintf(fp, "                                     trace:procname, trace:vpid, loglevel, emf.\n");
        fprintf(fp, "                                     (default: trace:hostname,trace:procname,trace:vpid)\n");
        fprintf(fp, "      --clock-cycles             Timestamp in cycles\n");
        fprintf(fp, "      --clock-offset seconds     Clock offset in seconds\n");
@@ -209,6 +209,8 @@ static int get_fields_args(poptContext *pc)
                        opt_trace_vpid_field = 1;
                else if (!strcmp(str, "loglevel"))
                        opt_loglevel_field = 1;
+               else if (!strcmp(str, "emf"))
+                       opt_emf_field = 1;
                else {
                        fprintf(stderr, "[error] unknown field type %s\n", str);
                        return -EINVAL;
index 7211c97f955889a4d6c15e409f2df0a87b4ae275..ca44a6fdc961e54830662877675b31a78a3da147 100644 (file)
@@ -49,6 +49,7 @@ int opt_all_field_names,
        opt_trace_hostname_field,
        opt_trace_default_fields = 1,
        opt_loglevel_field,
+       opt_emf_field,
        opt_delta_field = 1;
 
 enum field_item {
@@ -385,6 +386,19 @@ int ctf_text_write_event(struct stream_pos *ppos, struct ctf_stream_definition *
                        fprintf(pos->fp, ", ");
                dom_print = 1;
        }
+       if ((opt_emf_field || opt_all_fields) && event_class->model_emf_uri) {
+               set_field_names_print(pos, ITEM_HEADER);
+               if (pos->print_names) {
+                       fprintf(pos->fp, "model.emf.uri = ");
+               } else if (dom_print) {
+                       fprintf(pos->fp, ":");
+               }
+               fprintf(pos->fp, "%s",
+                       g_quark_to_string(event_class->model_emf_uri));
+               if (pos->print_names)
+                       fprintf(pos->fp, ", ");
+               dom_print = 1;
+       }
        if (dom_print && !pos->print_names)
                fprintf(pos->fp, " ");
        set_field_names_print(pos, ITEM_HEADER);
index ea8148b257953320431154df55d82bf80eb718f9..af75788aa92dedfd9794ea9b2f80473330e23cca 100644 (file)
@@ -1741,6 +1741,23 @@ int ctf_event_declaration_visit(FILE *fd, int depth, struct ctf_node *node, stru
                        }
                        event->loglevel = (int) loglevel;
                        CTF_EVENT_SET_FIELD(event, loglevel);
+               } else if (!strcmp(left, "model.emf.uri")) {
+                       char *right;
+
+                       if (CTF_EVENT_FIELD_IS_SET(event, model_emf_uri)) {
+                               fprintf(fd, "[error] %s: model.emf.uri already declared in event declaration\n", __func__);
+                               ret = -EPERM;
+                               goto error;
+                       }
+                       right = concatenate_unary_strings(&node->u.ctf_expression.right);
+                       if (!right) {
+                               fprintf(fd, "[error] %s: unexpected unary expression for event model.emf.uri\n", __func__);
+                               ret = -EINVAL;
+                               goto error;
+                       }
+                       event->model_emf_uri = g_quark_from_string(right);
+                       g_free(right);
+                       CTF_EVENT_SET_FIELD(event, model_emf_uri);
                } else {
                        fprintf(fd, "[warning] %s: attribute \"%s\" is unknown in event declaration.\n", __func__, left);
                        /* Fall-through after warning */
index 9f14177dc1431f8e519dd41b26063751f2bf7828..b3d51ef35d6778c1e704d74b9912032e68535643 100644 (file)
@@ -62,6 +62,7 @@ extern int opt_all_field_names,
        opt_trace_hostname_field,
        opt_trace_default_fields,
        opt_loglevel_field,
+       opt_emf_field,
        opt_delta_field,
        opt_clock_cycles,
        opt_clock_seconds,
index 63a6c2a9b4a9b9aa0d28259fd9ca8adb39937e3e..3176bbd4d46ec48cb82ce997dfb4644c5ce7c6ee 100644 (file)
@@ -237,12 +237,14 @@ struct ctf_event_declaration {
        uint64_t id;            /* Numeric identifier within the stream */
        uint64_t stream_id;
        int loglevel;
+       GQuark model_emf_uri;
 
        enum {                                  /* Fields populated mask */
                CTF_EVENT_name  =               (1 << 0),
                CTF_EVENT_id    =               (1 << 1),
                CTF_EVENT_stream_id =           (1 << 2),
                CTF_EVENT_loglevel =            (1 << 4),
+               CTF_EVENT_model_emf_uri =       (1 << 5),
        } field_mask;
 };
 
This page took 0.037896 seconds and 4 git commands to generate.