Merge branch 'master' of ssh://efficios.com/home/efficios/git/babeltrace
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 14 Jul 2011 13:36:56 +0000 (09:36 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 14 Jul 2011 13:36:56 +0000 (09:36 -0400)
Conflicts:
formats/ctf/ctf.c

44 files changed:
README
converter/babeltrace-lib.c
converter/babeltrace-log.c
converter/babeltrace.c
formats/ctf-text/ctf-text.c
formats/ctf-text/types/array.c
formats/ctf-text/types/enum.c
formats/ctf-text/types/float.c
formats/ctf-text/types/integer.c
formats/ctf-text/types/sequence.c
formats/ctf-text/types/string.c
formats/ctf-text/types/struct.c
formats/ctf-text/types/variant.c
formats/ctf/ctf.c
formats/ctf/metadata/ctf-test/fail/typealias-left-abstract-array.txt [new file with mode: 0644]
formats/ctf/metadata/ctf-test/readme.txt
formats/ctf/metadata/ctf-test/tofix/ctf-redefine-type.txt [new file with mode: 0644]
formats/ctf/metadata/ctf-test/tofix/ctf-typedef-ambiguity.txt [new file with mode: 0644]
formats/ctf/metadata/ctf-visitor-generate-io-struct.c
formats/ctf/metadata/ctf-visitor-parent-links.c
formats/ctf/metadata/ctf-visitor-semantic-validator.c
formats/ctf/metadata/ctf-visitor-xml.c
formats/ctf/types/array.c
formats/ctf/types/enum.c
formats/ctf/types/float.c
formats/ctf/types/integer.c
formats/ctf/types/sequence.c
formats/ctf/types/string.c
formats/ctf/types/struct.c
formats/ctf/types/variant.c
formats/registry.c
include/babeltrace/ctf-ir/metadata.h [new file with mode: 0644]
include/babeltrace/ctf/metadata.h
include/babeltrace/format.h
include/babeltrace/types.h
types/array.c
types/enum.c
types/float.c
types/integer.c
types/sequence.c
types/string.c
types/struct.c
types/types.c
types/variant.c

diff --git a/README b/README
index 45501009632e96a7bdf6ec202918e5d8885ea965..718bb68e5b73265c806ab056d902398d69347383 100644 (file)
--- a/README
+++ b/README
@@ -6,6 +6,16 @@ This project provides trace read and write libraries, as well as a trace
 converter. A plugin can be created for any trace format to allow its conversion
 to/from another trace format.
 
+The main format expected to be converted to/from is the Common Trace
+Format (CTF). The latest version of the CTF specification can be found at:
+
+  git tree:   git://git.efficios.com/ctf.git
+  gitweb:     http://git.efficios.com/?p=ctf.git
+
+The CE Workgroup of the Linux Foundation, Ericsson, and EfficiOS have
+sponsored this work.
+
+
 BUILDING
 --------
 
index 534e4eddd5e9ffa743b9f79dd46bdd3271863724..6cc2b7b8b73d07b72936dfad375d19c68ead3041 100644 (file)
@@ -3,7 +3,9 @@
  *
  * Babeltrace Trace Converter Library
  *
- * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -31,7 +33,7 @@ static int read_event(struct ctf_file_stream *sin)
 {
        int ret;
 
-       ret = sin->pos.parent.event_cb(&sin->pos.parent, &sin->stream);
+       ret = sin->pos.parent.event_cb(&sin->pos.parent, &sin->parent);
        if (ret == EOF)
                return EOF;
        else if (ret) {
@@ -48,7 +50,7 @@ int stream_compare(void *a, void *b)
 {
        struct ctf_file_stream *s_a = a, *s_b = b;
 
-       if (s_a->stream.timestamp < s_b->stream.timestamp)
+       if (s_a->parent.timestamp < s_b->parent.timestamp)
                return 1;
        else
                return 0;
@@ -73,8 +75,8 @@ int convert_trace(struct trace_descriptor *td_write,
 
                if (!stream)
                        continue;
-               for (filenr = 0; filenr < stream->files->len; filenr++) {
-                       struct ctf_file_stream *file_stream = g_ptr_array_index(stream->files, filenr);
+               for (filenr = 0; filenr < stream->streams->len; filenr++) {
+                       struct ctf_file_stream *file_stream = g_ptr_array_index(stream->streams, filenr);
                        ret = read_event(file_stream);
                        if (ret == EOF) {
                                ret = 0;
@@ -100,7 +102,7 @@ int convert_trace(struct trace_descriptor *td_write,
                        ret = 0;
                        break;
                }
-               ret = sout->parent.event_cb(&sout->parent, &file_stream->stream);
+               ret = sout->parent.event_cb(&sout->parent, &file_stream->parent);
                if (ret) {
                        fprintf(stdout, "[error] Writing event failed.\n");
                        goto end;
index 19cf3692a795ded50d645b7d5934788aaeb0412f..2b573bdeef22a0db7590b89de10a2efc4c71bdb3 100644 (file)
@@ -3,7 +3,9 @@
  *
  * BabelTrace - Convert Text Log to CTF
  *
- * Copyright 2010, 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -45,6 +47,7 @@ int babeltrace_debug, babeltrace_verbose;
 
 static char *s_outputname;
 static int s_timestamp;
+static int s_help;
 static uuid_t s_uuid;
 
 /* Metadata format string */
@@ -178,7 +181,7 @@ void write_event_header(struct ctf_stream_pos *pos, char *line,
        /* timestamp */
        ctf_align_pos(pos, sizeof(uint64_t) * CHAR_BIT);
        if (!pos->dummy)
-               *(uint32_t *) ctf_get_pos_addr(pos) = *ts;
+               *(uint64_t *) ctf_get_pos_addr(pos) = *ts;
        ctf_move_pos(pos, sizeof(uint64_t) * CHAR_BIT);
 }
 
@@ -264,6 +267,11 @@ int parse_args(int argc, char **argv)
        for (i = 1; i < argc; i++) {
                if (!strcmp(argv[i], "-t"))
                        s_timestamp = 1;
+               else if (!strcmp(argv[i], "-h")) {
+                       s_help = 1;
+                       return 0;
+               } else if (argv[i][0] == '-')
+                       return -EINVAL;
                else
                        s_outputname = argv[i];
        }
@@ -281,10 +289,16 @@ int main(int argc, char **argv)
 
        ret = parse_args(argc, argv);
        if (ret) {
+               fprintf(stdout, "Error: invalid argument.\n");
                usage(stdout);
                goto error;
        }
 
+       if (s_help) {
+               usage(stdout);
+               exit(EXIT_SUCCESS);
+       }
+
        ret = mkdir(s_outputname, S_IRWXU|S_IRWXG);
        if (ret) {
                perror("mkdir");
index 9d4212241274a14d2a8934de3a81a28ef8af4ec3..dd335edbb20d56374559d450cdcbbfdf8b29861b 100644 (file)
@@ -3,7 +3,9 @@
  *
  * Babeltrace Trace Converter
  *
- * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -187,8 +189,6 @@ int main(int argc, char **argv)
                        opt_input_format);
                exit(EXIT_FAILURE);
        }
-       if (!opt_output_format)
-               opt_output_format = "ctf";
        fmt_write = bt_lookup_format(g_quark_from_static_string(opt_output_format));
        if (!fmt_write) {
                fprintf(stdout, "[error] format \"%s\" is not supported.\n\n",
index 1500d735c18c437be2fc9c0744498ce9ffd222e8..992fbdf6c04833c2d901af798f2036fe767a916d 100644 (file)
@@ -3,7 +3,9 @@
  *
  * CTF Text Format registration.
  *
- * Copyright 2010, 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -99,7 +101,7 @@ 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;
+       struct ctf_stream_event *event;
        uint64_t id = 0;
        int ret;
 
@@ -145,7 +147,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
index 1ee556a02431bcf3b1796c2a9efeba5f5ff57200..6dc84480c67e49eff8b0837ca81a040d13f9b4f7 100644 (file)
@@ -3,7 +3,9 @@
  *
  * Array format access functions.
  *
- * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
index 9043277d19b07b634cf33c522e0d117e8fcb6e43..12031c242fef048c6de3687636fd211790456405 100644 (file)
@@ -3,7 +3,9 @@
  *
  * Enumeration mapping strings (quarks) from/to integers.
  *
- * Copyright 2010, 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
index 7fe4fe0042fb1f314b3b70d8fcb7984864788ace..0c559b0eba4e8be23d1ca7d0c3511b3127bd513e 100644 (file)
@@ -3,7 +3,9 @@
  *
  * Floating point read/write functions.
  *
- * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
index 30209d6be6c66fbcad295273c947b2d14bfdeefe..06593a4a2fc346ddae9e36fc9646deb9973dfdae 100644 (file)
@@ -3,7 +3,9 @@
  *
  * Integers read/write functions.
  *
- * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
index cdf393086d8559adb68a510c5bed7c02cd4806ad..6a0472f87c5d797b3276caf8b22e24714e838a1d 100644 (file)
@@ -3,7 +3,9 @@
  *
  * Sequence format access functions.
  *
- * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
index 610d6db3a59930cc208ad5ce69cd29be15abc94c..82bc361f2b96931cbe1f79be93a777f5b0940fd8 100644 (file)
@@ -3,7 +3,9 @@
  *
  * Strings read/write functions.
  *
- * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
index cc36fde9e2f5aff0177db425bd3ba6c5992de815..b1395351d9ff7498663992915399b33cd3dc48de 100644 (file)
@@ -3,7 +3,9 @@
  *
  * Structure format access functions.
  *
- * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
index a21197aa1b3ad35bdac68c980fe2cf7c4bed0d88..871b8d58a8435af3badad90cface116bbae73a93 100644 (file)
@@ -3,7 +3,9 @@
  *
  * Variant format access functions.
  *
- * Copyright 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
index cf9b3077edf54889a942f165fc8d5a2cb27f1f8e..098b7eb15d7d4589880243ed7d0ecdc66c7b4152 100644 (file)
@@ -3,7 +3,9 @@
  *
  * Format registration.
  *
- * Copyright 2010, 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -119,7 +121,7 @@ int ctf_read_event(struct stream_pos *ppos, struct ctf_stream *stream)
        struct ctf_stream_pos *pos =
                container_of(ppos, struct ctf_stream_pos, parent);
        struct ctf_stream_class *stream_class = stream->stream_class;
-       struct ctf_file_event *event;
+       struct ctf_stream_event *event;
        uint64_t id = 0;
        int ret;
 
@@ -156,14 +158,17 @@ int ctf_read_event(struct stream_pos *ppos, struct ctf_stream *stream)
                }
 
                /* lookup timestamp */
+               stream->has_timestamp = 0;
                integer_definition = lookup_integer(&stream->stream_event_header->p, "timestamp", FALSE);
                if (integer_definition) {
                        ctf_update_timestamp(stream, integer_definition);
+                       stream->has_timestamp = 1;
                } else {
                        if (variant) {
                                integer_definition = lookup_integer(variant, "timestamp", FALSE);
                                if (integer_definition) {
                                        ctf_update_timestamp(stream, integer_definition);
+                                       stream->has_timestamp = 1;
                                }
                        }
                }
@@ -211,7 +216,7 @@ static
 int ctf_write_event(struct stream_pos *pos, struct ctf_stream *stream)
 {
        struct ctf_stream_class *stream_class = stream->stream_class;
-       struct ctf_file_event *event;
+       struct ctf_stream_event *event;
        uint64_t id = 0;
        int ret;
 
@@ -407,7 +412,7 @@ void ctf_move_pos_slow(struct ctf_stream_pos *pos, size_t offset, int whence)
                pos->mmap_offset = index->offset;
 
                /* Lookup context/packet size in index */
-               file_stream->stream.timestamp = index->timestamp_begin;
+               file_stream->parent.timestamp = index->timestamp_begin;
                pos->content_size = index->content_size;
                pos->packet_size = index->packet_size;
                if (index->data_offset < index->content_size)
@@ -427,14 +432,14 @@ void ctf_move_pos_slow(struct ctf_stream_pos *pos, size_t offset, int whence)
        }
 
        /* update trace_packet_header and stream_packet_context */
-       if (file_stream->stream.trace_packet_header) {
+       if (pos->prot != PROT_WRITE && file_stream->parent.trace_packet_header) {
                /* Read packet header */
-               ret = generic_rw(&pos->parent, &file_stream->stream.trace_packet_header->p);
+               ret = generic_rw(&pos->parent, &file_stream->parent.trace_packet_header->p);
                assert(!ret);
        }
-       if (file_stream->stream.stream_packet_context) {
+       if (pos->prot != PROT_WRITE && file_stream->parent.stream_packet_context) {
                /* Read packet context */
-               ret = generic_rw(&pos->parent, &file_stream->stream.stream_packet_context->p);
+               ret = generic_rw(&pos->parent, &file_stream->parent.stream_packet_context->p);
                assert(!ret);
        }
 }
@@ -579,20 +584,23 @@ static
 int ctf_open_trace_metadata_read(struct ctf_trace *td)
 {
        struct ctf_scanner *scanner;
+       struct ctf_file_stream *metadata_stream;
        FILE *fp;
        char *buf = NULL;
        int ret = 0;
 
-       td->metadata.pos.fd = openat(td->dirfd, "metadata", O_RDONLY);
-       if (td->metadata.pos.fd < 0) {
+       metadata_stream = g_new0(struct ctf_file_stream, 1);
+       td->metadata = &metadata_stream->parent;
+       metadata_stream->pos.fd = openat(td->dirfd, "metadata", O_RDONLY);
+       if (metadata_stream->pos.fd < 0) {
                fprintf(stdout, "Unable to open metadata.\n");
-               return td->metadata.pos.fd;
+               return metadata_stream->pos.fd;
        }
 
        if (babeltrace_debug)
                yydebug = 1;
 
-       fp = fdopen(td->metadata.pos.fd, "r");
+       fp = fdopen(metadata_stream->pos.fd, "r");
        if (!fp) {
                fprintf(stdout, "[error] Unable to open metadata stream.\n");
                ret = -errno;
@@ -643,16 +651,18 @@ end_packet_read:
        fclose(fp);
        free(buf);
 end_stream:
-       close(td->metadata.pos.fd);
+       close(metadata_stream->pos.fd);
+       if (ret)
+               g_free(metadata_stream);
        return ret;
 }
 
 static
-struct ctf_file_event *create_event_definitions(struct ctf_trace *td,
-                                               struct ctf_stream *stream,
-                                               struct ctf_event *event)
+struct ctf_stream_event *create_event_definitions(struct ctf_trace *td,
+                                                 struct ctf_stream *stream,
+                                                 struct ctf_event *event)
 {
-       struct ctf_file_event *file_event = g_new0(struct ctf_file_event, 1);
+       struct ctf_stream_event *stream_event = g_new0(struct ctf_stream_event, 1);
 
        if (event->context_decl) {
                struct definition *definition =
@@ -661,9 +671,9 @@ struct ctf_file_event *create_event_definitions(struct ctf_trace *td,
                if (!definition) {
                        goto error;
                }
-               file_event->event_context = container_of(definition,
+               stream_event->event_context = container_of(definition,
                                        struct definition_struct, p);
-               stream->parent_def_scope = file_event->event_context->p.scope;
+               stream->parent_def_scope = stream_event->event_context->p.scope;
        }
        if (event->fields_decl) {
                struct definition *definition =
@@ -672,17 +682,17 @@ struct ctf_file_event *create_event_definitions(struct ctf_trace *td,
                if (!definition) {
                        goto error;
                }
-               file_event->event_fields = container_of(definition,
+               stream_event->event_fields = container_of(definition,
                                        struct definition_struct, p);
-               stream->parent_def_scope = file_event->event_fields->p.scope;
+               stream->parent_def_scope = stream_event->event_fields->p.scope;
        }
-       return file_event;
+       return stream_event;
 
 error:
-       if (file_event->event_fields)
-               definition_unref(&file_event->event_fields->p);
-       if (file_event->event_context)
-               definition_unref(&file_event->event_context->p);
+       if (stream_event->event_fields)
+               definition_unref(&stream_event->event_fields->p);
+       if (stream_event->event_context)
+               definition_unref(&stream_event->event_context->p);
        return NULL;
 }
 
@@ -738,22 +748,22 @@ int create_stream_definitions(struct ctf_trace *td, struct ctf_stream *stream)
        g_ptr_array_set_size(stream->events_by_id, stream_class->events_by_id->len);
        for (i = 0; i < stream->events_by_id->len; i++) {
                struct ctf_event *event = g_ptr_array_index(stream_class->events_by_id, i);
-               struct ctf_file_event *file_event;
+               struct ctf_stream_event *stream_event;
 
                if (!event)
                        continue;
-               file_event = create_event_definitions(td, stream, event);
-               if (!file_event)
+               stream_event = create_event_definitions(td, stream, event);
+               if (!stream_event)
                        goto error_event;
-               g_ptr_array_index(stream->events_by_id, i) = file_event;
+               g_ptr_array_index(stream->events_by_id, i) = stream_event;
        }
        return 0;
 
 error_event:
        for (i = 0; i < stream->events_by_id->len; i++) {
-               struct ctf_file_event *file_event = g_ptr_array_index(stream->events_by_id, i);
-               if (file_event)
-                       g_free(file_event);
+               struct ctf_stream_event *stream_event = g_ptr_array_index(stream->events_by_id, i);
+               if (stream_event)
+                       g_free(stream_event);
        }
        g_ptr_array_free(stream->events_by_id, TRUE);
 error:
@@ -815,17 +825,17 @@ int create_stream_packet_index(struct ctf_trace *td,
                packet_index.timestamp_end = 0;
 
                /* read and check header, set stream id (and check) */
-               if (file_stream->stream.trace_packet_header) {
+               if (file_stream->parent.trace_packet_header) {
                        /* Read packet header */
-                       ret = generic_rw(&pos->parent, &file_stream->stream.trace_packet_header->p);
+                       ret = generic_rw(&pos->parent, &file_stream->parent.trace_packet_header->p);
                        if (ret)
                                return ret;
-                       len_index = struct_declaration_lookup_field_index(file_stream->stream.trace_packet_header->declaration, g_quark_from_static_string("magic"));
+                       len_index = struct_declaration_lookup_field_index(file_stream->parent.trace_packet_header->declaration, g_quark_from_static_string("magic"));
                        if (len_index >= 0) {
                                struct definition_integer *defint;
                                struct definition *field;
 
-                               field = struct_definition_get_field_from_index(file_stream->stream.trace_packet_header, len_index);
+                               field = struct_definition_get_field_from_index(file_stream->parent.trace_packet_header, len_index);
                                assert(field->declaration->id == CTF_TYPE_INTEGER);
                                defint = container_of(field, struct definition_integer, p);
                                assert(defint->declaration->signedness == FALSE);
@@ -839,14 +849,14 @@ int create_stream_packet_index(struct ctf_trace *td,
                        }
 
                        /* check uuid */
-                       len_index = struct_declaration_lookup_field_index(file_stream->stream.trace_packet_header->declaration, g_quark_from_static_string("uuid"));
+                       len_index = struct_declaration_lookup_field_index(file_stream->parent.trace_packet_header->declaration, g_quark_from_static_string("uuid"));
                        if (len_index >= 0) {
                                struct definition_array *defarray;
                                struct definition *field;
                                uint64_t i;
                                uint8_t uuidval[UUID_LEN];
 
-                               field = struct_definition_get_field_from_index(file_stream->stream.trace_packet_header, len_index);
+                               field = struct_definition_get_field_from_index(file_stream->parent.trace_packet_header, len_index);
                                assert(field->declaration->id == CTF_TYPE_ARRAY);
                                defarray = container_of(field, struct definition_array, p);
                                assert(array_len(defarray) == UUID_LEN);
@@ -869,12 +879,12 @@ int create_stream_packet_index(struct ctf_trace *td,
                        }
 
 
-                       len_index = struct_declaration_lookup_field_index(file_stream->stream.trace_packet_header->declaration, g_quark_from_static_string("stream_id"));
+                       len_index = struct_declaration_lookup_field_index(file_stream->parent.trace_packet_header->declaration, g_quark_from_static_string("stream_id"));
                        if (len_index >= 0) {
                                struct definition_integer *defint;
                                struct definition *field;
 
-                               field = struct_definition_get_field_from_index(file_stream->stream.trace_packet_header, len_index);
+                               field = struct_definition_get_field_from_index(file_stream->parent.trace_packet_header, len_index);
                                assert(field->declaration->id == CTF_TYPE_INTEGER);
                                defint = container_of(field, struct definition_integer, p);
                                assert(defint->declaration->signedness == FALSE);
@@ -882,12 +892,12 @@ int create_stream_packet_index(struct ctf_trace *td,
                        }
                }
 
-               if (!first_packet && file_stream->stream_id != stream_id) {
+               if (!first_packet && file_stream->parent.stream_id != stream_id) {
                        fprintf(stdout, "[error] Stream ID is changing within a stream.\n");
                        return -EINVAL;
                }
                if (first_packet) {
-                       file_stream->stream_id = stream_id;
+                       file_stream->parent.stream_id = stream_id;
                        if (stream_id >= td->streams->len) {
                                fprintf(stdout, "[error] Stream %" PRIu64 " is not declared in metadata.\n", stream_id);
                                return -EINVAL;
@@ -897,25 +907,25 @@ int create_stream_packet_index(struct ctf_trace *td,
                                fprintf(stdout, "[error] Stream %" PRIu64 " is not declared in metadata.\n", stream_id);
                                return -EINVAL;
                        }
-                       file_stream->stream.stream_class = stream;
-                       ret = create_stream_definitions(td, &file_stream->stream);
+                       file_stream->parent.stream_class = stream;
+                       ret = create_stream_definitions(td, &file_stream->parent);
                        if (ret)
                                return ret;
                }
                first_packet = 0;
 
-               if (file_stream->stream.stream_packet_context) {
+               if (file_stream->parent.stream_packet_context) {
                        /* Read packet context */
-                       ret = generic_rw(&pos->parent, &file_stream->stream.stream_packet_context->p);
+                       ret = generic_rw(&pos->parent, &file_stream->parent.stream_packet_context->p);
                        if (ret)
                                return ret;
                        /* read content size from header */
-                       len_index = struct_declaration_lookup_field_index(file_stream->stream.stream_packet_context->declaration, g_quark_from_static_string("content_size"));
+                       len_index = struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("content_size"));
                        if (len_index >= 0) {
                                struct definition_integer *defint;
                                struct definition *field;
 
-                               field = struct_definition_get_field_from_index(file_stream->stream.stream_packet_context, len_index);
+                               field = struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
                                assert(field->declaration->id == CTF_TYPE_INTEGER);
                                defint = container_of(field, struct definition_integer, p);
                                assert(defint->declaration->signedness == FALSE);
@@ -926,12 +936,12 @@ int create_stream_packet_index(struct ctf_trace *td,
                        }
 
                        /* read packet size from header */
-                       len_index = struct_declaration_lookup_field_index(file_stream->stream.stream_packet_context->declaration, g_quark_from_static_string("packet_size"));
+                       len_index = struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("packet_size"));
                        if (len_index >= 0) {
                                struct definition_integer *defint;
                                struct definition *field;
 
-                               field = struct_definition_get_field_from_index(file_stream->stream.stream_packet_context, len_index);
+                               field = struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
                                assert(field->declaration->id == CTF_TYPE_INTEGER);
                                defint = container_of(field, struct definition_integer, p);
                                assert(defint->declaration->signedness == FALSE);
@@ -942,12 +952,12 @@ int create_stream_packet_index(struct ctf_trace *td,
                        }
 
                        /* read timestamp begin from header */
-                       len_index = struct_declaration_lookup_field_index(file_stream->stream.stream_packet_context->declaration, g_quark_from_static_string("timestamp_begin"));
+                       len_index = struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("timestamp_begin"));
                        if (len_index >= 0) {
                                struct definition_integer *defint;
                                struct definition *field;
 
-                               field = struct_definition_get_field_from_index(file_stream->stream.stream_packet_context, len_index);
+                               field = struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
                                assert(field->declaration->id == CTF_TYPE_INTEGER);
                                defint = container_of(field, struct definition_integer, p);
                                assert(defint->declaration->signedness == FALSE);
@@ -955,12 +965,12 @@ int create_stream_packet_index(struct ctf_trace *td,
                        }
 
                        /* read timestamp end from header */
-                       len_index = struct_declaration_lookup_field_index(file_stream->stream.stream_packet_context->declaration, g_quark_from_static_string("timestamp_end"));
+                       len_index = struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("timestamp_end"));
                        if (len_index >= 0) {
                                struct definition_integer *defint;
                                struct definition *field;
 
-                               field = struct_definition_get_field_from_index(file_stream->stream.stream_packet_context, len_index);
+                               field = struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
                                assert(field->declaration->id == CTF_TYPE_INTEGER);
                                defint = container_of(field, struct definition_integer, p);
                                assert(defint->declaration->signedness == FALSE);
@@ -982,7 +992,7 @@ int create_stream_packet_index(struct ctf_trace *td,
 
                if (packet_index.packet_size > (filestats.st_size - packet_index.offset) * CHAR_BIT) {
                        fprintf(stdout, "[error] Packet size (%zu bits) is larger than remaining file size (%zu bits).\n",
-                               packet_index.content_size, (filestats.st_size - packet_index.offset) * CHAR_BIT);
+                               packet_index.content_size, (size_t) (filestats.st_size - packet_index.offset) * CHAR_BIT);
                        return -EINVAL;
                }
 
@@ -1040,19 +1050,20 @@ int ctf_open_file_stream_read(struct ctf_trace *td, const char *path, int flags)
                goto error;
        file_stream = g_new0(struct ctf_file_stream, 1);
        ctf_init_pos(&file_stream->pos, ret, flags);
-       ret = create_trace_definitions(td, &file_stream->stream);
+       ret = create_trace_definitions(td, &file_stream->parent);
        if (ret)
                goto error_def;
        ret = create_stream_packet_index(td, file_stream);
        if (ret)
                goto error_index;
        /* Add stream file to stream class */
-       g_ptr_array_add(file_stream->stream.stream_class->files, file_stream);
+       g_ptr_array_add(file_stream->parent.stream_class->streams,
+                       &file_stream->parent);
        return 0;
 
 error_index:
-       if (file_stream->stream.trace_packet_header)
-               definition_unref(&file_stream->stream.trace_packet_header->p);
+       if (file_stream->parent.trace_packet_header)
+               definition_unref(&file_stream->parent.trace_packet_header->p);
 error_def:
        ctf_fini_pos(&file_stream->pos);
        close(file_stream->pos.fd);
@@ -1192,9 +1203,9 @@ void ctf_close_trace(struct trace_descriptor *tdp)
                        stream = g_ptr_array_index(td->streams, i);
                        if (!stream)
                                continue;
-                       for (j = 0; j < stream->files->len; j++) {
+                       for (j = 0; j < stream->streams->len; j++) {
                                struct ctf_file_stream *file_stream;
-                               file_stream = g_ptr_array_index(stream->files, j);
+                               file_stream = container_of(g_ptr_array_index(stream->streams, j), struct ctf_file_stream, parent);
                                ctf_close_file_stream(file_stream);
                        }
 
diff --git a/formats/ctf/metadata/ctf-test/fail/typealias-left-abstract-array.txt b/formats/ctf/metadata/ctf-test/fail/typealias-left-abstract-array.txt
new file mode 100644 (file)
index 0000000..aced772
--- /dev/null
@@ -0,0 +1,17 @@
+typealias integer { size = 8; align = 8; signed = false; } := uint8_t;
+typealias uint8_t [] := puint8_t;
+
+trace {
+       major = 0;
+       minor = 1;
+       uuid = "2a6422d0-6cee-11e0-8c08-cb07d7b3a564";
+       byte_order = le;
+       packet.header := struct {
+            uint8_t  field;
+       };
+};
+
+event {
+       name = string;
+       fields := struct { string str; };
+};
index 8dbb13148823942cf48951aa381f94bb859d570e..5bcb830b6ccca7f96b8733a4ad7d00e14af3387f 100644 (file)
@@ -1,4 +1,7 @@
 These are the CTF metadata parser test. Those under succeed/ should successfully
 parse. Those under fail/ should provide an appropriate failure message.
 
+The tests under tofix/ do not follow the CTF specifications due to
+ambiguity in the LALR parser implementation. These are rarely used.
+
 Mathieu Desnoyers
diff --git a/formats/ctf/metadata/ctf-test/tofix/ctf-redefine-type.txt b/formats/ctf/metadata/ctf-test/tofix/ctf-redefine-type.txt
new file mode 100644 (file)
index 0000000..f7a03d3
--- /dev/null
@@ -0,0 +1,23 @@
+typealias integer { size = 8; align = 8; signed = false; } := uint8_t;
+typealias integer { size = 32; align = 8; signed = false; } := uint32_t;
+
+// Define newtype
+typealias uint32_t := newtype;
+
+trace {
+       // Hide newtype
+       typedef uint8_t newtype;
+    
+       major = 0;
+       minor = 1;
+       uuid = "2a6422d0-6cee-11e0-8c08-cb07d7b3a564";
+       byte_order = le;
+       packet.header := struct {
+            uint8_t  field;
+       };
+};
+
+event {
+       name = string;
+       fields := struct { string str; };
+};
diff --git a/formats/ctf/metadata/ctf-test/tofix/ctf-typedef-ambiguity.txt b/formats/ctf/metadata/ctf-test/tofix/ctf-typedef-ambiguity.txt
new file mode 100644 (file)
index 0000000..a5dd3a7
--- /dev/null
@@ -0,0 +1,8 @@
+// Define unsigned long
+typealias integer { ... } := unsigned long;
+
+// Define unsigned long int
+typealias integer { ... } := unsigned long int;
+
+// Define int
+typedef unsigned long int;
index f137f6d32e9d90efe8dcd828435bc20a9450391c..bab2f7869715a1ca8c26859b1bdbbd659cddf64d 100644 (file)
@@ -1747,7 +1747,7 @@ int ctf_stream_visit(FILE *fd, int depth, struct ctf_node *node,
        stream->declaration_scope = new_declaration_scope(parent_declaration_scope);
        stream->events_by_id = g_ptr_array_new();
        stream->event_quark_to_id = g_hash_table_new(g_direct_hash, g_direct_equal);
-       stream->files = g_ptr_array_new();
+       stream->streams = g_ptr_array_new();
        if (node) {
                cds_list_for_each_entry(iter, &node->u.stream.declaration_list, siblings) {
                        ret = ctf_stream_declaration_visit(fd, depth + 1, iter, stream, trace);
@@ -1785,7 +1785,7 @@ error:
                declaration_unref(&stream->event_context_decl->p);
        if (stream->packet_context_decl)
                declaration_unref(&stream->packet_context_decl->p);
-       g_ptr_array_free(stream->files, TRUE);
+       g_ptr_array_free(stream->streams, TRUE);
        g_ptr_array_free(stream->events_by_id, TRUE);
        g_hash_table_destroy(stream->event_quark_to_id);
        free_declaration_scope(stream->declaration_scope);
index a4476b22e648029ff5f8d92a193b5f9672fefed9..0258fd63591276fff956ebc733c6258c0e0e7aa6 100644 (file)
@@ -147,12 +147,14 @@ int ctf_visitor_type_declarator(FILE *fd, int depth, struct ctf_node *node)
                        if (ret)
                                return ret;
                }
-               cds_list_for_each_entry(iter, &node->u.type_declarator.u.nested.length,
-                                       siblings) {
-                       iter->parent = node;
-                       ret = ctf_visitor_parent_links(fd, depth + 1, iter);
-                       if (ret)
-                               return ret;
+               if (!node->u.type_declarator.u.nested.abstract_array) {
+                       cds_list_for_each_entry(iter, &node->u.type_declarator.u.nested.length,
+                                               siblings) {
+                               iter->parent = node;
+                               ret = ctf_visitor_parent_links(fd, depth + 1, iter);
+                               if (ret)
+                                       return ret;
+                       }
                }
                if (node->u.type_declarator.bitfield_len) {
                        node->u.type_declarator.bitfield_len = node;
index 5f72e0b42b1652c9a9929ceeb59b91733d282988..b89f7bd7660d0d363faf4dab4dd77d009bb57320 100644 (file)
@@ -363,15 +363,22 @@ int ctf_visitor_type_declarator(FILE *fd, int depth, struct ctf_node *node)
                        if (ret)
                                return ret;
                }
-               cds_list_for_each_entry(iter, &node->u.type_declarator.u.nested.length,
-                                       siblings) {
-                       if (iter->type != NODE_UNARY_EXPRESSION) {
-                               fprintf(fd, "[error] %s: expecting unary expression as length\n", __func__);
+               if (!node->u.type_declarator.u.nested.abstract_array) {
+                       cds_list_for_each_entry(iter, &node->u.type_declarator.u.nested.length,
+                                               siblings) {
+                               if (iter->type != NODE_UNARY_EXPRESSION) {
+                                       fprintf(fd, "[error] %s: expecting unary expression as length\n", __func__);
+                                       return -EINVAL;
+                               }
+                               ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
+                               if (ret)
+                                       return ret;
+                       }
+               } else {
+                       if (node->parent->type == NODE_TYPEALIAS_TARGET) {
+                               fprintf(fd, "[error] %s: abstract array declarator not permitted as target of typealias\n", __func__);
                                return -EINVAL;
                        }
-                       ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
-                       if (ret)
-                               return ret;
                }
                if (node->u.type_declarator.bitfield_len) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1,
index 49fa992817906dfd66d93d14b33b1de3794f9a42..c47bd27d8ed61ae0c64bf3f7939f443b239fdfd2 100644 (file)
@@ -313,7 +313,12 @@ int ctf_visitor_print_type_declarator(FILE *fd, int depth, struct ctf_node *node
                        print_tabs(fd, depth);
                        fprintf(fd, "</type_declarator>\n");
                }
-               if (!cds_list_empty(&node->u.type_declarator.u.nested.length)) {
+               if (node->u.type_declarator.u.nested.abstract_array) {
+                       print_tabs(fd, depth);
+                       fprintf(fd, "<length>\n");
+                       print_tabs(fd, depth);
+                       fprintf(fd, "</length>\n");
+               } else if (!cds_list_empty(&node->u.type_declarator.u.nested.length)) {
                        print_tabs(fd, depth);
                        fprintf(fd, "<length>\n");
                        cds_list_for_each_entry(iter, &node->u.type_declarator.u.nested.length,
@@ -325,12 +330,6 @@ int ctf_visitor_print_type_declarator(FILE *fd, int depth, struct ctf_node *node
                        print_tabs(fd, depth);
                        fprintf(fd, "</length>\n");
                }
-               if (node->u.type_declarator.u.nested.abstract_array) {
-                       print_tabs(fd, depth);
-                       fprintf(fd, "<length>\n");
-                       print_tabs(fd, depth);
-                       fprintf(fd, "</length>\n");
-               }
                if (node->u.type_declarator.bitfield_len) {
                        print_tabs(fd, depth);
                        fprintf(fd, "<bitfield_len>\n");
index 71475014b9034e33bdc055aa355de4ee527d0b82..e5b428cc57571b05283bb7a8b1dc5b2b13bdc73b 100644 (file)
@@ -3,7 +3,9 @@
  *
  * Array format access functions.
  *
- * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
index f8fc9e57f1b0f423e0e24c7dd21f2db170c80b11..c2b50fd532f1b3736a360f1e4bdab5e9cf80c66f 100644 (file)
@@ -3,7 +3,9 @@
  *
  * Enumeration mapping strings (quarks) from/to integers.
  *
- * Copyright 2010, 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
index 8ba8a69d51d83d45b1c43a05074f959c22554f70..7f5e40661e5858c0a51cecf4bb08821724418d6f 100644 (file)
@@ -3,7 +3,9 @@
  *
  * Floating point read/write functions.
  *
- * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
index b5c59ddea1bf4dc9704e096f53c6e5cdc5cc0c74..719823b9ff23675aab3a0f1b787ddeb8f0af25f2 100644 (file)
@@ -3,7 +3,9 @@
  *
  * Integers read/write functions.
  *
- * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
index a14d5891027370cac352bc5522aebd6d5c38aed8..6aa5750cdb10d6a8373a16fd7ac517325ef590c8 100644 (file)
@@ -3,7 +3,9 @@
  *
  * Sequence format access functions.
  *
- * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
index 197a7e135f276825ae9e29f85a70b20636755c13..682bd76d116b158e7b9577308040facaec1acd65 100644 (file)
@@ -3,7 +3,9 @@
  *
  * Strings read/write functions.
  *
- * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
index 2913f4d0e2d41d6099e6cfda5ce18339826b224c..adce6cbabb32211cddf296d6ab4dd36bdf1fd451 100644 (file)
@@ -3,7 +3,9 @@
  *
  * Structure format access functions.
  *
- * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
index 25c189dd5dc6f8c9314d8299033fed739432124b..d2ef7714dd8622407ca4a8255ef38168c5e449b8 100644 (file)
@@ -3,7 +3,9 @@
  *
  * Variant format access functions.
  *
- * Copyright 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
index 656d6360aca0030856c3a08830998cea1ea4119f..a08b59364548104a93ad1503aac1543fd06b4394 100644 (file)
@@ -3,7 +3,9 @@
  *
  * Format Registry
  *
- * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
diff --git a/include/babeltrace/ctf-ir/metadata.h b/include/babeltrace/ctf-ir/metadata.h
new file mode 100644 (file)
index 0000000..14c788c
--- /dev/null
@@ -0,0 +1,179 @@
+#ifndef _BABELTRACE_CTF_IR_METADATA_H
+#define _BABELTRACE_CTF_IR_METADATA_H
+
+/*
+ * BabelTrace
+ *
+ * CTF Intermediate Representation Metadata Header
+ *
+ * Copyright 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ */
+
+#include <babeltrace/types.h>
+#include <babeltrace/format.h>
+#include <babeltrace/ctf/types.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <uuid/uuid.h>
+#include <assert.h>
+#include <glib.h>
+
+struct ctf_trace;
+struct ctf_stream_class;
+struct ctf_stream;
+struct ctf_event;
+
+struct ctf_stream {
+       struct ctf_stream_class *stream_class;
+       uint64_t timestamp;                     /* Current timestamp, in ns */
+       int has_timestamp;
+       uint64_t stream_id;
+
+       struct definition_struct *trace_packet_header;
+       struct definition_struct *stream_packet_context;
+       struct definition_struct *stream_event_header;
+       struct definition_struct *stream_event_context;
+       GPtrArray *events_by_id;                /* Array of struct ctf_stream_event pointers indexed by id */
+       struct definition_scope *parent_def_scope;      /* for initialization */
+       int stream_definitions_created;
+};
+
+struct ctf_stream_event {
+       struct definition_struct *event_context;
+       struct definition_struct *event_fields;
+};
+
+#define CTF_TRACE_SET_FIELD(ctf_trace, field)                          \
+       do {                                                            \
+               (ctf_trace)->field_mask |= CTF_TRACE_ ## field;         \
+       } while (0)
+
+#define CTF_TRACE_FIELD_IS_SET(ctf_trace, field)                       \
+               ((ctf_trace)->field_mask & CTF_TRACE_ ## field)
+
+#define CTF_TRACE_GET_FIELD(ctf_trace, field)                          \
+       ({                                                              \
+               assert(CTF_TRACE_FIELD_IS_SET(ctf_trace, field));       \
+               (ctf_trace)->(field);                                   \
+       })
+
+
+struct ctf_trace {
+       struct trace_descriptor parent;
+       /* root scope */
+       struct declaration_scope *root_declaration_scope;
+
+       struct declaration_scope *declaration_scope;
+       /* innermost definition scope. to be used as parent of stream. */
+       struct definition_scope *definition_scope;
+       GPtrArray *streams;                     /* Array of struct ctf_stream_class pointers */
+       struct ctf_stream *metadata;
+
+       /* Declarations only used when parsing */
+       struct declaration_struct *packet_header_decl;
+
+       uint64_t major;
+       uint64_t minor;
+       uuid_t uuid;
+       int byte_order;         /* trace BYTE_ORDER. 0 if unset. */
+
+       enum {                                  /* Fields populated mask */
+               CTF_TRACE_major         =       (1U << 0),
+               CTF_TRACE_minor         =       (1U << 1),
+               CTF_TRACE_uuid          =       (1U << 2),
+               CTF_TRACE_byte_order    =       (1U << 3),
+               CTF_TRACE_packet_header =       (1U << 4),
+       } field_mask;
+
+       /* Information about trace backing directory and files */
+       DIR *dir;
+       int dirfd;
+       int flags;              /* open flags */
+
+       /* Heap of streams, ordered to always get the lowest timestam */
+       struct ptr_heap *stream_heap;
+};
+
+#define CTF_STREAM_SET_FIELD(ctf_stream, field)                                \
+       do {                                                            \
+               (ctf_stream)->field_mask |= CTF_STREAM_ ## field;       \
+       } while (0)
+
+#define CTF_STREAM_FIELD_IS_SET(ctf_stream, field)                     \
+               ((ctf_stream)->field_mask & CTF_STREAM_ ## field)
+
+#define CTF_STREAM_GET_FIELD(ctf_stream, field)                                \
+       ({                                                              \
+               assert(CTF_STREAM_FIELD_IS_SET(ctf_stream, field));     \
+               (ctf_stream)->(field);                                  \
+       })
+
+struct ctf_stream_class {
+       struct ctf_trace *trace;
+       /* parent is lexical scope conaining the stream scope */
+       struct declaration_scope *declaration_scope;
+       /* innermost definition scope. to be used as parent of event. */
+       struct definition_scope *definition_scope;
+       GPtrArray *events_by_id;                /* Array of struct ctf_event pointers indexed by id */
+       GHashTable *event_quark_to_id;          /* GQuark to numeric id */
+
+       /* Declarations only used when parsing */
+       struct declaration_struct *packet_context_decl;
+       struct declaration_struct *event_header_decl;
+       struct declaration_struct *event_context_decl;
+
+       uint64_t stream_id;
+
+       enum {                                  /* Fields populated mask */
+               CTF_STREAM_stream_id =  (1 << 0),
+       } field_mask;
+
+       GPtrArray *streams;     /* Array of struct ctf_stream pointers */
+};
+
+#define CTF_EVENT_SET_FIELD(ctf_event, field)                          \
+       do {                                                            \
+               (ctf_event)->field_mask |= CTF_EVENT_ ## field;         \
+       } while (0)
+
+#define CTF_EVENT_FIELD_IS_SET(ctf_event, field)                       \
+               ((ctf_event)->field_mask & CTF_EVENT_ ## field)
+
+#define CTF_EVENT_GET_FIELD(ctf_event, field)                          \
+       ({                                                              \
+               assert(CTF_EVENT_FIELD_IS_SET(ctf_event, field));       \
+               (ctf_event)->(field);                                   \
+       })
+
+struct ctf_event {
+       /* stream mapped by stream_id */
+       struct ctf_stream_class *stream;
+       /* parent is lexical scope conaining the event scope */
+       struct declaration_scope *declaration_scope;
+
+       /* Declarations only used when parsing */
+       struct declaration_struct *context_decl;
+       struct declaration_struct *fields_decl;
+
+       GQuark name;
+       uint64_t id;            /* Numeric identifier within the stream */
+       uint64_t stream_id;
+
+       enum {                                  /* Fields populated mask */
+               CTF_EVENT_name  =       (1 << 0),
+               CTF_EVENT_id    =       (1 << 1),
+               CTF_EVENT_stream_id =   (1 << 2),
+       } field_mask;
+};
+
+#endif /* _BABELTRACE_CTF_IR_METADATA_H */
index 56b0aa22e6f913466de2422a6e65ba45db35caef..e985ee5f034ebae3d7e6fc149c0fcd6e4bf74e50 100644 (file)
@@ -22,6 +22,7 @@
 #include <babeltrace/types.h>
 #include <babeltrace/format.h>
 #include <babeltrace/ctf/types.h>
+#include <babeltrace/ctf-ir/metadata.h>
 #include <sys/types.h>
 #include <dirent.h>
 #include <uuid/uuid.h>
 #define CTF_MAGIC      0xC1FC1FC1
 #define TSDL_MAGIC     0x75D11D57
 
-struct ctf_trace;
-struct ctf_stream_class;
-struct ctf_stream;
-struct ctf_event;
-
-struct ctf_stream {
-       struct ctf_stream_class *stream_class;
-       uint64_t timestamp;                     /* Current timestamp, in ns */
-
-       struct definition_struct *trace_packet_header;
-       struct definition_struct *stream_packet_context;
-       struct definition_struct *stream_event_header;
-       struct definition_struct *stream_event_context;
-       GPtrArray *events_by_id;                /* Array of struct ctf_file_event pointers indexed by id */
-       struct definition_scope *parent_def_scope;      /* for initialization */
-       int stream_definitions_created;
-};
-
-struct ctf_file_event {
-       struct definition_struct *event_context;
-       struct definition_struct *event_fields;
-};
-
 struct ctf_file_stream {
-       uint64_t stream_id;
-       struct ctf_stream stream;
+       struct ctf_stream parent;
        struct ctf_stream_pos pos;      /* current stream position */
 };
 
-#define CTF_TRACE_SET_FIELD(ctf_trace, field)                          \
-       do {                                                            \
-               (ctf_trace)->field_mask |= CTF_TRACE_ ## field;         \
-       } while (0)
-
-#define CTF_TRACE_FIELD_IS_SET(ctf_trace, field)                       \
-               ((ctf_trace)->field_mask & CTF_TRACE_ ## field)
-
-#define CTF_TRACE_GET_FIELD(ctf_trace, field)                          \
-       ({                                                              \
-               assert(CTF_TRACE_FIELD_IS_SET(ctf_trace, field));       \
-               (ctf_trace)->(field);                                   \
-       })
-
-
-struct ctf_trace {
-       struct trace_descriptor parent;
-       /* root scope */
-       struct declaration_scope *root_declaration_scope;
-
-       struct declaration_scope *declaration_scope;
-       /* innermost definition scope. to be used as parent of stream. */
-       struct definition_scope *definition_scope;
-       GPtrArray *streams;                     /* Array of struct ctf_stream_class pointers */
-       struct ctf_file_stream metadata;
-
-       /* Declarations only used when parsing */
-       struct declaration_struct *packet_header_decl;
-
-       uint64_t major;
-       uint64_t minor;
-       uuid_t uuid;
-       int byte_order;         /* trace BYTE_ORDER. 0 if unset. */
-
-       enum {                                  /* Fields populated mask */
-               CTF_TRACE_major         =       (1U << 0),
-               CTF_TRACE_minor         =       (1U << 1),
-               CTF_TRACE_uuid          =       (1U << 2),
-               CTF_TRACE_byte_order    =       (1U << 3),
-               CTF_TRACE_packet_header =       (1U << 4),
-       } field_mask;
-
-       /* Information about trace backing directory and files */
-       DIR *dir;
-       int dirfd;
-       int flags;              /* open flags */
-
-       /* Heap of streams, ordered to always get the lowest timestam */
-       struct ptr_heap *stream_heap;
-};
-
-#define CTF_STREAM_SET_FIELD(ctf_stream, field)                                \
-       do {                                                            \
-               (ctf_stream)->field_mask |= CTF_STREAM_ ## field;       \
-       } while (0)
-
-#define CTF_STREAM_FIELD_IS_SET(ctf_stream, field)                     \
-               ((ctf_stream)->field_mask & CTF_STREAM_ ## field)
-
-#define CTF_STREAM_GET_FIELD(ctf_stream, field)                                \
-       ({                                                              \
-               assert(CTF_STREAM_FIELD_IS_SET(ctf_stream, field));     \
-               (ctf_stream)->(field);                                  \
-       })
-
-struct ctf_stream_class {
-       struct ctf_trace *trace;
-       /* parent is lexical scope conaining the stream scope */
-       struct declaration_scope *declaration_scope;
-       /* innermost definition scope. to be used as parent of event. */
-       struct definition_scope *definition_scope;
-       GPtrArray *events_by_id;                /* Array of struct ctf_event pointers indexed by id */
-       GHashTable *event_quark_to_id;          /* GQuark to numeric id */
-
-       /* Declarations only used when parsing */
-       struct declaration_struct *packet_context_decl;
-       struct declaration_struct *event_header_decl;
-       struct declaration_struct *event_context_decl;
-
-       uint64_t stream_id;
-
-       enum {                                  /* Fields populated mask */
-               CTF_STREAM_stream_id =  (1 << 0),
-       } field_mask;
-
-       GPtrArray *files;                       /* Array of struct ctf_file_stream pointers */
-};
-
-#define CTF_EVENT_SET_FIELD(ctf_event, field)                          \
-       do {                                                            \
-               (ctf_event)->field_mask |= CTF_EVENT_ ## field;         \
-       } while (0)
-
-#define CTF_EVENT_FIELD_IS_SET(ctf_event, field)                       \
-               ((ctf_event)->field_mask & CTF_EVENT_ ## field)
-
-#define CTF_EVENT_GET_FIELD(ctf_event, field)                          \
-       ({                                                              \
-               assert(CTF_EVENT_FIELD_IS_SET(ctf_event, field));       \
-               (ctf_event)->(field);                                   \
-       })
-
-struct ctf_event {
-       /* stream mapped by stream_id */
-       struct ctf_stream_class *stream;
-       /* parent is lexical scope conaining the event scope */
-       struct declaration_scope *declaration_scope;
-
-       /* Declarations only used when parsing */
-       struct declaration_struct *context_decl;
-       struct declaration_struct *fields_decl;
-
-       GQuark name;
-       uint64_t id;            /* Numeric identifier within the stream */
-       uint64_t stream_id;
-
-       enum {                                  /* Fields populated mask */
-               CTF_EVENT_name  =       (1 << 0),
-               CTF_EVENT_id    =       (1 << 1),
-               CTF_EVENT_stream_id =   (1 << 2),
-       } field_mask;
-};
-
 #define HEADER_END             char end_field
 #define header_sizeof(type)    offsetof(typeof(type), end_field)
 
index c97d1987fd9e14c05f440223308d41c5d1c9b39c..c50b28dc330b8c81c23aefb4133829974b2f7cce 100644 (file)
@@ -6,7 +6,9 @@
  *
  * Trace Format Header
  *
- * Copyright 2010, 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
index 4534d0f1c2e491c2db7ba5f865b09a22826e7897..a9fb5fe3ef6e30acd2b63d5b046128291ba1e064 100644 (file)
@@ -6,7 +6,9 @@
  *
  * Type Header
  *
- * Copyright 2010, 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -512,6 +514,8 @@ void append_scope_path(const char *path, GArray *q);
 /*
  * Lookup helpers.
  */
+struct definition *lookup_definition(struct definition *definition,
+                                    const char *field_name);
 struct definition_integer *lookup_integer(struct definition *definition,
                                          const char *field_name,
                                          int signedness);
index 4cc1fbaa6cbc80c2c2a43d9ad54fd5c12fce9575..db6853f5ebcbf902a60cdcb9a86782c6bb225f5e 100644 (file)
@@ -3,7 +3,9 @@
  *
  * BabelTrace - Array Type Converter
  *
- * Copyright 2010, 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
index 5e7b8a4d61dd94f8df96261298bdddb88a240ef6..f096d5b6dc4081626087094598bc1f59f2cbb1d9 100644 (file)
@@ -3,7 +3,9 @@
  *
  * BabelTrace - Enumeration Type
  *
- * Copyright 2010, 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
index 78270e22aba3cf212ddeb6b6a390c871b5cdfeda..cc6c957aeebe09ebc6124cc4cdf8db985f558893 100644 (file)
@@ -3,7 +3,9 @@
  *
  * BabelTrace - Float Type Converter
  *
- * Copyright 2010, 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
index 5f9989b2111493ad0bdfe98c27805faf33d598e9..e55c03e8a3cb353a96aff3019d700e573584f278 100644 (file)
@@ -3,7 +3,9 @@
  *
  * BabelTrace - Integer Type Converter
  *
- * Copyright 2010, 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
index 1066bc712d9a063a8cd489b6e5382105084a16c1..ed719bc5d553ef3b34d5125c38dcd771076ec1a9 100644 (file)
@@ -3,7 +3,9 @@
  *
  * BabelTrace - Sequence Type Converter
  *
- * Copyright 2010, 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
index 1999cffdb0b4ff188c706bd16a5cc96cab15e8dc..9eaa9df800e25219e6d817e98c57daa2b94f4565 100644 (file)
@@ -3,7 +3,9 @@
  *
  * BabelTrace - String Type Converter
  *
- * Copyright 2010, 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
index 3961afc529e7492fa568fc61d53a3863e3e21503..188be82cadb95592864162cd47f8b8fcd5c21f48 100644 (file)
@@ -3,7 +3,9 @@
  *
  * BabelTrace - Structure Type Converter
  *
- * Copyright 2010, 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
index 3b48d83abe0da025479690079d5a2a96cdd916eb..11e91b02218524b15a21f558c0f7ec311f69f50a 100644 (file)
@@ -5,7 +5,9 @@
  *
  * Types registry.
  *
- * Copyright 2010, 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -597,7 +599,6 @@ void free_definition_scope(struct definition_scope *scope)
        g_free(scope);
 }
 
-static
 struct definition *lookup_definition(struct definition *definition,
                                     const char *field_name)
 {
index 30ef3d8aeca45954a13e0cb86b13ba8e2fd97799..bb4faa17093a87ec0266f7f08349922037105e1b 100644 (file)
@@ -3,7 +3,9 @@
  *
  * BabelTrace - Variant Type Converter
  *
- * Copyright 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
This page took 0.087663 seconds and 4 git commands to generate.