Add support for trace:hostname field
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 27 Aug 2012 00:22:27 +0000 (20:22 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 27 Aug 2012 00:22:27 +0000 (20:22 -0400)
Very, very, incredibly useful for multi-node traces.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
converter/babeltrace.c
doc/babeltrace.1
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 21722d23f19f045d875b5f5eec46a6e1219b44f8..a6020737f8094f6c0dd158ab4ca2b0b64139eb4b 100644 (file)
@@ -133,8 +133,8 @@ static void usage(FILE *fp)
        fprintf(fp, "                                     none, all, scope, header, (context OR ctx)\n");
        fprintf(fp, "                                        (default: payload,context)\n");
        fprintf(fp, "  -f, --fields name1<,name2,...> Print additional fields:\n");
-       fprintf(fp, "                                     all, trace, trace:domain, trace:procname,\n");
-       fprintf(fp, "                                     trace:vpid, loglevel.\n");
+       fprintf(fp, "                                     all, trace, trace:hostname, trace:domain,\n");
+       fprintf(fp, "                                     trace:procname, trace:vpid, loglevel.\n");
        fprintf(fp, "      --clock-cycles             Timestamp in cycles\n");
        fprintf(fp, "      --clock-offset seconds     Clock offset in seconds\n");
        fprintf(fp, "      --clock-seconds            Print the timestamps as [sec.ns]\n");
@@ -203,6 +203,8 @@ static int get_fields_args(poptContext *pc)
                        opt_trace_procname_field = 1;
                else if (!strcmp(str, "trace:vpid"))
                        opt_trace_vpid_field = 1;
+               else if (!strcmp(str, "trace:hostname"))
+                       opt_trace_hostname_field = 1;
                else if (!strcmp(str, "loglevel"))
                        opt_loglevel_field = 1;
                else {
index c41d4ddc06db7b95af7819c9208b9ba90c937470..319629909a34ce462e93531c7c403c2bfd10d1d4 100644 (file)
@@ -54,8 +54,8 @@ Print field names: (payload OR args OR arg), none, all, scope, header,
 (context OR ctx), (default: payload,context).
 .TP
 .BR "-f, --fields name1<,name2,...>"
-Print additional fields: all, trace, trace:domain, trace:procname,
-trace:vpid, loglevel.
+Print additional fields: all, trace, trace:hostname, trace:domain,
+trace:procname, trace:vpid, loglevel.
 .TP
 .BR "--clock-raw"
 Disregard internal clock offset (use raw value)
index 55158caa427ed6666c017c6259965fa568a217e9..d209eca23f99da6634d6c1680045d8a3bd14f79b 100644 (file)
@@ -46,6 +46,7 @@ int opt_all_field_names,
        opt_trace_domain_field,
        opt_trace_procname_field,
        opt_trace_vpid_field,
+       opt_trace_hostname_field,
        opt_loglevel_field,
        opt_delta_field = 1;
 
@@ -322,6 +323,16 @@ int ctf_text_write_event(struct stream_pos *ppos, struct ctf_stream_definition *
                else
                        fprintf(pos->fp, " ");
        }
+       if ((opt_trace_hostname_field && !opt_all_fields) && stream_class->trace->env.hostname[0] != '\0') {
+               set_field_names_print(pos, ITEM_HEADER);
+               if (pos->print_names) {
+                       fprintf(pos->fp, "trace:hostname = ");
+               }
+               fprintf(pos->fp, "%s", stream_class->trace->env.hostname);
+               if (pos->print_names)
+                       fprintf(pos->fp, ", ");
+               dom_print = 1;
+       }
        if ((opt_trace_domain_field && !opt_all_fields) && stream_class->trace->env.domain[0] != '\0') {
                set_field_names_print(pos, ITEM_HEADER);
                if (pos->print_names) {
index 43fdcb22442386cace3e60553842e3b5c7eabd82..ea8148b257953320431154df55d82bf80eb718f9 100644 (file)
@@ -2458,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;
 
@@ -2562,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';
index 29354a4a0eaa5f4503fec218c2aa0489a042d308..92e2f5123809a86b11fe2dfb4752dea24d7f01dd 100644 (file)
@@ -59,6 +59,7 @@ extern int opt_all_field_names,
        opt_trace_domain_field,
        opt_trace_procname_field,
        opt_trace_vpid_field,
+       opt_trace_hostname_field,
        opt_loglevel_field,
        opt_delta_field,
        opt_clock_cycles,
index 85b0f2d5ef8637ff8a25d5efe50dcaa5b8f7719d..63a6c2a9b4a9b9aa0d28259fd9ca8adb39937e3e 100644 (file)
@@ -123,6 +123,7 @@ struct ctf_tracer_env {
 
        /* All strings below: "" if unset. */
        char procname[TRACER_ENV_LEN];
+       char hostname[TRACER_ENV_LEN];
        char domain[TRACER_ENV_LEN];
        char sysname[TRACER_ENV_LEN];
        char release[TRACER_ENV_LEN];
This page took 0.028828 seconds and 4 git commands to generate.