X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=formats%2Fctf-text%2Fctf-text.c;h=f1c1f037a1e979d5301650bae1b39f805a9b44de;hp=0d551179710dafc368ed9059cbe2a40b62d5facf;hb=ae23d232404678391ac28a103af7be54be03aa61;hpb=e28d4618a97ed5c6da7cda25af9d1121808664cf diff --git a/formats/ctf-text/ctf-text.c b/formats/ctf-text/ctf-text.c index 0d551179..f1c1f037 100644 --- a/formats/ctf-text/ctf-text.c +++ b/formats/ctf-text/ctf-text.c @@ -3,7 +3,9 @@ * * CTF Text Format registration. * - * Copyright 2010, 2011 - Mathieu Desnoyers + * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation + * + * Author: Mathieu Desnoyers * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -19,7 +21,7 @@ #include #include #include -#include +#include #include #include #include @@ -32,7 +34,9 @@ #include #include -struct trace_descriptor *ctf_text_open_trace(const char *path, int flags); +struct trace_descriptor *ctf_text_open_trace(const char *path, int flags, + void (*move_pos_slow)(struct ctf_stream_pos *pos, size_t offset, + int whence), FILE *metadata_fp); void ctf_text_close_trace(struct trace_descriptor *descriptor); static @@ -53,6 +57,43 @@ struct format ctf_text_format = { .close_trace = ctf_text_close_trace, }; +static GQuark Q_STREAM_PACKET_CONTEXT_TIMESTAMP_BEGIN, + Q_STREAM_PACKET_CONTEXT_TIMESTAMP_END, + Q_STREAM_PACKET_CONTEXT_EVENTS_DISCARDED, + Q_STREAM_PACKET_CONTEXT_CONTENT_SIZE, + Q_STREAM_PACKET_CONTEXT_PACKET_SIZE; + +static +void __attribute__((constructor)) init_quarks(void) +{ + Q_STREAM_PACKET_CONTEXT_TIMESTAMP_BEGIN = g_quark_from_static_string("stream.packet.context.timestamp_begin"); + Q_STREAM_PACKET_CONTEXT_TIMESTAMP_END = g_quark_from_static_string("stream.packet.context.timestamp_end"); + Q_STREAM_PACKET_CONTEXT_EVENTS_DISCARDED = g_quark_from_static_string("stream.packet.context.events_discarded"); + Q_STREAM_PACKET_CONTEXT_CONTENT_SIZE = g_quark_from_static_string("stream.packet.context.content_size"); + Q_STREAM_PACKET_CONTEXT_PACKET_SIZE = g_quark_from_static_string("stream.packet.context.packet_size"); +} + +int print_field(struct definition *definition) +{ + /* Print all fields in verbose mode */ + if (babeltrace_verbose) + return 1; + + /* Filter out part of the packet context */ + if (definition->path == Q_STREAM_PACKET_CONTEXT_TIMESTAMP_BEGIN) + return 0; + if (definition->path == Q_STREAM_PACKET_CONTEXT_TIMESTAMP_END) + return 0; + if (definition->path == Q_STREAM_PACKET_CONTEXT_EVENTS_DISCARDED) + return 0; + if (definition->path == Q_STREAM_PACKET_CONTEXT_CONTENT_SIZE) + return 0; + if (definition->path == Q_STREAM_PACKET_CONTEXT_PACKET_SIZE) + return 0; + + return 1; +} + static int ctf_text_write_event(struct stream_pos *ppos, struct ctf_stream *stream) @@ -62,36 +103,11 @@ int ctf_text_write_event(struct stream_pos *ppos, struct ctf_stream_class *stream_class = stream->stream_class; int field_nr_saved; struct ctf_event *event_class; - struct ctf_file_event *event; - uint64_t id = 0; + struct ctf_stream_event *event; + uint64_t id; int ret; - /* print event header */ - if (stream->stream_event_header) { - struct definition_integer *integer_definition; - struct definition *variant; - - /* lookup event id */ - integer_definition = lookup_integer(&stream->stream_event_header->p, "id", FALSE); - if (integer_definition) { - id = integer_definition->value._unsigned; - } else { - struct definition_enum *enum_definition; - - enum_definition = lookup_enum(&stream->stream_event_header->p, "id", FALSE); - if (enum_definition) { - id = enum_definition->integer->value._unsigned; - } - } - - variant = lookup_variant(&stream->stream_event_header->p, "v"); - if (variant) { - integer_definition = lookup_integer(variant, "id", FALSE); - if (integer_definition) { - id = integer_definition->value._unsigned; - } - } - } + id = stream->event_id; if (id >= stream_class->events_by_id->len) { fprintf(stdout, "[error] Event id %" PRIu64 " is outside range.\n", id); @@ -108,7 +124,7 @@ int ctf_text_write_event(struct stream_pos *ppos, return -EINVAL; } - if (stream->timestamp) { + if (stream->has_timestamp) { if (pos->print_names) fprintf(pos->fp, "timestamp = "); else @@ -211,7 +227,9 @@ error: } -struct trace_descriptor *ctf_text_open_trace(const char *path, int flags) +struct trace_descriptor *ctf_text_open_trace(const char *path, int flags, + void (*move_pos_slow)(struct ctf_stream_pos *pos, size_t offset, + int whence), FILE *metadata_fp) { struct ctf_text_stream_pos *pos; FILE *fp;