Save current event id
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 12 Aug 2011 21:36:29 +0000 (17:36 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 12 Aug 2011 21:36:29 +0000 (17:36 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
formats/ctf-text/ctf-text.c
formats/ctf/ctf.c
include/babeltrace/ctf-ir/metadata.h

index 992fbdf6c04833c2d901af798f2036fe767a916d..ac35cfb769450a7b96f830399cae0409f8466c98 100644 (file)
@@ -102,35 +102,10 @@ int ctf_text_write_event(struct stream_pos *ppos,
        int field_nr_saved;
        struct ctf_event *event_class;
        struct ctf_stream_event *event;
-       uint64_t id = 0;
+       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);
index f078735c3ea9fd5307c46333b28b2c473867a7e1..b39b86906e506ffbbe8cc77619a9a90d01c0b5e6 100644 (file)
@@ -159,6 +159,7 @@ int ctf_read_event(struct stream_pos *ppos, struct ctf_stream *stream)
                                id = integer_definition->value._unsigned;
                        }
                }
+               stream->event_id = id;
 
                /* lookup timestamp */
                stream->has_timestamp = 0;
@@ -220,35 +221,13 @@ int ctf_write_event(struct stream_pos *pos, struct ctf_stream *stream)
 {
        struct ctf_stream_class *stream_class = stream->stream_class;
        struct ctf_stream_event *event;
-       uint64_t id = 0;
+       uint64_t id;
        int ret;
 
+       id = stream->event_id;
+
        /* 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;
-                       }
-               }
-
                ret = generic_rw(pos, &stream->stream_event_header->p);
                if (ret)
                        goto error;
index 61349152fbb426df2430fd3f64ea69c5d9282276..b8835ec2d8b17bc29f99f35e48e17c3a6c9a2323 100644 (file)
@@ -36,6 +36,7 @@ struct ctf_event;
 struct ctf_stream {
        struct ctf_stream_class *stream_class;
        uint64_t timestamp;                     /* Current timestamp, in ns */
+       uint64_t event_id;                      /* Current event ID */
        int has_timestamp;
        uint64_t stream_id;
 
This page took 0.036416 seconds and 4 git commands to generate.