Initial implementation of the debuginfo API
[babeltrace.git] / include / babeltrace / types.h
CommitLineData
d79865b9
MD
1#ifndef _BABELTRACE_TYPES_H
2#define _BABELTRACE_TYPES_H
3
4/*
5 * BabelTrace
6 *
fc93b2bd 7 * Type Header
d79865b9 8 *
64fa3fec
MD
9 * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
10 *
11 * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
d79865b9 12 *
ccd7e1c8
MD
13 * Permission is hereby granted, free of charge, to any person obtaining a copy
14 * of this software and associated documentation files (the "Software"), to deal
15 * in the Software without restriction, including without limitation the rights
16 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 * copies of the Software, and to permit persons to whom the Software is
18 * furnished to do so, subject to the following conditions:
d79865b9 19 *
ccd7e1c8
MD
20 * The above copyright notice and this permission notice shall be included in
21 * all copies or substantial portions of the Software.
c462e188
MD
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 * SOFTWARE.
d79865b9
MD
30 */
31
bed864a7 32#include <babeltrace/align.h>
d65d8abb 33#include <babeltrace/list.h>
9843982d 34#include <babeltrace/ctf/events.h>
4c8bfb7e
MD
35#include <stdbool.h>
36#include <stdint.h>
8099326b 37#include <babeltrace/compat/limits.h>
bed864a7 38#include <string.h>
4c8bfb7e 39#include <glib.h>
8eab883c 40#include <assert.h>
bed864a7 41
11796b96
MD
42/* Preallocate this many fields for structures */
43#define DEFAULT_NR_STRUCT_FIELDS 8
44
9e88d150 45struct ctf_stream_definition;
1cf393f6 46struct bt_stream_pos;
37b99bdb 47struct bt_format;
0d69b916 48struct bt_definition;
56e60373 49struct ctf_clock;
4c8bfb7e 50
64893f33 51/* type scope */
f6625916 52struct declaration_scope {
c13cbf74 53 /* Hash table mapping type name GQuark to "struct declaration" */
1ee8e81d 54 /* Used for both typedef and typealias. */
f6625916
MD
55 GHashTable *typedef_declarations;
56 /* Hash table mapping struct name GQuark to "struct declaration_struct" */
57 GHashTable *struct_declarations;
58 /* Hash table mapping variant name GQuark to "struct declaration_variant" */
59 GHashTable *variant_declarations;
c13cbf74 60 /* Hash table mapping enum name GQuark to "struct type_enum" */
f6625916
MD
61 GHashTable *enum_declarations;
62 struct declaration_scope *parent_scope;
64893f33
MD
63};
64
e1151715
MD
65/* definition scope */
66struct definition_scope {
67 /* Hash table mapping field name GQuark to "struct definition" */
68 GHashTable *definitions;
69 struct definition_scope *parent_scope;
05c749e5
MD
70 /*
71 * Complete "path" leading to this definition scope.
9e29e16e 72 * Includes dynamic scope name '.' field name '.' field name '.' ....
05c749e5 73 * Array of GQuark elements (which are each separated by dots).
9e29e16e
MD
74 * The dynamic scope name can contain dots, and is encoded into
75 * a single GQuark. Thus, scope_path[0] returns the GQuark
76 * identifying the dynamic scope.
05c749e5
MD
77 */
78 GArray *scope_path; /* array of GQuark */
6b71274a
MD
79};
80
ecc54f11 81struct bt_declaration {
9a19a512 82 enum bt_ctf_type_id id;
fc93b2bd 83 size_t alignment; /* type alignment, in bits */
e19c3d69 84 int ref; /* number of references to the type */
c054553d 85 /*
f6625916 86 * declaration_free called with declaration ref is decremented to 0.
c054553d 87 */
ecc54f11 88 void (*declaration_free)(struct bt_declaration *declaration);
0d69b916 89 struct bt_definition *
ecc54f11 90 (*definition_new)(struct bt_declaration *declaration,
05c749e5 91 struct definition_scope *parent_scope,
98df1c9f
MD
92 GQuark field_name, int index,
93 const char *root_name);
c054553d 94 /*
e1151715 95 * definition_free called with definition ref is decremented to 0.
e19c3d69 96 */
0d69b916 97 void (*definition_free)(struct bt_definition *definition);
c054553d
MD
98};
99
0d69b916 100struct bt_definition {
ecc54f11 101 struct bt_declaration *declaration;
05c749e5 102 int index; /* Position of the definition in its container */
b1a2f580 103 GQuark name; /* Field name in its container (or 0 if unset) */
e1151715 104 int ref; /* number of references to the definition */
31262354 105 GQuark path;
a35173fe 106 struct definition_scope *scope;
fc93b2bd
MD
107};
108
1cf393f6 109typedef int (*rw_dispatch)(struct bt_stream_pos *pos,
0d69b916 110 struct bt_definition *definition);
d11e9c49
MD
111
112/* Parent of per-plugin positions */
1cf393f6 113struct bt_stream_pos {
d11e9c49
MD
114 /* read/write dispatch table. Specific to plugin used for stream. */
115 rw_dispatch *rw_table; /* rw dispatch table */
1cf393f6 116 int (*event_cb)(struct bt_stream_pos *pos,
9e88d150 117 struct ctf_stream_definition *stream);
7237592a
MD
118 int (*pre_trace_cb)(struct bt_stream_pos *pos,
119 struct bt_trace_descriptor *trace);
120 int (*post_trace_cb)(struct bt_stream_pos *pos,
121 struct bt_trace_descriptor *trace);
ca334c72 122 struct bt_trace_descriptor *trace;
d11e9c49
MD
123};
124
125static inline
0d69b916 126int generic_rw(struct bt_stream_pos *pos, struct bt_definition *definition)
d11e9c49 127{
9a19a512 128 enum bt_ctf_type_id dispatch_id = definition->declaration->id;
d11e9c49
MD
129 rw_dispatch call;
130
131 assert(pos->rw_table[dispatch_id] != NULL);
132 call = pos->rw_table[dispatch_id];
c5e74408 133 return call(pos, definition);
d11e9c49
MD
134}
135
bed864a7
MD
136/*
137 * Because we address in bits, bitfields end up being exactly the same as
138 * integers, except that their read/write functions must be able to deal with
139 * read/write non aligned on CHAR_BIT.
140 */
f6625916 141struct declaration_integer {
ecc54f11 142 struct bt_declaration p;
7fe00194 143 size_t len; /* length, in bits. */
c35a1669 144 int byte_order; /* LITTLE_ENDIAN/BIG_ENDIAN, 0 == "Native" */
7fe00194 145 int signedness;
164078da 146 int base; /* Base for pretty-printing: 2, 8, 10, 16 */
81dee1bb 147 enum ctf_string_encoding encoding;
56e60373 148 struct ctf_clock *clock;
fc93b2bd
MD
149};
150
c40a57e5
AB
151#ifdef ENABLE_DEBUGINFO
152struct debug_info_source;
153#endif
154
e1151715 155struct definition_integer {
0d69b916 156 struct bt_definition p;
f6625916 157 struct declaration_integer *declaration;
c054553d
MD
158 /* Last values read */
159 union {
160 uint64_t _unsigned;
161 int64_t _signed;
162 } value;
c40a57e5
AB
163
164#ifdef ENABLE_DEBUGINFO
165 /*
166 * Debug infos (NULL if not set).
167 *
168 * This is extended debug informations set by the CTF input plugin
169 * itself when available. If it's set, then this integer definition
170 * is the "_ip" field of the stream event context.
171 */
172 struct debug_info_source *debug_info_src;
173#endif
c054553d
MD
174};
175
f6625916 176struct declaration_float {
ecc54f11 177 struct bt_declaration p;
f6625916
MD
178 struct declaration_integer *sign;
179 struct declaration_integer *mantissa;
180 struct declaration_integer *exp;
c35a1669 181 int byte_order; /* LITTLE_ENDIAN/BIG_ENDIAN, 0 == "Native" */
0a46062b 182 /* TODO: we might want to express more info about NaN, +inf and -inf */
fc93b2bd
MD
183};
184
e1151715 185struct definition_float {
0d69b916 186 struct bt_definition p;
f6625916 187 struct declaration_float *declaration;
d11e9c49
MD
188 struct definition_integer *sign;
189 struct definition_integer *mantissa;
190 struct definition_integer *exp;
c054553d 191 /* Last values read */
f72803ca 192 double value;
c054553d
MD
193};
194
d65d8abb
MD
195/*
196 * enum_val_equal assumes that signed and unsigned memory layout overlap.
197 */
198struct enum_range {
199 union {
200 int64_t _signed;
201 uint64_t _unsigned;
202 } start; /* lowest range value */
203 union {
204 int64_t _signed;
205 uint64_t _unsigned;
206 } end; /* highest range value */
207};
208
209struct enum_range_to_quark {
3122e6f0 210 struct bt_list_head node;
d65d8abb
MD
211 struct enum_range range;
212 GQuark quark;
213};
214
215/*
216 * We optimize the common case (range of size 1: single value) by creating a
217 * hash table mapping values to quark sets. We then lookup the ranges to
218 * complete the quark set.
219 *
220 * TODO: The proper structure to hold the range to quark set mapping would be an
221 * interval tree, with O(n) size, O(n*log(n)) build time and O(log(n)) query
222 * time. Using a simple O(n) list search for now for implementation speed and
223 * given that we can expect to have a _relatively_ small number of enumeration
224 * ranges. This might become untrue if we are fed with symbol tables often
225 * required to lookup function names from instruction pointer value.
226 */
448d3cc7 227struct enum_table {
d65d8abb 228 GHashTable *value_to_quark_set; /* (value, GQuark GArray) */
3122e6f0 229 struct bt_list_head range_to_quark; /* (range, GQuark) */
d65d8abb 230 GHashTable *quark_to_range_set; /* (GQuark, range GArray) */
448d3cc7
MD
231};
232
f6625916 233struct declaration_enum {
ecc54f11 234 struct bt_declaration p;
f6625916 235 struct declaration_integer *integer_declaration;
448d3cc7 236 struct enum_table table;
fc93b2bd
MD
237};
238
e1151715 239struct definition_enum {
0d69b916 240 struct bt_definition p;
e1151715 241 struct definition_integer *integer;
f6625916 242 struct declaration_enum *declaration;
c054553d
MD
243 /* Last GQuark values read. Keeping a reference on the GQuark array. */
244 GArray *value;
245};
246
f6625916 247struct declaration_string {
ecc54f11 248 struct bt_declaration p;
ab4cf058 249 enum ctf_string_encoding encoding;
c054553d
MD
250};
251
e1151715 252struct definition_string {
0d69b916 253 struct bt_definition p;
f6625916 254 struct declaration_string *declaration;
e1151715 255 char *value; /* freed at definition_string teardown */
d11e9c49 256 size_t len, alloc_len;
11796b96
MD
257};
258
f6625916 259struct declaration_field {
e19c3d69 260 GQuark name;
ecc54f11 261 struct bt_declaration *declaration;
c054553d
MD
262};
263
f6625916 264struct declaration_struct {
ecc54f11 265 struct bt_declaration p;
e19c3d69 266 GHashTable *fields_by_name; /* Tuples (field name, field index) */
f6625916
MD
267 struct declaration_scope *scope;
268 GArray *fields; /* Array of declaration_field */
e19c3d69
MD
269};
270
e1151715 271struct definition_struct {
0d69b916 272 struct bt_definition p;
f6625916 273 struct declaration_struct *declaration;
0d69b916 274 GPtrArray *fields; /* Array of pointers to struct bt_definition */
c054553d
MD
275};
276
d60cb676 277struct declaration_untagged_variant {
ecc54f11 278 struct bt_declaration p;
c054553d 279 GHashTable *fields_by_tag; /* Tuples (field tag, field index) */
f6625916
MD
280 struct declaration_scope *scope;
281 GArray *fields; /* Array of declaration_field */
c054553d
MD
282};
283
d60cb676 284struct declaration_variant {
ecc54f11 285 struct bt_declaration p;
d60cb676
MD
286 struct declaration_untagged_variant *untagged_variant;
287 GArray *tag_name; /* Array of GQuark */
288};
289
290/* A variant needs to be tagged to be defined. */
e1151715 291struct definition_variant {
0d69b916 292 struct bt_definition p;
f6625916 293 struct declaration_variant *declaration;
0d69b916
JD
294 struct bt_definition *enum_tag;
295 GPtrArray *fields; /* Array of pointers to struct bt_definition */
296 struct bt_definition *current_field; /* Last field read */
11796b96
MD
297};
298
f6625916 299struct declaration_array {
ecc54f11 300 struct bt_declaration p;
11796b96 301 size_t len;
ecc54f11 302 struct bt_declaration *elem;
f6625916 303 struct declaration_scope *scope;
11796b96
MD
304};
305
e1151715 306struct definition_array {
0d69b916 307 struct bt_definition p;
f6625916 308 struct declaration_array *declaration;
0d69b916 309 GPtrArray *elems; /* Array of pointers to struct bt_definition */
81dee1bb 310 GString *string; /* String for encoded integer children */
c054553d
MD
311};
312
f6625916 313struct declaration_sequence {
ecc54f11 314 struct bt_declaration p;
98df1c9f 315 GArray *length_name; /* Array of GQuark */
ecc54f11 316 struct bt_declaration *elem;
f6625916 317 struct declaration_scope *scope;
e19c3d69
MD
318};
319
e1151715 320struct definition_sequence {
0d69b916 321 struct bt_definition p;
f6625916 322 struct declaration_sequence *declaration;
98df1c9f 323 struct definition_integer *length;
0d69b916 324 GPtrArray *elems; /* Array of pointers to struct bt_definition */
81dee1bb 325 GString *string; /* String for encoded integer children */
c054553d
MD
326};
327
becd02a1 328int bt_register_declaration(GQuark declaration_name,
ecc54f11 329 struct bt_declaration *declaration,
f6625916 330 struct declaration_scope *scope);
ecc54f11 331struct bt_declaration *bt_lookup_declaration(GQuark declaration_name,
78af2bcd 332 struct declaration_scope *scope);
c13cbf74
MD
333
334/*
335 * Type scopes also contain a separate registry for struct, variant and
e1151715 336 * enum types. Those register types rather than type definitions, so
c13cbf74
MD
337 * that a named variant can be declared without specifying its target
338 * "choice" tag field immediately.
339 */
c8c98132 340int bt_register_struct_declaration(GQuark struct_name,
f6625916
MD
341 struct declaration_struct *struct_declaration,
342 struct declaration_scope *scope);
343struct declaration_struct *
c8c98132 344 bt_lookup_struct_declaration(GQuark struct_name,
f6625916 345 struct declaration_scope *scope);
becd02a1 346int bt_register_variant_declaration(GQuark variant_name,
a0720417 347 struct declaration_untagged_variant *untagged_variant_declaration,
f6625916 348 struct declaration_scope *scope);
becd02a1 349struct declaration_untagged_variant *bt_lookup_variant_declaration(GQuark variant_name,
f6625916 350 struct declaration_scope *scope);
becd02a1 351int bt_register_enum_declaration(GQuark enum_name,
f6625916
MD
352 struct declaration_enum *enum_declaration,
353 struct declaration_scope *scope);
354struct declaration_enum *
becd02a1 355 bt_lookup_enum_declaration(GQuark enum_name,
f6625916
MD
356 struct declaration_scope *scope);
357
358struct declaration_scope *
becd02a1
JD
359 bt_new_declaration_scope(struct declaration_scope *parent_scope);
360void bt_free_declaration_scope(struct declaration_scope *scope);
c054553d 361
c13cbf74 362/*
e1151715
MD
363 * field_definition is for field definitions. They are registered into
364 * definition scopes.
c13cbf74 365 */
0d69b916 366struct bt_definition *
2b77e6a6 367 bt_lookup_path_definition(GArray *cur_path, /* array of GQuark */
a35173fe
MD
368 GArray *lookup_path, /* array of GQuark */
369 struct definition_scope *scope);
2b77e6a6 370int bt_register_field_definition(GQuark field_name,
0d69b916 371 struct bt_definition *definition,
e1151715
MD
372 struct definition_scope *scope);
373struct definition_scope *
2b77e6a6 374 bt_new_definition_scope(struct definition_scope *parent_scope,
98df1c9f 375 GQuark field_name, const char *root_name);
2b77e6a6 376void bt_free_definition_scope(struct definition_scope *scope);
4c8bfb7e 377
2b77e6a6 378GQuark bt_new_definition_path(struct definition_scope *parent_scope,
98df1c9f 379 GQuark field_name, const char *root_name);
31262354
MD
380
381static inline
0d69b916 382int compare_definition_path(struct bt_definition *definition, GQuark path)
31262354
MD
383{
384 return definition->path == path;
385}
386
ecc54f11
JD
387void bt_declaration_ref(struct bt_declaration *declaration);
388void bt_declaration_unref(struct bt_declaration *declaration);
64893f33 389
0d69b916
JD
390void bt_definition_ref(struct bt_definition *definition);
391void bt_definition_unref(struct bt_definition *definition);
698f0fe4 392
becd02a1 393struct declaration_integer *bt_integer_declaration_new(size_t len, int byte_order,
164078da 394 int signedness, size_t alignment,
56e60373
MD
395 int base, enum ctf_string_encoding encoding,
396 struct ctf_clock *clock);
0d69b916
JD
397uint64_t bt_get_unsigned_int(const struct bt_definition *field);
398int64_t bt_get_signed_int(const struct bt_definition *field);
399int bt_get_int_signedness(const struct bt_definition *field);
400int bt_get_int_byte_order(const struct bt_definition *field);
401int bt_get_int_base(const struct bt_definition *field);
402size_t bt_get_int_len(const struct bt_definition *field); /* in bits */
403enum ctf_string_encoding bt_get_int_encoding(const struct bt_definition *field);
0a46062b 404
11d43b90
MD
405/*
406 * mantissa_len is the length of the number of bytes represented by the mantissa
407 * (e.g. result of DBL_MANT_DIG). It includes the leading 1.
408 */
becd02a1 409struct declaration_float *bt_float_declaration_new(size_t mantissa_len,
e19c3d69
MD
410 size_t exp_len, int byte_order,
411 size_t alignment);
0a46062b 412
448d3cc7
MD
413/*
414 * A GQuark can be translated to/from strings with g_quark_from_string() and
415 * g_quark_to_string().
416 */
47e0f2e2
MD
417
418/*
419 * Returns a GArray of GQuark or NULL.
420 * Caller must release the GArray with g_array_unref().
421 */
2399b6f4 422GArray *bt_enum_uint_to_quark_set(const struct declaration_enum *enum_declaration,
f6625916 423 uint64_t v);
d65d8abb
MD
424
425/*
47e0f2e2 426 * Returns a GArray of GQuark or NULL.
d65d8abb
MD
427 * Caller must release the GArray with g_array_unref().
428 */
2399b6f4 429GArray *bt_enum_int_to_quark_set(const struct declaration_enum *enum_declaration,
bcdf4cf2 430 int64_t v);
47e0f2e2
MD
431
432/*
433 * Returns a GArray of struct enum_range or NULL.
fdacfb73
MD
434 * Callers do _not_ own the returned GArray (and therefore _don't_ need to
435 * release it).
47e0f2e2 436 */
2399b6f4 437GArray *bt_enum_quark_to_range_set(const struct declaration_enum *enum_declaration,
f6625916 438 GQuark q);
2399b6f4 439void bt_enum_signed_insert(struct declaration_enum *enum_declaration,
d65d8abb 440 int64_t start, int64_t end, GQuark q);
2399b6f4 441void bt_enum_unsigned_insert(struct declaration_enum *enum_declaration,
d65d8abb 442 uint64_t start, uint64_t end, GQuark q);
2399b6f4 443size_t bt_enum_get_nr_enumerators(struct declaration_enum *enum_declaration);
f6625916
MD
444
445struct declaration_enum *
2399b6f4 446 bt_enum_declaration_new(struct declaration_integer *integer_declaration);
f6625916 447
e397791f 448struct declaration_string *
ebdb2383 449 bt_string_declaration_new(enum ctf_string_encoding encoding);
0d69b916
JD
450char *bt_get_string(const struct bt_definition *field);
451enum ctf_string_encoding bt_get_string_encoding(const struct bt_definition *field);
e397791f 452
e5a73b90
JG
453double bt_get_float(const struct bt_definition *field);
454
812e6682
JG
455const struct bt_definition *bt_get_variant_field(struct bt_definition *definition);
456
f6625916 457struct declaration_struct *
c8c98132 458 bt_struct_declaration_new(struct declaration_scope *parent_scope,
b7e35bad 459 uint64_t min_align);
c8c98132 460void bt_struct_declaration_add_field(struct declaration_struct *struct_declaration,
f6625916 461 const char *field_name,
ecc54f11 462 struct bt_declaration *field_declaration);
11796b96
MD
463/*
464 * Returns the index of a field within a structure.
465 */
c8c98132 466int bt_struct_declaration_lookup_field_index(struct declaration_struct *struct_declaration,
f6625916 467 GQuark field_name);
11796b96
MD
468/*
469 * field returned only valid as long as the field structure is not appended to.
470 */
f6625916 471struct declaration_field *
c8c98132 472bt_struct_declaration_get_field_from_index(struct declaration_struct *struct_declaration,
0f980a35 473 int index);
0d69b916 474struct bt_definition *
3a068915 475bt_struct_definition_get_field_from_index(const struct definition_struct *struct_definition,
0f980a35 476 int index);
0d69b916 477int bt_struct_rw(struct bt_stream_pos *pos, struct bt_definition *definition);
3a068915 478uint64_t bt_struct_declaration_len(const struct declaration_struct *struct_declaration);
11796b96 479
c054553d
MD
480/*
481 * The tag enumeration is validated to ensure that it contains only mappings
482 * from numeric values to a single tag. Overlapping tag value ranges are
483 * therefore forbidden.
484 */
becd02a1 485struct declaration_untagged_variant *bt_untagged_bt_variant_declaration_new(
1934b94f 486 struct declaration_scope *parent_scope);
becd02a1 487struct declaration_variant *bt_variant_declaration_new(struct declaration_untagged_variant *untagged_variant,
d60cb676
MD
488 const char *tag);
489
becd02a1 490void bt_untagged_variant_declaration_add_field(struct declaration_untagged_variant *untagged_variant_declaration,
d60cb676 491 const char *field_name,
ecc54f11 492 struct bt_declaration *field_declaration);
f6625916 493struct declaration_field *
becd02a1 494 bt_untagged_variant_declaration_get_field_from_tag(struct declaration_untagged_variant *untagged_variant_declaration,
1934b94f 495 GQuark tag);
c054553d
MD
496/*
497 * Returns 0 on success, -EPERM on error.
498 */
e1151715 499int variant_definition_set_tag(struct definition_variant *variant,
0d69b916 500 struct bt_definition *enum_tag);
c054553d
MD
501/*
502 * Returns the field selected by the current tag value.
503 * field returned only valid as long as the variant structure is not appended
504 * to.
505 */
0d69b916
JD
506struct bt_definition *bt_variant_get_current_field(struct definition_variant *variant);
507int bt_variant_rw(struct bt_stream_pos *pos, struct bt_definition *definition);
c054553d 508
d06d03db 509/*
f6625916
MD
510 * elem_declaration passed as parameter now belongs to the array. No
511 * need to free it explicitly. "len" is the number of elements in the
512 * array.
d06d03db 513 */
f6625916 514struct declaration_array *
ecc54f11 515 bt_array_declaration_new(size_t len, struct bt_declaration *elem_declaration,
1934b94f 516 struct declaration_scope *parent_scope);
dcaa2e7d 517uint64_t bt_array_len(struct definition_array *array);
0d69b916
JD
518struct bt_definition *bt_array_index(struct definition_array *array, uint64_t i);
519int bt_array_rw(struct bt_stream_pos *pos, struct bt_definition *definition);
520GString *bt_get_char_array(const struct bt_definition *field);
521int bt_get_array_len(const struct bt_definition *field);
11796b96 522
d06d03db 523/*
f6625916
MD
524 * int_declaration and elem_declaration passed as parameter now belong
525 * to the sequence. No need to free them explicitly.
d06d03db 526 */
f6625916 527struct declaration_sequence *
9ffd39fc 528 bt_sequence_declaration_new(const char *length_name,
ecc54f11 529 struct bt_declaration *elem_declaration,
1934b94f 530 struct declaration_scope *parent_scope);
9ffd39fc 531uint64_t bt_sequence_len(struct definition_sequence *sequence);
0d69b916
JD
532struct bt_definition *bt_sequence_index(struct definition_sequence *sequence, uint64_t i);
533int bt_sequence_rw(struct bt_stream_pos *pos, struct bt_definition *definition);
11796b96 534
d60cb676
MD
535/*
536 * in: path (dot separated), out: q (GArray of GQuark)
537 */
dd0365d9 538void bt_append_scope_path(const char *path, GArray *q);
d60cb676 539
a35173fe
MD
540/*
541 * Lookup helpers.
542 */
0d69b916 543struct bt_definition *bt_lookup_definition(const struct bt_definition *definition,
620961f6 544 const char *field_name);
c40a57e5
AB
545struct bt_definition *bt_lookup_definition_by_quark(const struct bt_definition *definition,
546 GQuark quark);
0d69b916 547struct definition_integer *bt_lookup_integer(const struct bt_definition *definition,
a35173fe
MD
548 const char *field_name,
549 int signedness);
0d69b916 550struct definition_enum *bt_lookup_enum(const struct bt_definition *definition,
a35173fe
MD
551 const char *field_name,
552 int signedness);
0d69b916 553struct bt_definition *bt_lookup_variant(const struct bt_definition *definition,
a35173fe
MD
554 const char *field_name);
555
300d317a
JD
556static inline
557const char *rem_(const char *str)
558{
559 if (str[0] == '_')
560 return &str[1];
561 else
562 return str;
563}
564
31262354 565#endif /* _BABELTRACE_TYPES_H */
This page took 0.067331 seconds and 4 git commands to generate.