Add "-n trace" option to print trace name
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 22 Nov 2011 09:34:31 +0000 (10:34 +0100)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 22 Nov 2011 09:34:31 +0000 (10:34 +0100)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
converter/babeltrace.c
formats/ctf-text/ctf-text.c
formats/ctf/ctf.c
formats/ctf/metadata/ctf-visitor-generate-io-struct.c
include/babeltrace/babeltrace-internal.h
include/babeltrace/ctf-ir/metadata.h

index 22743c96878a1072585315e3d4eb0fb571d52a83..bac8a85f700a2f7b14dc5fbe4265d24e47aeadca 100644 (file)
@@ -97,8 +97,9 @@ static void usage(FILE *fp)
        fprintf(fp, "                                 (or set BABELTRACE_DEBUG environment variable)\n");
        fprintf(fp, "  -n, --names name1<,name2,...>  Print field names.\n");
        fprintf(fp, "                                 Available field names:\n");
-       fprintf(fp, "                                     payload OR args OR arg\n");
-       fprintf(fp, "                                     all, scope, header, context OR ctx\n");
+       fprintf(fp, "                                     (payload OR args OR arg)\n");
+       fprintf(fp, "                                     all, scope, header, (context OR ctx)\n");
+       fprintf(fp, "                                     trace\n");
        fprintf(fp, "                                        (payload active by default)\n");
        list_formats(fp);
        fprintf(fp, "\n");
@@ -125,6 +126,8 @@ static int get_names_args(poptContext *pc)
                        opt_header_field_names = 1;
                else if (!strcmp(str, "payload") || !strcmp(str, "args") || !strcmp(str, "arg"))
                        opt_payload_field_names = 1;
+               else if (!strcmp(str, "trace"))
+                       opt_trace_name = 1;
                else {
                        fprintf(stdout, "[error] unknown field name type %s\n", str);
                        return -EINVAL;
index 5879cf4f8dfbb2a1f02216332e3dc817217a88c0..9ad23012d9512cc2fe4c79e8cc999a8a1850ada1 100644 (file)
@@ -38,7 +38,8 @@ int opt_all_field_names,
        opt_scope_field_names,
        opt_header_field_names,
        opt_context_field_names,
-       opt_payload_field_names;
+       opt_payload_field_names,
+       opt_trace_name;
 
 enum field_item {
        ITEM_SCOPE,
@@ -186,6 +187,18 @@ int ctf_text_write_event(struct stream_pos *ppos,
                else
                        fprintf(pos->fp, " ");
        }
+       if ((opt_trace_name || opt_all_field_names) && stream_class->trace->path[0] != '\0') {
+               set_field_names_print(pos, ITEM_HEADER);
+               if (pos->print_names)
+                       fprintf(pos->fp, "trace = ");
+
+               fprintf(pos->fp, "%s", stream_class->trace->path);
+
+               if (pos->print_names)
+                       fprintf(pos->fp, ", ");
+               else
+                       fprintf(pos->fp, " ");
+       }
        set_field_names_print(pos, ITEM_HEADER);
        if (pos->print_names)
                fprintf(pos->fp, "name = ");
index 9af3f45386bcf721fd590ca8a0ac893c79622f9d..8b9441fdd701ea078bd2839b1009af05e5e1b117 100644 (file)
@@ -1167,6 +1167,8 @@ int ctf_open_trace_read(struct ctf_trace *td, const char *path, int flags,
                ret = -errno;
                goto error_dirfd;
        }
+       strncpy(td->path, path, PATH_MAX);
+       td->path[PATH_MAX - 1] = '\0';
 
        /*
         * Keep the metadata file separate.
index 725235d18a8d66a980134600fe44dade95aec6bc..82af10a10f259be1fd05a6467bc210aa13c0ae83 100644 (file)
@@ -1793,6 +1793,7 @@ int ctf_stream_visit(FILE *fd, int depth, struct ctf_node *node,
        if (trace->streams->len <= stream->stream_id)
                g_ptr_array_set_size(trace->streams, stream->stream_id + 1);
        g_ptr_array_index(trace->streams, stream->stream_id) = stream;
+       stream->trace = trace;
 
        return 0;
 
index 78adefce346e40bd2dc82d964ebf31fc1730acd2..a329cc939192012bdb5c0979aa51fb6fe6fed9ca 100644 (file)
@@ -33,6 +33,7 @@ extern int opt_all_field_names,
        opt_scope_field_names,
        opt_header_field_names,
        opt_context_field_names,
-       opt_payload_field_names;
+       opt_payload_field_names,
+       opt_trace_name;
 
 #endif
index b8835ec2d8b17bc29f99f35e48e17c3a6c9a2323..b9157567ff4bbfca880e5ba2ce8dcdd6169ef1d8 100644 (file)
@@ -102,6 +102,7 @@ struct ctf_trace {
 
        /* Heap of streams, ordered to always get the lowest timestam */
        struct ptr_heap *stream_heap;
+       char path[PATH_MAX];
 };
 
 #define CTF_STREAM_SET_FIELD(ctf_stream, field)                                \
This page took 0.039785 seconds and 4 git commands to generate.