From d63ca2cd2249356c28a63653d30c681e9a7ce249 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Mon, 9 May 2011 10:59:04 -0400 Subject: [PATCH] Add -t option Signed-off-by: Mathieu Desnoyers --- converter/babeltrace.c | 7 +++++++ formats/ctf-text/ctf-text.c | 10 +++++++++- formats/ctf-text/types/array.c | 2 -- formats/ctf-text/types/enum.c | 3 --- formats/ctf-text/types/float.c | 1 - formats/ctf-text/types/integer.c | 10 ++-------- formats/ctf-text/types/sequence.c | 2 -- formats/ctf-text/types/string.c | 1 - formats/ctf-text/types/struct.c | 2 -- formats/ctf-text/types/variant.c | 2 -- include/babeltrace/babeltrace.h | 2 ++ 11 files changed, 20 insertions(+), 22 deletions(-) diff --git a/converter/babeltrace.c b/converter/babeltrace.c index 64392d0c..9d421224 100644 --- a/converter/babeltrace.c +++ b/converter/babeltrace.c @@ -33,6 +33,7 @@ static const char *opt_input_path; static const char *opt_output_path; int babeltrace_verbose, babeltrace_debug; +int opt_field_names; void strlower(char *str) { @@ -48,6 +49,7 @@ enum { OPT_LIST, OPT_VERBOSE, OPT_DEBUG, + OPT_NAMES, }; static struct poptOption long_options[] = { @@ -58,6 +60,7 @@ static struct poptOption long_options[] = { { "list", 'l', POPT_ARG_NONE, NULL, OPT_LIST, NULL, NULL }, { "verbose", 'v', POPT_ARG_NONE, NULL, OPT_VERBOSE, NULL, NULL }, { "debug", 'd', POPT_ARG_NONE, NULL, OPT_DEBUG, NULL, NULL }, + { "names", 'n', POPT_ARG_NONE, NULL, OPT_NAMES, NULL, NULL }, { NULL, 0, 0, NULL, 0, NULL, NULL }, }; @@ -84,6 +87,7 @@ static void usage(FILE *fp) fprintf(fp, " -l, --list List available formats\n"); fprintf(fp, " -v, --verbose Verbose mode\n"); fprintf(fp, " -d, --debug Debug mode\n"); + fprintf(fp, " -n, --names Print field names\n"); list_formats(fp); fprintf(fp, "\n"); } @@ -121,6 +125,9 @@ static int parse_options(int argc, char **argv) case OPT_DEBUG: babeltrace_debug = 1; break; + case OPT_NAMES: + opt_field_names = 1; + break; default: ret = -EINVAL; goto end; diff --git a/formats/ctf-text/ctf-text.c b/formats/ctf-text/ctf-text.c index ceca3e4e..423cb10f 100644 --- a/formats/ctf-text/ctf-text.c +++ b/formats/ctf-text/ctf-text.c @@ -98,6 +98,8 @@ int ctf_text_write_event(struct stream_pos *ppos, if (stream_class->event_header) { if (pos->print_names) fprintf(pos->fp, ", stream.event.header ="); + else + fprintf(pos->fp, ","); fprintf(pos->fp, " "); ret = generic_rw(ppos, &stream_class->event_header->p); if (ret) @@ -108,6 +110,8 @@ int ctf_text_write_event(struct stream_pos *ppos, if (stream_class->event_context) { if (pos->print_names) fprintf(pos->fp, ", stream.event.context ="); + else + fprintf(pos->fp, ","); fprintf(pos->fp, " "); ret = generic_rw(ppos, &stream_class->event_context->p); if (ret) @@ -118,6 +122,8 @@ int ctf_text_write_event(struct stream_pos *ppos, if (event_class->context) { if (pos->print_names) fprintf(pos->fp, ", event.context ="); + else + fprintf(pos->fp, ","); fprintf(pos->fp, " "); ret = generic_rw(ppos, &event_class->context->p); if (ret) @@ -128,6 +134,8 @@ int ctf_text_write_event(struct stream_pos *ppos, if (event_class->fields) { if (pos->print_names) fprintf(pos->fp, ", event.fields ="); + else + fprintf(pos->fp, ","); fprintf(pos->fp, " "); ret = generic_rw(ppos, &event_class->fields->p); if (ret) @@ -161,7 +169,7 @@ struct trace_descriptor *ctf_text_open_trace(const char *path, int flags) pos->fp = fp; pos->parent.rw_table = write_dispatch_table; pos->parent.event_cb = ctf_text_write_event; - pos->print_names = 1; + pos->print_names = opt_field_names; break; case O_RDONLY: default: diff --git a/formats/ctf-text/types/array.c b/formats/ctf-text/types/array.c index f61693ab..aa941b5e 100644 --- a/formats/ctf-text/types/array.c +++ b/formats/ctf-text/types/array.c @@ -25,7 +25,6 @@ int ctf_text_array_write(struct stream_pos *ppos, struct definition *definition) int ret; if (!pos->dummy) { - //print_pos_tabs(pos); if (definition->index != 0 && definition->index != INT_MAX) fprintf(pos->fp, ","); if (definition->index != INT_MAX) @@ -39,7 +38,6 @@ int ctf_text_array_write(struct stream_pos *ppos, struct definition *definition) ret = array_rw(ppos, definition); if (!pos->dummy) { pos->depth--; - //print_pos_tabs(pos); fprintf(pos->fp, " ]"); } return ret; diff --git a/formats/ctf-text/types/enum.c b/formats/ctf-text/types/enum.c index cf8cc4fa..0cb90218 100644 --- a/formats/ctf-text/types/enum.c +++ b/formats/ctf-text/types/enum.c @@ -41,11 +41,9 @@ int ctf_text_enum_write(struct stream_pos *ppos, struct definition *definition) fprintf(pos->fp, "%s = ", g_quark_to_string(definition->name)); - //print_pos_tabs(pos); fprintf(pos->fp, "("); pos->depth++; ret = generic_rw(ppos, &integer_definition->p); - //print_pos_tabs(pos); fprintf(pos->fp, " :"); qs = enum_definition->value; @@ -61,7 +59,6 @@ int ctf_text_enum_write(struct stream_pos *ppos, struct definition *definition) fprintf(pos->fp, "%s\n", str); } pos->depth--; - //print_pos_tabs(pos); fprintf(pos->fp, " )"); return ret; } diff --git a/formats/ctf-text/types/float.c b/formats/ctf-text/types/float.c index d2a66d4b..3569fd4e 100644 --- a/formats/ctf-text/types/float.c +++ b/formats/ctf-text/types/float.c @@ -29,7 +29,6 @@ int ctf_text_float_write(struct stream_pos *ppos, struct definition *definition) if (pos->dummy) return 0; - //print_pos_tabs(pos); if (definition->index != 0 && definition->index != INT_MAX) fprintf(pos->fp, ","); diff --git a/formats/ctf-text/types/integer.c b/formats/ctf-text/types/integer.c index f25f4540..0032e642 100644 --- a/formats/ctf-text/types/integer.c +++ b/formats/ctf-text/types/integer.c @@ -40,15 +40,9 @@ int ctf_text_integer_write(struct stream_pos *ppos, struct definition *definitio fprintf(pos->fp, "%s = ", g_quark_to_string(definition->name)); - //print_pos_tabs(pos); - if (!compare_definition_path(definition, g_quark_from_static_string("stream.event.header.timestamp"))) { - if (!pos->print_names) - fprintf(pos->fp, "[%" PRIu64 "]", - integer_definition->value._unsigned); - else - fprintf(pos->fp, "%" PRIu64, - integer_definition->value._unsigned); + fprintf(pos->fp, "%" PRIu64, + integer_definition->value._unsigned); return 0; } diff --git a/formats/ctf-text/types/sequence.c b/formats/ctf-text/types/sequence.c index 70a41dc3..4e904894 100644 --- a/formats/ctf-text/types/sequence.c +++ b/formats/ctf-text/types/sequence.c @@ -25,7 +25,6 @@ int ctf_text_sequence_write(struct stream_pos *ppos, struct definition *definiti int ret; if (!pos->dummy) { - //print_pos_tabs(pos); if (definition->index != 0 && definition->index != INT_MAX) fprintf(pos->fp, ","); if (definition->index != INT_MAX) @@ -39,7 +38,6 @@ int ctf_text_sequence_write(struct stream_pos *ppos, struct definition *definiti ret = sequence_rw(ppos, definition); if (!pos->dummy) { pos->depth--; - //print_pos_tabs(pos); fprintf(pos->fp, " ]"); } return ret; diff --git a/formats/ctf-text/types/string.c b/formats/ctf-text/types/string.c index 59924daf..3979e826 100644 --- a/formats/ctf-text/types/string.c +++ b/formats/ctf-text/types/string.c @@ -31,7 +31,6 @@ int ctf_text_string_write(struct stream_pos *ppos, assert(string_definition->value != NULL); if (pos->dummy) return 0; - //print_pos_tabs(pos); if (definition->index != 0 && definition->index != INT_MAX) fprintf(pos->fp, ","); diff --git a/formats/ctf-text/types/struct.c b/formats/ctf-text/types/struct.c index e8ffddc2..9f63c7bd 100644 --- a/formats/ctf-text/types/struct.c +++ b/formats/ctf-text/types/struct.c @@ -26,7 +26,6 @@ int ctf_text_struct_write(struct stream_pos *ppos, struct definition *definition if (!pos->dummy) { if (pos->depth >= 0) { - //print_pos_tabs(pos); if (definition->index != 0 && definition->index != INT_MAX) fprintf(pos->fp, ","); if (definition->index != INT_MAX) @@ -42,7 +41,6 @@ int ctf_text_struct_write(struct stream_pos *ppos, struct definition *definition if (!pos->dummy) { pos->depth--; if (pos->depth >= 0) { - //print_pos_tabs(pos); fprintf(pos->fp, " }"); } } diff --git a/formats/ctf-text/types/variant.c b/formats/ctf-text/types/variant.c index e6abd499..1787fb3e 100644 --- a/formats/ctf-text/types/variant.c +++ b/formats/ctf-text/types/variant.c @@ -26,7 +26,6 @@ int ctf_text_variant_write(struct stream_pos *ppos, struct definition *definitio if (!pos->dummy) { if (pos->depth >= 0) { - //print_pos_tabs(pos); if (definition->index != 0 && definition->index != INT_MAX) fprintf(pos->fp, ","); if (definition->index != INT_MAX) @@ -42,7 +41,6 @@ int ctf_text_variant_write(struct stream_pos *ppos, struct definition *definitio if (!pos->dummy) { pos->depth--; if (pos->depth >= 0) { - //print_pos_tabs(pos); fprintf(pos->fp, " }"); } } diff --git a/include/babeltrace/babeltrace.h b/include/babeltrace/babeltrace.h index fe23fefd..b7646a1d 100644 --- a/include/babeltrace/babeltrace.h +++ b/include/babeltrace/babeltrace.h @@ -25,4 +25,6 @@ struct trace_descriptor; int convert_trace(struct trace_descriptor *td_write, struct trace_descriptor *td_read); +extern int opt_field_names; + #endif -- 2.34.1