Fix typo
[ctf.git] / common-trace-format-proposal.txt
CommitLineData
5ba9f198 1
4767a9e7 2RFC: Common Trace Format (CTF) Proposal (pre-v1.7)
5ba9f198
MD
3
4Mathieu Desnoyers, EfficiOS Inc.
5
6The goal of the present document is to propose a trace format that suits the
cc089c3a 7needs of the embedded, telecom, high-performance and kernel communities. It is
5ba9f198 8based on the Common Trace Format Requirements (v1.4) document. It is designed to
cc089c3a 9allow traces to be natively generated by the Linux kernel, Linux user-space
6c7226e9
MD
10applications written in C/C++, and hardware components. One major element of
11CTF is the Trace Stream Description Language (TSDL) which flexibility
12enables description of various binary trace stream layouts.
cc089c3a
MD
13
14The latest version of this document can be found at:
15
16 git tree: git://git.efficios.com/ctf.git
17 gitweb: http://git.efficios.com/?p=ctf.git
5ba9f198
MD
18
19A reference implementation of a library to read and write this trace format is
20being implemented within the BabelTrace project, a converter between trace
21formats. The development tree is available at:
22
23 git tree: git://git.efficios.com/babeltrace.git
24 gitweb: http://git.efficios.com/?p=babeltrace.git
25
26
271. Preliminary definitions
28
3bf79539
MD
29 - Event Trace: An ordered sequence of events.
30 - Event Stream: An ordered sequence of events, containing a subset of the
31 trace event types.
32 - Event Packet: A sequence of physically contiguous events within an event
33 stream.
5ba9f198
MD
34 - Event: This is the basic entry in a trace. (aka: a trace record).
35 - An event identifier (ID) relates to the class (a type) of event within
3bf79539
MD
36 an event stream.
37 e.g. event: irq_entry.
5ba9f198
MD
38 - An event (or event record) relates to a specific instance of an event
39 class.
3bf79539
MD
40 e.g. event: irq_entry, at time X, on CPU Y
41 - Source Architecture: Architecture writing the trace.
42 - Reader Architecture: Architecture reading the trace.
5ba9f198
MD
43
44
452. High-level representation of a trace
46
3bf79539
MD
47A trace is divided into multiple event streams. Each event stream contains a
48subset of the trace event types.
5ba9f198 49
3bf79539
MD
50The final output of the trace, after its generation and optional transport over
51the network, is expected to be either on permanent or temporary storage in a
52virtual file system. Because each event stream is appended to while a trace is
53being recorded, each is associated with a separate file for output. Therefore,
54a stored trace can be represented as a directory containing one file per stream.
5ba9f198 55
6672e9e1
MD
56Meta-data description associated with the trace contains information on
57trace event types expressed in the Trace Stream Description Language
58(TSDL). This language describes:
5ba9f198
MD
59
60- Trace version.
61- Types available.
6672e9e1 62- Per-trace event header description.
3bf79539 63- Per-stream event header description.
6672e9e1 64- Per-stream event context description.
5ba9f198 65- Per-event
3bf79539 66 - Event type to stream mapping.
5ba9f198
MD
67 - Event type to name mapping.
68 - Event type to ID mapping.
6672e9e1 69 - Event context description.
5ba9f198
MD
70 - Event fields description.
71
72
3bf79539 733. Event stream
5ba9f198 74
6672e9e1
MD
75An event stream can be divided into contiguous event packets of variable
76size. These subdivisions have a variable size. An event packet can
77contain a certain amount of padding at the end. The stream header is
78repeated at the beginning of each event packet. The rationale for the
79event stream design choices is explained in Appendix B. Stream Header
80Rationale.
5ba9f198 81
3bf79539
MD
82The event stream header will therefore be referred to as the "event packet
83header" throughout the rest of this document.
5ba9f198
MD
84
85
864. Types
87
1fad7a85
MD
88Types are organized as type classes. Each type class belong to either of two
89kind of types: basic types or compound types.
90
5ba9f198
MD
914.1 Basic types
92
1fad7a85
MD
93A basic type is a scalar type, as described in this section. It includes
94integers, GNU/C bitfields, enumerations, and floating point values.
5ba9f198
MD
95
964.1.1 Type inheritance
97
80fd2569
MD
98Type specifications can be inherited to allow deriving types from a
99type class. For example, see the uint32_t named type derived from the "integer"
100type class below ("Integers" section). Types have a precise binary
101representation in the trace. A type class has methods to read and write these
102types, but must be derived into a type to be usable in an event field.
5ba9f198
MD
103
1044.1.2 Alignment
105
106We define "byte-packed" types as aligned on the byte size, namely 8-bit.
107We define "bit-packed" types as following on the next bit, as defined by the
370eae99 108"Integers" section.
5ba9f198 109
6672e9e1
MD
110Each basic type must specify its alignment, in bits. Examples of
111possible alignments are: bit-packed, byte-packed, or word-aligned. The
112choice depends on the architecture preference and compactness vs
113performance trade-offs of the implementation. Architectures providing
114fast unaligned write byte-packed basic types to save space, aligning
115each type on byte boundaries (8-bit). Architectures with slow unaligned
116writes align types on specific alignment values. If no specific
370eae99
MD
117alignment is declared for a type, it is assumed to be bit-packed for
118integers with size not multiple of 8 bits and for gcc bitfields. All
6672e9e1
MD
119other types are byte-packed. It is however recommended to always specify
120the alignment explicitly.
5ba9f198 121
6672e9e1 122TSDL meta-data attribute representation of a specific alignment:
5ba9f198
MD
123
124 align = value; /* value in bits */
125
1264.1.3 Byte order
127
3bf79539
MD
128By default, the native endianness of the source architecture the trace is used.
129Byte order can be overridden for a basic type by specifying a "byte_order"
130attribute. Typical use-case is to specify the network byte order (big endian:
131"be") to save data captured from the network into the trace without conversion.
132If not specified, the byte order is native.
5ba9f198 133
6672e9e1 134TSDL meta-data representation:
5ba9f198
MD
135
136 byte_order = native OR network OR be OR le; /* network and be are aliases */
137
1384.1.4 Size
139
140Type size, in bits, for integers and floats is that returned by "sizeof()" in C
141multiplied by CHAR_BIT.
142We require the size of "char" and "unsigned char" types (CHAR_BIT) to be fixed
143to 8 bits for cross-endianness compatibility.
144
6672e9e1 145TSDL meta-data representation:
5ba9f198
MD
146
147 size = value; (value is in bits)
148
1494.1.5 Integers
150
6672e9e1
MD
151Signed integers are represented in two-complement. Integer alignment,
152size, signedness and byte ordering are defined in the TSDL meta-data.
153Integers aligned on byte size (8-bit) and with length multiple of byte
154size (8-bit) correspond to the C99 standard integers. In addition,
155integers with alignment and/or size that are _not_ a multiple of the
156byte size are permitted; these correspond to the C99 standard bitfields,
157with the added specification that the CTF integer bitfields have a fixed
158binary representation. A MIT-licensed reference implementation of the
159CTF portable bitfields is available at:
5ba9f198
MD
160
161 http://git.efficios.com/?p=babeltrace.git;a=blob;f=include/babeltrace/bitfield.h
162
163Binary representation of integers:
164
165- On little and big endian:
166 - Within a byte, high bits correspond to an integer high bits, and low bits
167 correspond to low bits.
168- On little endian:
169 - Integer across multiple bytes are placed from the less significant to the
170 most significant.
171 - Consecutive integers are placed from lower bits to higher bits (even within
172 a byte).
173- On big endian:
174 - Integer across multiple bytes are placed from the most significant to the
175 less significant.
176 - Consecutive integers are placed from higher bits to lower bits (even within
177 a byte).
178
179This binary representation is derived from the bitfield implementation in GCC
180for little and big endian. However, contrary to what GCC does, integers can
6672e9e1 181cross units boundaries (no padding is required). Padding can be explicitly
5ba9f198
MD
182added (see 4.1.6 GNU/C bitfields) to follow the GCC layout if needed.
183
6672e9e1 184TSDL meta-data representation:
5ba9f198 185
80fd2569 186 integer {
5ba9f198
MD
187 signed = true OR false; /* default false */
188 byte_order = native OR network OR be OR le; /* default native */
189 size = value; /* value in bits, no default */
190 align = value; /* value in bits */
2152348f 191 }
5ba9f198 192
80fd2569 193Example of type inheritance (creation of a uint32_t named type):
5ba9f198 194
359894ac 195typealias integer {
9e4e34e9 196 size = 32;
5ba9f198
MD
197 signed = false;
198 align = 32;
38b8da21 199} := uint32_t;
5ba9f198 200
80fd2569 201Definition of a named 5-bit signed bitfield:
5ba9f198 202
359894ac 203typealias integer {
5ba9f198
MD
204 size = 5;
205 signed = true;
206 align = 1;
38b8da21 207} := int5_t;
5ba9f198
MD
208
2094.1.6 GNU/C bitfields
210
211The GNU/C bitfields follow closely the integer representation, with a
212particularity on alignment: if a bitfield cannot fit in the current unit, the
80fd2569
MD
213unit is padded and the bitfield starts at the following unit. The unit size is
214defined by the size of the type "unit_type".
5ba9f198 215
6672e9e1 216TSDL meta-data representation:
80fd2569
MD
217
218 unit_type name:size:
219
5ba9f198
MD
220As an example, the following structure declared in C compiled by GCC:
221
222struct example {
223 short a:12;
224 short b:5;
225};
226
2152348f
MD
227The example structure is aligned on the largest element (short). The second
228bitfield would be aligned on the next unit boundary, because it would not fit in
229the current unit.
5ba9f198
MD
230
2314.1.7 Floating point
232
6672e9e1 233The floating point values byte ordering is defined in the TSDL meta-data.
5ba9f198
MD
234
235Floating point values follow the IEEE 754-2008 standard interchange formats.
236Description of the floating point values include the exponent and mantissa size
237in bits. Some requirements are imposed on the floating point values:
238
239- FLT_RADIX must be 2.
240- mant_dig is the number of digits represented in the mantissa. It is specified
241 by the ISO C99 standard, section 5.2.4, as FLT_MANT_DIG, DBL_MANT_DIG and
242 LDBL_MANT_DIG as defined by <float.h>.
243- exp_dig is the number of digits represented in the exponent. Given that
244 mant_dig is one bit more than its actual size in bits (leading 1 is not
245 needed) and also given that the sign bit always takes one bit, exp_dig can be
246 specified as:
247
248 - sizeof(float) * CHAR_BIT - FLT_MANT_DIG
249 - sizeof(double) * CHAR_BIT - DBL_MANT_DIG
250 - sizeof(long double) * CHAR_BIT - LDBL_MANT_DIG
251
6672e9e1 252TSDL meta-data representation:
5ba9f198 253
80fd2569 254floating_point {
5ba9f198
MD
255 exp_dig = value;
256 mant_dig = value;
257 byte_order = native OR network OR be OR le;
2152348f 258}
5ba9f198
MD
259
260Example of type inheritance:
261
359894ac 262typealias floating_point {
5ba9f198
MD
263 exp_dig = 8; /* sizeof(float) * CHAR_BIT - FLT_MANT_DIG */
264 mant_dig = 24; /* FLT_MANT_DIG */
265 byte_order = native;
38b8da21 266} := float;
5ba9f198
MD
267
268TODO: define NaN, +inf, -inf behavior.
269
2704.1.8 Enumerations
271
272Enumerations are a mapping between an integer type and a table of strings. The
273numerical representation of the enumeration follows the integer type specified
6672e9e1
MD
274by the meta-data. The enumeration mapping table is detailed in the enumeration
275description within the meta-data. The mapping table maps inclusive value
276ranges (or single values) to strings. Instead of being limited to simple
3bf79539 277"value -> string" mappings, these enumerations map
80fd2569 278"[ start_value ... end_value ] -> string", which map inclusive ranges of
3bf79539
MD
279values to strings. An enumeration from the C language can be represented in
280this format by having the same start_value and end_value for each element, which
281is in fact a range of size 1. This single-value range is supported without
4767a9e7 282repeating the start and end values with the value = string declaration.
80fd2569 283
a9b83695 284enum name : integer_type {
359894ac 285 somestring = start_value1 ... end_value1,
80fd2569
MD
286 "other string" = start_value2 ... end_value2,
287 yet_another_string, /* will be assigned to end_value2 + 1 */
288 "some other string" = value,
289 ...
290};
291
292If the values are omitted, the enumeration starts at 0 and increment of 1 for
293each entry:
294
a9b83695 295enum name : unsigned int {
80fd2569
MD
296 ZERO,
297 ONE,
298 TWO,
299 TEN = 10,
300 ELEVEN,
3bf79539 301};
5ba9f198 302
80fd2569 303Overlapping ranges within a single enumeration are implementation defined.
5ba9f198 304
2152348f
MD
305A nameless enumeration can be declared as a field type or as part of a typedef:
306
a9b83695 307enum : integer_type {
2152348f
MD
308 ...
309}
310
c2742c56
MD
311Enumerations omitting the container type ": integer_type" use the "int"
312type (for compatibility with C99). The "int" type must be previously
313declared. E.g.:
314
315typealias integer { size = 32; align = 32; signed = true } := int;
316
317enum {
318 ...
319}
320
1fad7a85 321
5ba9f198
MD
3224.2 Compound types
323
1fad7a85
MD
324Compound are aggregation of type declarations. Compound types include
325structures, variant, arrays, sequences, and strings.
326
5ba9f198
MD
3274.2.1 Structures
328
329Structures are aligned on the largest alignment required by basic types
330contained within the structure. (This follows the ISO/C standard for structures)
331
6672e9e1 332TSDL meta-data representation of a named structure:
5ba9f198 333
80fd2569
MD
334struct name {
335 field_type field_name;
336 field_type field_name;
337 ...
338};
5ba9f198
MD
339
340Example:
341
80fd2569
MD
342struct example {
343 integer { /* Nameless type */
344 size = 16;
345 signed = true;
346 align = 16;
347 } first_field_name;
6672e9e1 348 uint64_t second_field_name; /* Named type declared in the meta-data */
3bf79539 349};
5ba9f198
MD
350
351The fields are placed in a sequence next to each other. They each possess a
352field name, which is a unique identifier within the structure.
353
2152348f 354A nameless structure can be declared as a field type or as part of a typedef:
80fd2569
MD
355
356struct {
357 ...
2152348f 358}
80fd2569 359
77a98c82 3604.2.2 Variants (Discriminated/Tagged Unions)
fcba70d4 361
fdf2bb05
MD
362A CTF variant is a selection between different types. A CTF variant must
363always be defined within the scope of a structure or within fields
364contained within a structure (defined recursively). A "tag" enumeration
365field must appear in either the same lexical scope, prior to the variant
366field (in field declaration order), in an uppermost lexical scope (see
6c7226e9 367Section 7.3.1), or in an uppermost dynamic scope (see Section 7.3.2).
fdf2bb05
MD
368The type selection is indicated by the mapping from the enumeration
369value to the string used as variant type selector. The field to use as
370tag is specified by the "tag_field", specified between "< >" after the
371"variant" keyword for unnamed variants, and after "variant name" for
372named variants.
fcba70d4
MD
373
374The alignment of the variant is the alignment of the type as selected by the tag
375value for the specific instance of the variant. The alignment of the type
376containing the variant is independent of the variant alignment. The size of the
377variant is the size as selected by the tag value for the specific instance of
378the variant.
379
380A named variant declaration followed by its definition within a structure
381declaration:
382
383variant name {
384 field_type sel1;
385 field_type sel2;
386 field_type sel3;
387 ...
388};
389
390struct {
a9b83695 391 enum : integer_type { sel1, sel2, sel3, ... } tag_field;
fcba70d4
MD
392 ...
393 variant name <tag_field> v;
394}
395
396An unnamed variant definition within a structure is expressed by the following
6672e9e1 397TSDL meta-data:
fcba70d4
MD
398
399struct {
a9b83695 400 enum : integer_type { sel1, sel2, sel3, ... } tag_field;
fcba70d4
MD
401 ...
402 variant <tag_field> {
403 field_type sel1;
404 field_type sel2;
405 field_type sel3;
406 ...
407 } v;
408}
409
410Example of a named variant within a sequence that refers to a single tag field:
411
412variant example {
413 uint32_t a;
414 uint64_t b;
415 short c;
416};
417
418struct {
a9b83695 419 enum : uint2_t { a, b, c } choice;
15850440 420 variant example <choice> v[unsigned int];
fcba70d4
MD
421}
422
423Example of an unnamed variant:
424
425struct {
a9b83695 426 enum : uint2_t { a, b, c, d } choice;
fcba70d4
MD
427 /* Unrelated fields can be added between the variant and its tag */
428 int32_t somevalue;
429 variant <choice> {
430 uint32_t a;
431 uint64_t b;
432 short c;
433 struct {
434 unsigned int field1;
435 uint64_t field2;
436 } d;
437 } s;
438}
439
440Example of an unnamed variant within an array:
441
442struct {
a9b83695 443 enum : uint2_t { a, b, c } choice;
fcba70d4
MD
444 variant <choice> {
445 uint32_t a;
446 uint64_t b;
447 short c;
15850440 448 } v[10];
fcba70d4
MD
449}
450
451Example of a variant type definition within a structure, where the defined type
452is then declared within an array of structures. This variant refers to a tag
453located in an upper lexical scope. This example clearly shows that a variant
454type definition referring to the tag "x" uses the closest preceding field from
455the lexical scope of the type definition.
456
457struct {
a9b83695 458 enum : uint2_t { a, b, c, d } x;
fcba70d4
MD
459
460 typedef variant <x> { /*
461 * "x" refers to the preceding "x" enumeration in the
462 * lexical scope of the type definition.
463 */
464 uint32_t a;
465 uint64_t b;
466 short c;
467 } example_variant;
468
469 struct {
a9b83695 470 enum : int { x, y, z } x; /* This enumeration is not used by "v". */
fcba70d4 471 example_variant v; /*
a9b83695 472 * "v" uses the "enum : uint2_t { a, b, c, d }"
fcba70d4
MD
473 * tag.
474 */
475 } a[10];
476}
477
4784.2.3 Arrays
5ba9f198 479
6672e9e1
MD
480Arrays are fixed-length. Their length is declared in the type
481declaration within the meta-data. They contain an array of "inner type"
482elements, which can refer to any type not containing the type of the
483array being declared (no circular dependency). The length is the number
484of elements in an array.
5ba9f198 485
6672e9e1 486TSDL meta-data representation of a named array:
80fd2569
MD
487
488typedef elem_type name[length];
5ba9f198 489
2152348f 490A nameless array can be declared as a field type within a structure, e.g.:
5ba9f198 491
2152348f 492 uint8_t field_name[10];
80fd2569 493
5ba9f198 494
fcba70d4 4954.2.4 Sequences
5ba9f198
MD
496
497Sequences are dynamically-sized arrays. They start with an integer that specify
498the length of the sequence, followed by an array of "inner type" elements.
3bf79539 499The length is the number of elements in the sequence.
5ba9f198 500
6672e9e1 501TSDL meta-data representation for a named sequence:
80fd2569
MD
502
503typedef elem_type name[length_type];
504
505A nameless sequence can be declared as a field type, e.g.:
506
80fd2569
MD
507long field_name[int];
508
509The length type follows the integer types specifications, and the sequence
5ba9f198
MD
510elements follow the "array" specifications.
511
fcba70d4 5124.2.5 Strings
5ba9f198
MD
513
514Strings are an array of bytes of variable size and are terminated by a '\0'
6672e9e1
MD
515"NULL" character. Their encoding is described in the TSDL meta-data. In
516absence of encoding attribute information, the default encoding is
517UTF-8.
5ba9f198 518
6672e9e1 519TSDL meta-data representation of a named string type:
80fd2569 520
359894ac 521typealias string {
5ba9f198 522 encoding = UTF8 OR ASCII;
38b8da21 523} := name;
5ba9f198 524
80fd2569
MD
525A nameless string type can be declared as a field type:
526
527string field_name; /* Use default UTF8 encoding */
5ba9f198 528
3bf79539
MD
5295. Event Packet Header
530
6672e9e1
MD
531The event packet header consists of two parts: the "event packet header"
532is the same for all streams of a trace. The second part, the "event
533packet context", is described on a per-stream basis. Both are described
534in the TSDL meta-data. The packets are aligned on architecture-page-sized
535addresses.
3bf79539 536
6672e9e1 537Event packet header (all fields are optional, specified by TSDL meta-data):
3bf79539 538
6672e9e1
MD
539- Magic number (CTF magic number: 0xC1FC1FC1) specifies that this is a
540 CTF packet. This magic number is optional, but when present, it should
541 come at the very beginning of the packet.
542- Trace UUID, used to ensure the event packet match the meta-data used.
543 (note: we cannot use a meta-data checksum in every cases instead of a
544 UUID because meta-data can be appended to while tracing is active)
545 This field is optional.
546- Stream ID, used as reference to stream description in meta-data.
547 This field is optional if there is only one stream description in the
548 meta-data, but becomes required if there are more than one stream in
549 the TSDL meta-data description.
3bf79539 550
6672e9e1 551Event packet context (all fields are optional, specified by TSDL meta-data):
3bf79539
MD
552
553- Event packet content size (in bytes).
554- Event packet size (in bytes, includes padding).
555- Event packet content checksum (optional). Checksum excludes the event packet
556 header.
557- Per-stream event packet sequence count (to deal with UDP packet loss). The
558 number of significant sequence counter bits should also be present, so
b11853af 559 wrap-arounds are dealt with correctly.
6672e9e1 560- Time-stamp at the beginning and time-stamp at the end of the event packet.
3bf79539
MD
561 Both timestamps are written in the packet header, but sampled respectively
562 while (or before) writing the first event and while (or after) writing the
563 last event in the packet. The inclusive range between these timestamps should
564 include all event timestamps assigned to events contained within the packet.
5ba9f198 565- Events discarded count
3bf79539
MD
566 - Snapshot of a per-stream free-running counter, counting the number of
567 events discarded that were supposed to be written in the stream prior to
568 the first event in the event packet.
5ba9f198 569 * Note: producer-consumer buffer full condition should fill the current
3bf79539 570 event packet with padding so we know exactly where events have been
5ba9f198 571 discarded.
3bf79539
MD
572- Lossless compression scheme used for the event packet content. Applied
573 directly to raw data. New types of compression can be added in following
574 versions of the format.
5ba9f198
MD
575 0: no compression scheme
576 1: bzip2
577 2: gzip
3bf79539
MD
578 3: xz
579- Cypher used for the event packet content. Applied after compression.
5ba9f198
MD
580 0: no encryption
581 1: AES
3bf79539 582- Checksum scheme used for the event packet content. Applied after encryption.
5ba9f198
MD
583 0: no checksum
584 1: md5
585 2: sha1
586 3: crc32
587
6672e9e1 5885.1 Event Packet Header Description
3bf79539 589
fc5425db 590The event packet header layout is indicated by the trace packet.header
6672e9e1
MD
591field. Here is a recommended structure type for the packet header with
592the fields typically expected (although these fields are each optional):
fc5425db 593
80fd2569
MD
594struct event_packet_header {
595 uint32_t magic;
596 uint8_t trace_uuid[16];
3bf79539 597 uint32_t stream_id;
80fd2569 598};
5ba9f198 599
fc5425db
MD
600trace {
601 ...
602 packet.header := struct event_packet_header;
603};
604
6672e9e1
MD
605If the magic number is not present, tools such as "file" will have no
606mean to discover the file type.
607
608If the trace_uuid is not present, no validation that the meta-data
37b39e47
MD
609actually corresponds to the stream is performed.
610
611If the stream_id packet header field is missing, the trace can only
612contain a single stream. Its "id" field can be left out, and its events
613don't need to declare a "stream_id" field.
614
615
3bf79539
MD
6165.2 Event Packet Context Description
617
618Event packet context example. These are declared within the stream declaration
6672e9e1 619in the meta-data. All these fields are optional. If the packet size field is
6a7c61df 620missing, the whole stream only contains a single packet. If the content
f6b81726
MD
621size field is missing, the packet is filled (no padding). The content
622and packet sizes include all headers.
3bf79539
MD
623
624An example event packet context type:
625
80fd2569 626struct event_packet_context {
3bf79539
MD
627 uint64_t timestamp_begin;
628 uint64_t timestamp_end;
629 uint32_t checksum;
630 uint32_t stream_packet_count;
631 uint32_t events_discarded;
632 uint32_t cpu_id;
633 uint32_t/uint16_t content_size;
634 uint32_t/uint16_t packet_size;
635 uint8_t stream_packet_count_bits; /* Significant counter bits */
636 uint8_t compression_scheme;
637 uint8_t encryption_scheme;
3b0f8e4d 638 uint8_t checksum_scheme;
3bf79539 639};
5ba9f198 640
fcba70d4 641
5ba9f198
MD
6426. Event Structure
643
644The overall structure of an event is:
645
6672e9e1
MD
6461 - Stream Packet Context (as specified by the stream meta-data)
647 2 - Event Header (as specified by the stream meta-data)
648 3 - Stream Event Context (as specified by the stream meta-data)
649 4 - Event Context (as specified by the event meta-data)
650 5 - Event Payload (as specified by the event meta-data)
5ba9f198 651
fdf2bb05 652This structure defines an implicit dynamic scoping, where variants
7d9d7e92
MD
653located in inner structures (those with a higher number in the listing
654above) can refer to the fields of outer structures (with lower number in
6c7226e9 655the listing above). See Section 7.3 TSDL Scopes for more detail.
5ba9f198 656
fdf2bb05 6576.1 Event Header
fcba70d4 658
6672e9e1 659Event headers can be described within the meta-data. We hereby propose, as an
fcba70d4
MD
660example, two types of events headers. Type 1 accommodates streams with less than
66131 event IDs. Type 2 accommodates streams with 31 or more event IDs.
5ba9f198 662
3bf79539
MD
663One major factor can vary between streams: the number of event IDs assigned to
664a stream. Luckily, this information tends to stay relatively constant (modulo
5ba9f198 665event registration while trace is being recorded), so we can specify different
3bf79539 666representations for streams containing few event IDs and streams containing
6672e9e1
MD
667many event IDs, so we end up representing the event ID and time-stamp as
668densely as possible in each case.
5ba9f198 669
fcba70d4
MD
670The header is extended in the rare occasions where the information cannot be
671represented in the ranges available in the standard event header. They are also
3bf79539
MD
672used in the rare occasions where the data required for a field could not be
673collected: the flag corresponding to the missing field within the missing_fields
674array is then set to 1.
5ba9f198 675
6672e9e1
MD
676Types uintX_t represent an X-bit unsigned integer, as declared with
677either:
5ba9f198 678
6672e9e1
MD
679 typealias integer { size = X; align = X; signed = false } := uintX_t;
680
681 or
682
683 typealias integer { size = X; align = 1; signed = false } := uintX_t;
5ba9f198 684
fdf2bb05 6856.1.1 Type 1 - Few event IDs
5ba9f198
MD
686
687 - Aligned on 32-bit (or 8-bit if byte-packed, depending on the architecture
688 preference).
5ba9f198 689 - Native architecture byte ordering.
fcba70d4
MD
690 - For "compact" selection
691 - Fixed size: 32 bits.
692 - For "extended" selection
693 - Size depends on the architecture and variant alignment.
5ba9f198 694
80fd2569 695struct event_header_1 {
fcba70d4
MD
696 /*
697 * id: range: 0 - 30.
698 * id 31 is reserved to indicate an extended header.
699 */
a9b83695 700 enum : uint5_t { compact = 0 ... 30, extended = 31 } id;
fcba70d4
MD
701 variant <id> {
702 struct {
703 uint27_t timestamp;
704 } compact;
705 struct {
706 uint32_t id; /* 32-bit event IDs */
707 uint64_t timestamp; /* 64-bit timestamps */
708 } extended;
709 } v;
5ba9f198
MD
710};
711
5ba9f198 712
fdf2bb05 7136.1.2 Type 2 - Many event IDs
5ba9f198 714
fcba70d4 715 - Aligned on 16-bit (or 8-bit if byte-packed, depending on the architecture
5ba9f198 716 preference).
5ba9f198 717 - Native architecture byte ordering.
fcba70d4
MD
718 - For "compact" selection
719 - Size depends on the architecture and variant alignment.
720 - For "extended" selection
721 - Size depends on the architecture and variant alignment.
5ba9f198 722
80fd2569 723struct event_header_2 {
fcba70d4
MD
724 /*
725 * id: range: 0 - 65534.
726 * id 65535 is reserved to indicate an extended header.
727 */
a9b83695 728 enum : uint16_t { compact = 0 ... 65534, extended = 65535 } id;
fcba70d4
MD
729 variant <id> {
730 struct {
731 uint32_t timestamp;
732 } compact;
733 struct {
734 uint32_t id; /* 32-bit event IDs */
735 uint64_t timestamp; /* 64-bit timestamps */
736 } extended;
737 } v;
5ba9f198
MD
738};
739
5ba9f198
MD
740
7416.2 Event Context
742
6672e9e1
MD
743The event context contains information relative to the current event.
744The choice and meaning of this information is specified by the TSDL
745stream and event meta-data descriptions. The stream context is applied
746to all events within the stream. The stream context structure follows
747the event header. The event context is applied to specific events. Its
748structure follows the stream context structure.
5ba9f198 749
fcba70d4
MD
750An example of stream-level event context is to save the event payload size with
751each event, or to save the current PID with each event. These are declared
6672e9e1 752within the stream declaration within the meta-data:
5ba9f198 753
fcba70d4
MD
754 stream {
755 ...
6672e9e1 756 event.context := struct {
80fd2569
MD
757 uint pid;
758 uint16_t payload_size;
6672e9e1 759 };
fcba70d4
MD
760 };
761
762An example of event-specific event context is to declare a bitmap of missing
763fields, only appended after the stream event context if the extended event
764header is selected. NR_FIELDS is the number of fields within the event (a
765numeric value).
5ba9f198 766
fcba70d4
MD
767 event {
768 context = struct {
769 variant <id> {
770 struct { } compact;
771 struct {
772 uint1_t missing_fields[NR_FIELDS]; /* missing event fields bitmap */
773 } extended;
774 } v;
775 };
776 ...
777 }
5ba9f198
MD
778
7796.3 Event Payload
780
781An event payload contains fields specific to a given event type. The fields
6672e9e1 782belonging to an event type are described in the event-specific meta-data
5ba9f198
MD
783within a structure type.
784
7856.3.1 Padding
786
787No padding at the end of the event payload. This differs from the ISO/C standard
788for structures, but follows the CTF standard for structures. In a trace, even
789though it makes sense to align the beginning of a structure, it really makes no
790sense to add padding at the end of the structure, because structures are usually
791not followed by a structure of the same type.
792
793This trick can be done by adding a zero-length "end" field at the end of the C
794structures, and by using the offset of this field rather than using sizeof()
3bf79539 795when calculating the size of a structure (see Appendix "A. Helper macros").
5ba9f198
MD
796
7976.3.2 Alignment
798
799The event payload is aligned on the largest alignment required by types
800contained within the payload. (This follows the ISO/C standard for structures)
801
802
6c7226e9
MD
8037. Trace Stream Description Language (TSDL)
804
805The Trace Stream Description Language (TSDL) allows expression of the
806binary trace streams layout in a C99-like Domain Specific Language
807(DSL).
808
809
6672e9e1 8107.1 Meta-data
6c7226e9
MD
811
812The trace stream layout description is located in the trace meta-data.
813The meta-data is itself located in a stream identified by its name:
814"metadata".
5ba9f198 815
6672e9e1
MD
816The meta-data description can be expressed in two different formats:
817text-only and packet-based. The text-only description facilitates
818generation of meta-data and provides a convenient way to enter the
819meta-data information by hand. The packet-based meta-data provides the
820CTF stream packet facilities (checksumming, compression, encryption,
821network-readiness) for meta-data stream generated and transported by a
822tracer.
823
824The text-only meta-data file is a plain text TSDL description.
825
826The packet-based meta-data is made of "meta-data packets", which each
827start with a meta-data packet header. The packet-based meta-data
828description is detected by reading the magic number "0x75D11D57" at the
829beginning of the file. This magic number is also used to detect the
830endianness of the architecture by trying to read the CTF magic number
831and its counterpart in reversed endianness. The events within the
832meta-data stream have no event header nor event context. Each event only
833contains a "string" payload. Each meta-data packet start with a special
834packet header, specific to the meta-data stream, which contains,
835exactly:
836
837struct metadata_packet_header {
838 uint32_t magic; /* 0x3FF1C105 */
839 uint8_t trace_uuid[16]; /* Unique Universal Identifier */
840 uint32_t checksum; /* 0 if unused */
841 uint32_t content_size; /* in bits */
842 uint32_t packet_size; /* in bits */
843 uint8_t compression_scheme; /* 0 if unused */
844 uint8_t encryption_scheme; /* 0 if unused */
845 uint8_t checksum_scheme; /* 0 if unused */
846};
847
848The packet-based meta-data can be converted to a text-only meta-data by
849concatenating all the strings in contains.
4fafe1ad 850
6672e9e1
MD
851In the textual representation of the meta-data, the text contained
852within "/*" and "*/", as well as within "//" and end of line, are
853treated as comments. Boolean values can be represented as true, TRUE,
854or 1 for true, and false, FALSE, or 0 for false. Within the string-based
855meta-data description, the trace UUID is represented as a string of
856hexadecimal digits and dashes "-". In the event packet header, the trace
857UUID is represented as an array of bytes.
fcba70d4 858
fdf2bb05 859
6c7226e9 8607.2 Declaration vs Definition
fdf2bb05
MD
861
862A declaration associates a layout to a type, without specifying where
863this type is located in the event structure hierarchy (see Section 6).
864This therefore includes typedef, typealias, as well as all type
865specifiers. In certain circumstances (typedef, structure field and
866variant field), a declaration is followed by a declarator, which specify
867the newly defined type name (for typedef), or the field name (for
868declarations located within structure and variants). Array and sequence,
869declared with square brackets ("[" "]"), are part of the declarator,
a9b83695 870similarly to C99. The enumeration base type is specified by
6c7226e9 871": enum_base", which is part of the type specifier. The variant tag
a9b83695 872name, specified between "<" ">", is also part of the type specifier.
fdf2bb05
MD
873
874A definition associates a type to a location in the event structure
b9606a77
MD
875hierarchy (see Section 6). This association is denoted by ":=", as shown
876in Section 7.3.
fdf2bb05
MD
877
878
6c7226e9 8797.3 TSDL Scopes
fdf2bb05 880
6c7226e9
MD
881TSDL uses two different types of scoping: a lexical scope is used for
882declarations and type definitions, and a dynamic scope is used for
883variants references to tag fields.
fdf2bb05 884
6c7226e9 8857.3.1 Lexical Scope
fdf2bb05 886
d285084f
MD
887Each of "trace", "stream", "event", "struct" and "variant" have their own
888nestable declaration scope, within which types can be declared using "typedef"
fdf2bb05 889and "typealias". A root declaration scope also contains all declarations
7d9d7e92 890located outside of any of the aforementioned declarations. An inner
fdf2bb05 891declaration scope can refer to type declared within its container
7d9d7e92
MD
892lexical scope prior to the inner declaration scope. Redefinition of a
893typedef or typealias is not valid, although hiding an upper scope
fdf2bb05
MD
894typedef or typealias is allowed within a sub-scope.
895
6c7226e9 8967.3.2 Dynamic Scope
fdf2bb05 897
7d9d7e92
MD
898A dynamic scope consists in the lexical scope augmented with the
899implicit event structure definition hierarchy presented at Section 6.
900The dynamic scope is only used for variant tag definitions. It is used
901at definition time to look up the location of the tag field associated
902with a variant.
903
904Therefore, variants in lower levels in the dynamic scope (e.g. event
905context) can refer to a tag field located in upper levels (e.g. in the
906event header) by specifying, in this case, the associated tag with
907<header.field_name>. This allows, for instance, the event context to
908define a variant referring to the "id" field of the event header as
909selector.
fdf2bb05
MD
910
911The target dynamic scope must be specified explicitly when referring to
912a field outside of the local static scope. The dynamic scope prefixes
913are thus:
914
e0d9e2c7 915 - Trace Packet Header: <trace.packet.header. >,
7d9d7e92
MD
916 - Stream Packet Context: <stream.packet.context. >,
917 - Event Header: <stream.event.header. >,
918 - Stream Event Context: <stream.event.context. >,
919 - Event Context: <event.context. >,
920 - Event Payload: <event.fields. >.
fdf2bb05
MD
921
922Multiple declarations of the same field name within a single scope is
923not valid. It is however valid to re-use the same field name in
924different scopes. There is no possible conflict, because the dynamic
925scope must be specified when a variant refers to a tag field located in
926a different dynamic scope.
927
457d8b0a
MD
928The information available in the dynamic scopes can be thought of as the
929current tracing context. At trace production, information about the
930current context is saved into the specified scope field levels. At trace
931consumption, for each event, the current trace context is therefore
932readable by accessing the upper dynamic scopes.
933
fdf2bb05 934
6c7226e9 9357.4 TSDL Examples
d285084f 936
6672e9e1 937The grammar representing the TSDL meta-data is presented in Appendix C.
7df6b93a 938TSDL Grammar. This section presents a rather lighter reading that
6672e9e1 939consists in examples of TSDL meta-data, with template values.
969f30c0 940
350bb633
MD
941The stream "id" can be left out if there is only one stream in the
942trace. The event "id" field can be left out if there is only one event
943in a stream.
944
5ba9f198 945trace {
fdf2bb05 946 major = value; /* Trace format version */
5ba9f198 947 minor = value;
fdf2bb05 948 uuid = "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"; /* Trace UUID */
58997e9e 949 byte_order = be OR le; /* Endianness (required) */
fc5425db
MD
950 packet.header := struct {
951 uint32_t magic;
952 uint8_t trace_uuid[16];
953 uint32_t stream_id;
954 };
3bf79539 955};
5ba9f198 956
3bf79539
MD
957stream {
958 id = stream_id;
fdf2bb05 959 /* Type 1 - Few event IDs; Type 2 - Many event IDs. See section 6.1. */
4fa992a5
MD
960 event.header := event_header_1 OR event_header_2;
961 event.context := struct {
77a98c82 962 ...
3bf79539 963 };
4fa992a5 964 packet.context := struct {
77a98c82 965 ...
3bf79539
MD
966 };
967};
5ba9f198
MD
968
969event {
3d13ef1a 970 name = event_name;
3bf79539
MD
971 id = value; /* Numeric identifier within the stream */
972 stream = stream_id;
4fa992a5 973 context := struct {
fcba70d4
MD
974 ...
975 };
4fa992a5 976 fields := struct {
80fd2569
MD
977 ...
978 };
3bf79539 979};
5ba9f198
MD
980
981/* More detail on types in section 4. Types */
982
3d13ef1a
MD
983/*
984 * Named types:
985 *
4fa992a5 986 * Type declarations behave similarly to the C standard.
3d13ef1a
MD
987 */
988
80af8ac6 989typedef aliased_type_specifiers new_type_declarators;
2152348f 990
3d13ef1a 991/* e.g.: typedef struct example new_type_name[10]; */
80fd2569 992
4fa992a5
MD
993/*
994 * typealias
995 *
996 * The "typealias" declaration can be used to give a name (including
80af8ac6
MD
997 * pointer declarator specifier) to a type. It should also be used to
998 * map basic C types (float, int, unsigned long, ...) to a CTF type.
999 * Typealias is a superset of "typedef": it also allows assignment of a
38b8da21 1000 * simple variable identifier to a type.
4fa992a5
MD
1001 */
1002
1003typealias type_class {
80fd2569 1004 ...
38b8da21 1005} := type_specifiers type_declarator;
2152348f 1006
3d13ef1a
MD
1007/*
1008 * e.g.:
4fa992a5 1009 * typealias integer {
3d13ef1a
MD
1010 * size = 32;
1011 * align = 32;
1012 * signed = false;
38b8da21 1013 * } := struct page *;
359894ac
MD
1014 *
1015 * typealias integer {
1016 * size = 32;
1017 * align = 32;
1018 * signed = true;
38b8da21 1019 * } := int;
3d13ef1a 1020 */
80fd2569
MD
1021
1022struct name {
3bf79539
MD
1023 ...
1024};
5ba9f198 1025
fcba70d4
MD
1026variant name {
1027 ...
1028};
1029
a9b83695 1030enum name : integer_type {
3bf79539
MD
1031 ...
1032};
1033
2152348f 1034
4fa992a5
MD
1035/*
1036 * Unnamed types, contained within compound type fields, typedef or typealias.
1037 */
2152348f 1038
80fd2569
MD
1039struct {
1040 ...
2152348f 1041}
5ba9f198 1042
fcba70d4
MD
1043variant {
1044 ...
1045}
1046
a9b83695 1047enum : integer_type {
80fd2569 1048 ...
2152348f
MD
1049}
1050
1051typedef type new_type[length];
3bf79539 1052
2152348f
MD
1053struct {
1054 type field_name[length];
1055}
1056
1057typedef type new_type[length_type];
1058
1059struct {
1060 type field_name[length_type];
1061}
1062
1063integer {
80fd2569 1064 ...
2152348f 1065}
3bf79539 1066
2152348f 1067floating_point {
80fd2569 1068 ...
2152348f
MD
1069}
1070
1071struct {
1072 integer_type field_name:size; /* GNU/C bitfield */
1073}
1074
1075struct {
1076 string field_name;
1077}
3bf79539 1078
fcba70d4 1079
3bf79539 1080A. Helper macros
5ba9f198
MD
1081
1082The two following macros keep track of the size of a GNU/C structure without
1083padding at the end by placing HEADER_END as the last field. A one byte end field
1084is used for C90 compatibility (C99 flexible arrays could be used here). Note
1085that this does not affect the effective structure size, which should always be
1086calculated with the header_sizeof() helper.
1087
1088#define HEADER_END char end_field
1089#define header_sizeof(type) offsetof(typeof(type), end_field)
3bf79539
MD
1090
1091
1092B. Stream Header Rationale
1093
1094An event stream is divided in contiguous event packets of variable size. These
1095subdivisions allow the trace analyzer to perform a fast binary search by time
1096within the stream (typically requiring to index only the event packet headers)
1097without reading the whole stream. These subdivisions have a variable size to
1098eliminate the need to transfer the event packet padding when partially filled
1099event packets must be sent when streaming a trace for live viewing/analysis.
1100An event packet can contain a certain amount of padding at the end. Dividing
1101streams into event packets is also useful for network streaming over UDP and
1102flight recorder mode tracing (a whole event packet can be swapped out of the
1103buffer atomically for reading).
1104
1105The stream header is repeated at the beginning of each event packet to allow
1106flexibility in terms of:
1107
1108 - streaming support,
1109 - allowing arbitrary buffers to be discarded without making the trace
1110 unreadable,
1111 - allow UDP packet loss handling by either dealing with missing event packet
1112 or asking for re-transmission.
1113 - transparently support flight recorder mode,
1114 - transparently support crash dump.
1115
6c7226e9
MD
1116
1117C. TSDL Grammar
fcba70d4 1118
4fa992a5 1119/*
6c7226e9 1120 * Common Trace Format (CTF) Trace Stream Description Language (TSDL) Grammar.
4fa992a5
MD
1121 *
1122 * Inspired from the C99 grammar:
1123 * http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf (Annex A)
6c7226e9
MD
1124 * and c++1x grammar (draft)
1125 * http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3291.pdf (Annex A)
4fa992a5
MD
1126 *
1127 * Specialized for CTF needs by including only constant and declarations from
1128 * C99 (excluding function declarations), and by adding support for variants,
6c7226e9
MD
1129 * sequences and CTF-specific specifiers. Enumeration container types
1130 * semantic is inspired from c++1x enum-base.
4fa992a5
MD
1131 */
1132
11331) Lexical grammar
1134
11351.1) Lexical elements
1136
1137token:
1138 keyword
1139 identifier
1140 constant
1141 string-literal
1142 punctuator
1143
11441.2) Keywords
1145
1146keyword: is one of
1147
1148const
1149char
1150double
1151enum
1152event
1153floating_point
1154float
1155integer
1156int
1157long
1158short
1159signed
1160stream
1161string
1162struct
1163trace
3e1e1a78 1164typealias
4fa992a5
MD
1165typedef
1166unsigned
1167variant
1168void
1169_Bool
1170_Complex
1171_Imaginary
1172
1173
11741.3) Identifiers
1175
1176identifier:
1177 identifier-nondigit
1178 identifier identifier-nondigit
1179 identifier digit
1180
1181identifier-nondigit:
1182 nondigit
1183 universal-character-name
1184 any other implementation-defined characters
1185
1186nondigit:
1187 _
1188 [a-zA-Z] /* regular expression */
1189
1190digit:
1191 [0-9] /* regular expression */
1192
11931.4) Universal character names
1194
1195universal-character-name:
1196 \u hex-quad
1197 \U hex-quad hex-quad
1198
1199hex-quad:
1200 hexadecimal-digit hexadecimal-digit hexadecimal-digit hexadecimal-digit
1201
12021.5) Constants
1203
1204constant:
1205 integer-constant
1206 enumeration-constant
1207 character-constant
1208
1209integer-constant:
1210 decimal-constant integer-suffix-opt
1211 octal-constant integer-suffix-opt
1212 hexadecimal-constant integer-suffix-opt
1213
1214decimal-constant:
1215 nonzero-digit
1216 decimal-constant digit
1217
1218octal-constant:
1219 0
1220 octal-constant octal-digit
1221
1222hexadecimal-constant:
1223 hexadecimal-prefix hexadecimal-digit
1224 hexadecimal-constant hexadecimal-digit
1225
1226hexadecimal-prefix:
1227 0x
1228 0X
1229
1230nonzero-digit:
1231 [1-9]
1232
1233integer-suffix:
1234 unsigned-suffix long-suffix-opt
1235 unsigned-suffix long-long-suffix
1236 long-suffix unsigned-suffix-opt
1237 long-long-suffix unsigned-suffix-opt
1238
1239unsigned-suffix:
1240 u
1241 U
1242
1243long-suffix:
1244 l
1245 L
1246
1247long-long-suffix:
1248 ll
1249 LL
1250
1251digit-sequence:
1252 digit
1253 digit-sequence digit
1254
1255hexadecimal-digit-sequence:
1256 hexadecimal-digit
1257 hexadecimal-digit-sequence hexadecimal-digit
1258
1259enumeration-constant:
1260 identifier
1261 string-literal
1262
1263character-constant:
1264 ' c-char-sequence '
1265 L' c-char-sequence '
1266
1267c-char-sequence:
1268 c-char
1269 c-char-sequence c-char
1270
1271c-char:
1272 any member of source charset except single-quote ('), backslash
1273 (\), or new-line character.
1274 escape-sequence
1275
1276escape-sequence:
1277 simple-escape-sequence
1278 octal-escape-sequence
1279 hexadecimal-escape-sequence
1280 universal-character-name
1281
1282simple-escape-sequence: one of
1283 \' \" \? \\ \a \b \f \n \r \t \v
1284
1285octal-escape-sequence:
1286 \ octal-digit
1287 \ octal-digit octal-digit
1288 \ octal-digit octal-digit octal-digit
1289
1290hexadecimal-escape-sequence:
1291 \x hexadecimal-digit
1292 hexadecimal-escape-sequence hexadecimal-digit
1293
12941.6) String literals
1295
1296string-literal:
1297 " s-char-sequence-opt "
1298 L" s-char-sequence-opt "
1299
1300s-char-sequence:
1301 s-char
1302 s-char-sequence s-char
1303
1304s-char:
1305 any member of source charset except double-quote ("), backslash
1306 (\), or new-line character.
1307 escape-sequence
1308
13091.7) Punctuators
1310
1311punctuator: one of
1312 [ ] ( ) { } . -> * + - < > : ; ... = ,
1313
1314
13152) Phrase structure grammar
1316
1317primary-expression:
1318 identifier
1319 constant
1320 string-literal
1321 ( unary-expression )
1322
1323postfix-expression:
1324 primary-expression
1325 postfix-expression [ unary-expression ]
1326 postfix-expression . identifier
1327 postfix-expressoin -> identifier
1328
1329unary-expression:
1330 postfix-expression
1331 unary-operator postfix-expression
1332
1333unary-operator: one of
1334 + -
1335
4fa992a5
MD
1336assignment-operator:
1337 =
1338
b9606a77
MD
1339type-assignment-operator:
1340 :=
1341
4fa992a5
MD
1342constant-expression:
1343 unary-expression
1344
1345constant-expression-range:
1346 constant-expression ... constant-expression
1347
13482.2) Declarations:
1349
1350declaration:
689e04b4 1351 declaration-specifiers declarator-list-opt ;
4fa992a5
MD
1352 ctf-specifier ;
1353
1354declaration-specifiers:
689e04b4 1355 storage-class-specifier declaration-specifiers-opt
4fa992a5
MD
1356 type-specifier declaration-specifiers-opt
1357 type-qualifier declaration-specifiers-opt
1358
1359declarator-list:
1360 declarator
1361 declarator-list , declarator
1362
d285084f
MD
1363abstract-declarator-list:
1364 abstract-declarator
1365 abstract-declarator-list , abstract-declarator
1366
4fa992a5
MD
1367storage-class-specifier:
1368 typedef
1369
1370type-specifier:
1371 void
1372 char
1373 short
1374 int
1375 long
1376 float
1377 double
1378 signed
1379 unsigned
1380 _Bool
1381 _Complex
cfdd51ec 1382 _Imaginary
9dfcfc0f
MD
1383 struct-specifier
1384 variant-specifier
4fa992a5
MD
1385 enum-specifier
1386 typedef-name
1387 ctf-type-specifier
1388
1389struct-specifier:
3b0f8e4d 1390 struct identifier-opt { struct-or-variant-declaration-list-opt }
4fa992a5
MD
1391 struct identifier
1392
1393struct-or-variant-declaration-list:
1394 struct-or-variant-declaration
1395 struct-or-variant-declaration-list struct-or-variant-declaration
1396
1397struct-or-variant-declaration:
1398 specifier-qualifier-list struct-or-variant-declarator-list ;
550aca33 1399 declaration-specifiers storage-class-specifier declaration-specifiers declarator-list ;
38b8da21
MD
1400 typealias declaration-specifiers abstract-declarator-list := declaration-specifiers abstract-declarator-list ;
1401 typealias declaration-specifiers abstract-declarator-list := declarator-list ;
4fa992a5
MD
1402
1403specifier-qualifier-list:
1404 type-specifier specifier-qualifier-list-opt
1405 type-qualifier specifier-qualifier-list-opt
1406
1407struct-or-variant-declarator-list:
1408 struct-or-variant-declarator
1409 struct-or-variant-declarator-list , struct-or-variant-declarator
1410
1411struct-or-variant-declarator:
1412 declarator
1413 declarator-opt : constant-expression
1414
1415variant-specifier:
1416 variant identifier-opt variant-tag-opt { struct-or-variant-declaration-list }
1417 variant identifier variant-tag
1418
1419variant-tag:
1420 < identifier >
1421
1422enum-specifier:
1423 enum identifier-opt { enumerator-list }
1424 enum identifier-opt { enumerator-list , }
1425 enum identifier
a9b83695
MD
1426 enum identifier-opt : declaration-specifiers { enumerator-list }
1427 enum identifier-opt : declaration-specifiers { enumerator-list , }
4fa992a5
MD
1428
1429enumerator-list:
1430 enumerator
1431 enumerator-list , enumerator
1432
1433enumerator:
1434 enumeration-constant
1435 enumeration-constant = constant-expression
1436 enumeration-constant = constant-expression-range
1437
1438type-qualifier:
1439 const
1440
1441declarator:
1442 pointer-opt direct-declarator
1443
1444direct-declarator:
1445 identifier
1446 ( declarator )
1447 direct-declarator [ type-specifier ]
1448 direct-declarator [ constant-expression ]
1449
d285084f
MD
1450abstract-declarator:
1451 pointer-opt direct-abstract-declarator
1452
1453direct-abstract-declarator:
1454 identifier-opt
1455 ( abstract-declarator )
1456 direct-abstract-declarator [ type-specifier ]
1457 direct-abstract-declarator [ constant-expression ]
1458 direct-abstract-declarator [ ]
1459
4fa992a5 1460pointer:
3b0f8e4d
MD
1461 * type-qualifier-list-opt
1462 * type-qualifier-list-opt pointer
4fa992a5
MD
1463
1464type-qualifier-list:
1465 type-qualifier
1466 type-qualifier-list type-qualifier
1467
4fa992a5
MD
1468typedef-name:
1469 identifier
1470
14712.3) CTF-specific declarations
1472
1473ctf-specifier:
1474 event { ctf-assignment-expression-list-opt }
1475 stream { ctf-assignment-expression-list-opt }
1476 trace { ctf-assignment-expression-list-opt }
38b8da21
MD
1477 typealias declaration-specifiers abstract-declarator-list := declaration-specifiers abstract-declarator-list ;
1478 typealias declaration-specifiers abstract-declarator-list := declarator-list ;
4fa992a5
MD
1479
1480ctf-type-specifier:
1481 floating_point { ctf-assignment-expression-list-opt }
1482 integer { ctf-assignment-expression-list-opt }
1483 string { ctf-assignment-expression-list-opt }
1484
1485ctf-assignment-expression-list:
1486 ctf-assignment-expression
1487 ctf-assignment-expression-list ; ctf-assignment-expression
1488
1489ctf-assignment-expression:
1490 unary-expression assignment-operator unary-expression
1491 unary-expression type-assignment-operator type-specifier
550aca33 1492 declaration-specifiers storage-class-specifier declaration-specifiers declarator-list
38b8da21
MD
1493 typealias declaration-specifiers abstract-declarator-list := declaration-specifiers abstract-declarator-list
1494 typealias declaration-specifiers abstract-declarator-list := declarator-list
This page took 0.0986629999999999 seconds and 4 git commands to generate.