Add Python bindings for CTF-IR event-types getters
[babeltrace.git] / bindings / python / babeltrace.i.in
1 /*
2 * babeltrace.i.in
3 *
4 * Babeltrace Python Module interface file
5 *
6 * Copyright 2012 EfficiOS Inc.
7 *
8 * Author: Danny Serres <danny.serres@efficios.com>
9 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this software and associated documentation files (the "Software"), to deal
13 * in the Software without restriction, including without limitation the rights
14 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 * copies of the Software, and to permit persons to whom the Software is
16 * furnished to do so, subject to the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
20 */
21
22
23 %define DOCSTRING
24 "BABELTRACE_VERSION_STR
25
26 Babeltrace is a trace viewer and converter reading and writing the
27 Common Trace Format (CTF). Its main use is to pretty-print CTF
28 traces into a human-readable text output.
29
30 To use this module, the first step is to create a TraceCollection and add a
31 trace to it."
32 %enddef
33
34 %module(docstring=DOCSTRING) babeltrace
35
36 %include "typemaps.i"
37 %{
38 #define SWIG_FILE_WITH_INIT
39 #include <babeltrace/babeltrace.h>
40 #include <babeltrace/babeltrace-internal.h>
41 #include <babeltrace/trace-handle.h>
42 #include <babeltrace/trace-handle-internal.h>
43 #include <babeltrace/context.h>
44 #include <babeltrace/context-internal.h>
45 #include <babeltrace/iterator.h>
46 #include <babeltrace/iterator-internal.h>
47 #include <babeltrace/format.h>
48 #include <babeltrace/list.h>
49 #include <babeltrace/types.h>
50 #include <babeltrace/ctf/iterator.h>
51 #include "python-complements.h"
52 #include <babeltrace/ctf-writer/clock.h>
53 #include <babeltrace/ctf-writer/event-fields.h>
54 #include <babeltrace/ctf-writer/event-types.h>
55 #include <babeltrace/ctf-writer/event.h>
56 #include <babeltrace/ctf-writer/stream.h>
57 #include <babeltrace/ctf-writer/writer.h>
58 %}
59
60 typedef unsigned long long uint64_t;
61 typedef long long int64_t;
62 typedef int bt_intern_str;
63 typedef int64_t ssize_t;
64
65 /* =================================================================
66 PYTHON-COMPLEMENTS.H
67 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
68 */
69
70 struct bt_definition **_bt_python_field_listcaller(
71 const struct bt_ctf_event *ctf_event,
72 const struct bt_definition *scope,
73 unsigned int *OUTPUT);
74 struct bt_definition *_bt_python_field_one_from_list(
75 struct bt_definition **list, int index);
76 struct bt_ctf_event_decl **_bt_python_event_decl_listcaller(
77 int handle_id,
78 struct bt_context *ctx,
79 unsigned int *OUTPUT);
80 struct bt_ctf_event_decl *_bt_python_decl_one_from_list(
81 struct bt_ctf_event_decl **list, int index);
82 struct bt_ctf_field_decl **_by_python_field_decl_listcaller(
83 struct bt_ctf_event_decl *event_decl,
84 enum bt_ctf_scope scope,
85 unsigned int *OUTPUT);
86 struct bt_ctf_field_decl *_bt_python_field_decl_one_from_list(
87 struct bt_ctf_field_decl **list, int index);
88 struct definition_array *_bt_python_get_array_from_def(
89 struct bt_definition *field);
90 struct definition_sequence *_bt_python_get_sequence_from_def(
91 struct bt_definition *field);
92 struct bt_declaration *_bt_python_get_array_element_declaration(
93 struct bt_declaration *field);
94 struct bt_declaration *_bt_python_get_sequence_element_declaration(
95 struct bt_declaration *field);
96 const char *_bt_python_get_array_string(struct bt_definition *field);
97 const char *_bt_python_get_sequence_string(struct bt_definition *field);
98 int _bt_python_field_integer_get_signedness(const struct bt_ctf_field *field);
99 enum ctf_type_id _bt_python_get_field_type(const struct bt_ctf_field *field);
100 const char *_bt_python_ctf_field_type_enumeration_get_mapping(
101 struct bt_ctf_field_type *enumeration, size_t index,
102 int64_t *OUTPUT, int64_t *OUTPUT);
103 const char *_bt_python_ctf_field_type_enumeration_get_mapping_unsigned(
104 struct bt_ctf_field_type *enumeration, size_t index,
105 uint64_t *OUTPUT, uint64_t *OUTPUT);
106 const char *_bt_python_ctf_field_type_structure_get_field_name(
107 struct bt_ctf_field_type *structure, size_t index);
108 struct bt_ctf_field_type *_bt_python_ctf_field_type_structure_get_field_type(
109 struct bt_ctf_field_type *structure, size_t index);
110 const char *_bt_python_ctf_field_type_variant_get_field_name(
111 struct bt_ctf_field_type *variant, size_t index);
112 struct bt_ctf_field_type *_bt_python_ctf_field_type_variant_get_field_type(
113 struct bt_ctf_field_type *variant, size_t index);
114
115 /* =================================================================
116 CONTEXT.H, CONTEXT-INTERNAL.H
117 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
118 */
119
120 %rename("_bt_context_create") bt_context_create(void);
121 %rename("_bt_context_add_trace") bt_context_add_trace(
122 struct bt_context *ctx, const char *path, const char *format,
123 void (*packet_seek)(struct bt_stream_pos *pos, size_t index, int whence),
124 struct bt_mmap_stream_list *stream_list, FILE *metadata);
125 %rename("_bt_context_remove_trace") bt_context_remove_trace(
126 struct bt_context *ctx, int trace_id);
127 %rename("_bt_context_get") bt_context_get(struct bt_context *ctx);
128 %rename("_bt_context_put") bt_context_put(struct bt_context *ctx);
129 %rename("_bt_ctf_event_get_context") bt_ctf_event_get_context(
130 const struct bt_ctf_event *event);
131
132 struct bt_context *bt_context_create(void);
133 int bt_context_add_trace(struct bt_context *ctx, const char *path, const char *format,
134 void (*packet_seek)(struct bt_stream_pos *pos, size_t index, int whence),
135 struct bt_mmap_stream_list *stream_list, FILE *metadata);
136 void bt_context_remove_trace(struct bt_context *ctx, int trace_id);
137 void bt_context_get(struct bt_context *ctx);
138 void bt_context_put(struct bt_context *ctx);
139 struct bt_context *bt_ctf_event_get_context(const struct bt_ctf_event *event);
140
141 // class TraceCollection to prevent direct access to struct bt_context
142 %pythoncode%{
143 class TraceCollection:
144 """
145 The TraceCollection is the object that contains all currently opened traces.
146 """
147
148 def __init__(self):
149 self._tc = _bt_context_create()
150
151 def __del__(self):
152 _bt_context_put(self._tc)
153
154 def add_trace(self, path, format_str):
155 """
156 Add a trace by path to the TraceCollection.
157
158 Open a trace.
159
160 path is the path to the trace, it is not recursive.
161 If "path" is None, stream_list is used instead as a list
162 of mmap streams to open for the trace.
163
164 format is a string containing the format name in which the trace was
165 produced.
166
167 Return: the corresponding TraceHandle on success or None on error.
168 """
169 ret = _bt_context_add_trace(self._tc, path, format_str, None, None, None)
170 if ret < 0:
171 return None
172
173 th = TraceHandle.__new__(TraceHandle)
174 th._id = ret
175 th._trace_collection = self
176 return th
177
178 def add_traces_recursive(self, path, format_str):
179 """
180 Open a trace recursively.
181
182 Find each trace present in the subdirectory starting from the given
183 path, and add them to the TraceCollection.
184
185 Return a dict of TraceHandle instances (the full path is the key).
186 Return None on error.
187 """
188
189 import os
190
191 trace_handles = {}
192
193 noTrace = True
194 error = False
195
196 for fullpath, dirs, files in os.walk(path):
197 if "metadata" in files:
198 trace_handle = self.add_trace(fullpath, format_str)
199 if trace_handle is None:
200 error = True
201 continue
202
203 trace_handles[fullpath] = trace_handle
204 noTrace = False
205
206 if noTrace and error:
207 return None
208 return trace_handles
209
210 def remove_trace(self, trace_handle):
211 """
212 Remove a trace from the TraceCollection.
213 Effectively closing the trace.
214 """
215 try:
216 _bt_context_remove_trace(self._tc, trace_handle._id)
217 except AttributeError:
218 raise TypeError("in remove_trace, "
219 "argument 2 must be a TraceHandle instance")
220
221 @property
222 def events(self):
223 """
224 Generator function to iterate over the events of open in the current
225 TraceCollection.
226 """
227 begin_pos_ptr = _bt_iter_pos()
228 end_pos_ptr = _bt_iter_pos()
229 begin_pos_ptr.type = SEEK_BEGIN
230 end_pos_ptr.type = SEEK_LAST
231
232 for event in self._events(begin_pos_ptr, end_pos_ptr):
233 yield event
234
235 def events_timestamps(self, timestamp_begin, timestamp_end):
236 """
237 Generator function to iterate over the events of open in the current
238 TraceCollection from timestamp_begin to timestamp_end.
239 """
240 begin_pos_ptr = _bt_iter_pos()
241 end_pos_ptr = _bt_iter_pos()
242 begin_pos_ptr.type = end_pos_ptr.type = SEEK_TIME
243 begin_pos_ptr.u.seek_time = timestamp_begin
244 end_pos_ptr.u.seek_time = timestamp_end
245
246 for event in self._events(begin_pos_ptr, end_pos_ptr):
247 yield event
248
249 @property
250 def timestamp_begin(self):
251 pos_ptr = _bt_iter_pos()
252 pos_ptr.type = SEEK_BEGIN
253 return self._timestamp_at_pos(pos_ptr)
254
255 @property
256 def timestamp_end(self):
257 pos_ptr = _bt_iter_pos()
258 pos_ptr.type = SEEK_LAST
259 return self._timestamp_at_pos(pos_ptr)
260
261 def _timestamp_at_pos(self, pos_ptr):
262 ctf_it_ptr = _bt_ctf_iter_create(self._tc, pos_ptr, pos_ptr)
263 if ctf_it_ptr is None:
264 raise NotImplementedError("Creation of multiple iterators is unsupported.")
265 ev_ptr = _bt_ctf_iter_read_event(ctf_it_ptr)
266 _bt_ctf_iter_destroy(ctf_it_ptr)
267 if ev_ptr is None:
268 return None;
269
270 def _events(self, begin_pos_ptr, end_pos_ptr):
271 ctf_it_ptr = _bt_ctf_iter_create(self._tc, begin_pos_ptr, end_pos_ptr)
272 if ctf_it_ptr is None:
273 raise NotImplementedError(
274 "Creation of multiple iterators is unsupported.")
275
276 while True:
277 ev_ptr = _bt_ctf_iter_read_event(ctf_it_ptr)
278 if ev_ptr is None:
279 break
280
281 ev = Event.__new__(Event)
282 ev._e = ev_ptr
283 try:
284 yield ev
285 except GeneratorExit:
286 break
287
288 ret = _bt_iter_next(_bt_ctf_get_iter(ctf_it_ptr))
289 if ret != 0:
290 break
291
292 _bt_ctf_iter_destroy(ctf_it_ptr)
293
294 %}
295
296
297
298 /* =================================================================
299 FORMAT.H, REGISTRY
300 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
301 */
302
303 %rename("lookup_format") bt_lookup_format(bt_intern_str qname);
304 %rename("_bt_print_format_list") bt_fprintf_format_list(FILE *fp);
305 %rename("register_format") bt_register_format(struct format *format);
306 %rename("unregister_format") bt_unregister_format(struct bt_format *format);
307
308 extern struct format *bt_lookup_format(bt_intern_str qname);
309 extern void bt_fprintf_format_list(FILE *fp);
310 extern int bt_register_format(struct bt_format *format);
311 extern void bt_unregister_format(struct bt_format *format);
312
313 %pythoncode %{
314
315 def print_format_list(babeltrace_file):
316 """
317 Print a list of available formats to file.
318
319 babeltrace_file must be a File instance opened in write mode.
320 """
321 try:
322 if babeltrace_file._file is not None:
323 _bt_print_format_list(babeltrace_file._file)
324 except AttributeError:
325 raise TypeError("in print_format_list, "
326 "argument 1 must be a File instance")
327
328 %}
329
330
331 /* =================================================================
332 ITERATOR.H, ITERATOR-INTERNAL.H
333 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
334 */
335
336 %rename("_bt_iter_create") bt_iter_create(struct bt_context *ctx,
337 const struct bt_iter_pos *begin_pos, const struct bt_iter_pos *end_pos);
338 %rename("_bt_iter_destroy") bt_iter_destroy(struct bt_iter *iter);
339 %rename("_bt_iter_next") bt_iter_next(struct bt_iter *iter);
340 %rename("_bt_iter_get_pos") bt_iter_get_pos(struct bt_iter *iter);
341 %rename("_bt_iter_free_pos") bt_iter_free_pos(struct bt_iter_pos *pos);
342 %rename("_bt_iter_set_pos") bt_iter_set_pos(struct bt_iter *iter,
343 const struct bt_iter_pos *pos);
344 %rename("_bt_iter_create_time_pos") bt_iter_create_time_pos(struct bt_iter *iter,
345 uint64_t timestamp);
346
347 struct bt_iter *bt_iter_create(struct bt_context *ctx,
348 const struct bt_iter_pos *begin_pos, const struct bt_iter_pos *end_pos);
349 void bt_iter_destroy(struct bt_iter *iter);
350 int bt_iter_next(struct bt_iter *iter);
351 struct bt_iter_pos *bt_iter_get_pos(struct bt_iter *iter);
352 void bt_iter_free_pos(struct bt_iter_pos *pos);
353 int bt_iter_set_pos(struct bt_iter *iter, const struct bt_iter_pos *pos);
354 struct bt_iter_pos *bt_iter_create_time_pos(struct bt_iter *iter, uint64_t timestamp);
355
356 %rename("_bt_iter_pos") bt_iter_pos;
357 %rename("SEEK_TIME") BT_SEEK_TIME;
358 %rename("SEEK_RESTORE") BT_SEEK_RESTORE;
359 %rename("SEEK_CUR") BT_SEEK_CUR;
360 %rename("SEEK_BEGIN") BT_SEEK_BEGIN;
361 %rename("SEEK_LAST") BT_SEEK_LAST;
362
363 // This struct is taken from iterator.h
364 // All changes to the struct must also be made here
365 struct bt_iter_pos {
366 enum {
367 BT_SEEK_TIME, /* uses u.seek_time */
368 BT_SEEK_RESTORE, /* uses u.restore */
369 BT_SEEK_CUR,
370 BT_SEEK_BEGIN,
371 BT_SEEK_LAST
372 } type;
373 union {
374 uint64_t seek_time;
375 struct bt_saved_pos *restore;
376 } u;
377 };
378
379 /* =================================================================
380 TRACE-HANDLE.H, TRACE-HANDLE-INTERNAL.H
381 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
382 */
383
384 %rename("_bt_trace_handle_create") bt_trace_handle_create(struct bt_context *ctx);
385 %rename("_bt_trace_handle_destroy") bt_trace_handle_destroy(struct bt_trace_handle *bt);
386 struct bt_trace_handle *bt_trace_handle_create(struct bt_context *ctx);
387 void bt_trace_handle_destroy(struct bt_trace_handle *bt);
388
389 %rename("_bt_trace_handle_get_path") bt_trace_handle_get_path(struct bt_context *ctx,
390 int handle_id);
391 %rename("_bt_trace_handle_get_timestamp_begin") bt_trace_handle_get_timestamp_begin(
392 struct bt_context *ctx, int handle_id, enum bt_clock_type type);
393 %rename("_bt_trace_handle_get_timestamp_end") bt_trace_handle_get_timestamp_end(
394 struct bt_context *ctx, int handle_id, enum bt_clock_type type);
395 const char *bt_trace_handle_get_path(struct bt_context *ctx, int handle_id);
396 uint64_t bt_trace_handle_get_timestamp_begin(struct bt_context *ctx, int handle_id,
397 enum bt_clock_type type);
398 uint64_t bt_trace_handle_get_timestamp_end(struct bt_context *ctx, int handle_id,
399 enum bt_clock_type type);
400
401 %rename("_bt_ctf_event_get_handle_id") bt_ctf_event_get_handle_id(
402 const struct bt_ctf_event *event);
403 int bt_ctf_event_get_handle_id(const struct bt_ctf_event *event);
404
405
406 %pythoncode%{
407
408 # Based on enum bt_clock_type in clock-type.h
409 class ClockType:
410 CLOCK_CYCLES = 0
411 CLOCK_REAL = 1
412
413 class TraceHandle(object):
414 """
415 The TraceHandle allows the user to manipulate a trace file directly.
416 It is a unique identifier representing a trace file.
417 Do not instantiate.
418 """
419
420 def __init__(self):
421 raise NotImplementedError("TraceHandle cannot be instantiated")
422
423 def __repr__(self):
424 return "Babeltrace TraceHandle: trace_id('{0}')".format(self._id)
425
426 @property
427 def id(self):
428 """Return the TraceHandle id."""
429 return self._id
430
431 @property
432 def path(self):
433 """Return the path of a TraceHandle."""
434 return _bt_trace_handle_get_path(self._trace_collection._tc, self._id)
435
436 @property
437 def timestamp_begin(self):
438 """Return the creation time of the buffers of a trace."""
439 return _bt_trace_handle_get_timestamp_begin(
440 self._trace_collection._tc, self._id, ClockType.CLOCK_REAL)
441
442 @property
443 def timestamp_end(self):
444 """Return the destruction timestamp of the buffers of a trace."""
445 return _bt_trace_handle_get_timestamp_end(
446 self._trace_collection._tc, self._id, ClockType.CLOCK_REAL)
447
448 @property
449 def events(self):
450 """
451 Generator returning all events (EventDeclaration) in a trace.
452 """
453 ret = _bt_python_event_decl_listcaller(self.id, self._trace_collection._tc)
454
455 if not isinstance(ret, list):
456 return
457
458 ptr_list, count = ret
459 for i in range(count):
460 tmp = EventDeclaration.__new__(EventDeclaration)
461 tmp._ed = _bt_python_decl_one_from_list(ptr_list, i)
462 yield tmp
463
464 %}
465
466
467
468 // =================================================================
469 // CTF
470 // =================================================================
471
472 /* =================================================================
473 ITERATOR.H, EVENTS.H
474 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
475 */
476
477 //Iterator
478 %rename("_bt_ctf_iter_create") bt_ctf_iter_create(struct bt_context *ctx,
479 const struct bt_iter_pos *begin_pos,
480 const struct bt_iter_pos *end_pos);
481 %rename("_bt_ctf_get_iter") bt_ctf_get_iter(struct bt_ctf_iter *iter);
482 %rename("_bt_ctf_iter_destroy") bt_ctf_iter_destroy(struct bt_ctf_iter *iter);
483 %rename("_bt_ctf_iter_read_event") bt_ctf_iter_read_event(struct bt_ctf_iter *iter);
484
485 struct bt_ctf_iter *bt_ctf_iter_create(struct bt_context *ctx,
486 const struct bt_iter_pos *begin_pos,
487 const struct bt_iter_pos *end_pos);
488 struct bt_iter *bt_ctf_get_iter(struct bt_ctf_iter *iter);
489 void bt_ctf_iter_destroy(struct bt_ctf_iter *iter);
490 struct bt_ctf_event *bt_ctf_iter_read_event(struct bt_ctf_iter *iter);
491
492
493 //Events
494 %rename("_bt_ctf_get_top_level_scope") bt_ctf_get_top_level_scope(const struct
495 bt_ctf_event *event, enum bt_ctf_scope scope);
496 %rename("_bt_ctf_event_name") bt_ctf_event_name(const struct bt_ctf_event *ctf_event);
497 %rename("_bt_ctf_get_timestamp") bt_ctf_get_timestamp(
498 const struct bt_ctf_event *ctf_event);
499 %rename("_bt_ctf_get_cycles") bt_ctf_get_cycles(
500 const struct bt_ctf_event *ctf_event);
501
502 %rename("_bt_ctf_get_field") bt_ctf_get_field(const struct bt_ctf_event *ctf_event,
503 const struct bt_definition *scope, const char *field);
504 %rename("_bt_ctf_get_index") bt_ctf_get_index(const struct bt_ctf_event *ctf_event,
505 const struct bt_definition *field, unsigned int index);
506 %rename("_bt_ctf_field_name") bt_ctf_field_name(const struct bt_definition *field);
507 %rename("_bt_ctf_field_type") bt_ctf_field_type(const struct bt_declaration *field);
508 %rename("_bt_ctf_get_int_signedness") bt_ctf_get_int_signedness(
509 const struct bt_declaration *field);
510 %rename("_bt_ctf_get_int_base") bt_ctf_get_int_base(const struct bt_declaration *field);
511 %rename("_bt_ctf_get_int_byte_order") bt_ctf_get_int_byte_order(
512 const struct bt_declaration *field);
513 %rename("_bt_ctf_get_int_len") bt_ctf_get_int_len(const struct bt_declaration *field);
514 %rename("_bt_ctf_get_enum_int") bt_ctf_get_enum_int(const struct bt_definition *field);
515 %rename("_bt_ctf_get_enum_str") bt_ctf_get_enum_str(const struct bt_definition *field);
516 %rename("_bt_ctf_get_encoding") bt_ctf_get_encoding(const struct bt_declaration *field);
517 %rename("_bt_ctf_get_array_len") bt_ctf_get_array_len(const struct bt_declaration *field);
518 %rename("_bt_ctf_get_uint64") bt_ctf_get_uint64(const struct bt_definition *field);
519 %rename("_bt_ctf_get_int64") bt_ctf_get_int64(const struct bt_definition *field);
520 %rename("_bt_ctf_get_char_array") bt_ctf_get_char_array(const struct bt_definition *field);
521 %rename("_bt_ctf_get_string") bt_ctf_get_string(const struct bt_definition *field);
522 %rename("_bt_ctf_get_float") bt_ctf_get_float(const struct bt_definition *field);
523 %rename("_bt_ctf_get_variant") bt_ctf_get_variant(const struct bt_definition *field);
524 %rename("_bt_ctf_field_get_error") bt_ctf_field_get_error(void);
525 %rename("_bt_ctf_get_decl_event_name") bt_ctf_get_decl_event_name(const struct
526 bt_ctf_event_decl *event);
527 %rename("_bt_ctf_get_decl_event_id") bt_ctf_get_decl_event_id(const struct
528 bt_ctf_event_decl *event);
529 %rename("_bt_ctf_get_decl_field_name") bt_ctf_get_decl_field_name(
530 const struct bt_ctf_field_decl *field);
531 %rename("_bt_ctf_get_decl_from_def") bt_ctf_get_decl_from_def(
532 const struct bt_definition *field);
533 %rename("_bt_ctf_get_decl_from_field_decl") bt_ctf_get_decl_from_field_decl(
534 const struct bt_ctf_field_decl *field);
535 %rename("_bt_array_index") bt_array_index(struct definition_array *array, uint64_t i);
536 %rename("_bt_sequence_len") bt_sequence_len(struct definition_sequence *sequence);
537 %rename("_bt_sequence_index") bt_sequence_index(struct definition_sequence *sequence, uint64_t i);
538 %rename("_bt_ctf_get_struct_field_count") bt_ctf_get_struct_field_count(const struct bt_definition *structure);
539 %rename("_bt_ctf_get_struct_field_index") bt_ctf_get_struct_field_index(const struct bt_definition *structure, uint64_t i);
540
541 const struct bt_definition *bt_ctf_get_top_level_scope(const struct bt_ctf_event *ctf_event,
542 enum bt_ctf_scope scope);
543 const char *bt_ctf_event_name(const struct bt_ctf_event *ctf_event);
544 uint64_t bt_ctf_get_timestamp(const struct bt_ctf_event *ctf_event);
545 uint64_t bt_ctf_get_cycles(const struct bt_ctf_event *ctf_event);
546 const struct bt_definition *bt_ctf_get_field(const struct bt_ctf_event *ctf_event,
547 const struct bt_definition *scope,
548 const char *field);
549 const struct bt_definition *bt_ctf_get_index(const struct bt_ctf_event *ctf_event,
550 const struct bt_definition *field,
551 unsigned int index);
552 const char *bt_ctf_field_name(const struct bt_definition *field);
553 enum ctf_type_id bt_ctf_field_type(const struct bt_declaration *field);
554 int bt_ctf_get_int_signedness(const struct bt_declaration *field);
555 int bt_ctf_get_int_base(const struct bt_declaration *field);
556 int bt_ctf_get_int_byte_order(const struct bt_declaration *field);
557 ssize_t bt_ctf_get_int_len(const struct bt_declaration *field);
558 const struct bt_definition *bt_ctf_get_enum_int(const struct bt_definition *field);
559 const char *bt_ctf_get_enum_str(const struct bt_definition *field);
560 enum ctf_string_encoding bt_ctf_get_encoding(const struct bt_declaration *field);
561 int bt_ctf_get_array_len(const struct bt_declaration *field);
562 struct bt_definition *bt_array_index(struct definition_array *array, uint64_t i);
563 uint64_t bt_ctf_get_uint64(const struct bt_definition *field);
564 int64_t bt_ctf_get_int64(const struct bt_definition *field);
565 char *bt_ctf_get_char_array(const struct bt_definition *field);
566 char *bt_ctf_get_string(const struct bt_definition *field);
567 double bt_ctf_get_float(const struct bt_definition *field);
568 const struct bt_definition *bt_ctf_get_variant(const struct bt_definition *field);
569 int bt_ctf_field_get_error(void);
570 const char *bt_ctf_get_decl_event_name(const struct bt_ctf_event_decl *event);
571 uint64_t bt_ctf_get_decl_event_id(const struct bt_ctf_event_decl *event);
572 const char *bt_ctf_get_decl_field_name(const struct bt_ctf_field_decl *field);
573 const struct bt_declaration *bt_ctf_get_decl_from_def(const struct bt_definition *field);
574 const struct bt_declaration *bt_ctf_get_decl_from_field_decl(const struct bt_ctf_field_decl *field);
575 uint64_t bt_sequence_len(struct definition_sequence *sequence);
576 struct bt_definition *bt_sequence_index(struct definition_sequence *sequence, uint64_t i);
577 uint64_t bt_ctf_get_struct_field_count(const struct bt_definition *structure);
578 const struct bt_definition *bt_ctf_get_struct_field_index(const struct bt_definition *structure, uint64_t i);
579
580 %pythoncode%{
581
582 class CTFStringEncoding:
583 NONE = 0
584 UTF8 = 1
585 ASCII = 2
586 UNKNOWN = 3
587
588 # Based on the enum in ctf-writer/writer.h
589 class ByteOrder:
590 BYTE_ORDER_NATIVE = 0
591 BYTE_ORDER_LITTLE_ENDIAN = 1
592 BYTE_ORDER_BIG_ENDIAN = 2
593 BYTE_ORDER_NETWORK = 3
594 BYTE_ORDER_UNKNOWN = 4 # Python-specific entry
595
596 #enum equivalent, accessible constants
597 #These are taken directly from ctf/events.h
598 #All changes to enums must also be made here
599 class CTFTypeId:
600 UNKNOWN = 0
601 INTEGER = 1
602 FLOAT = 2
603 ENUM = 3
604 STRING = 4
605 STRUCT = 5
606 UNTAGGED_VARIANT = 6
607 VARIANT = 7
608 ARRAY = 8
609 SEQUENCE = 9
610 NR_CTF_TYPES = 10
611 def type_name(id):
612 name = "UNKNOWN_TYPE"
613 constants = [attr for attr in dir(CTFTypeId) if not callable(getattr(CTFTypeId, attr)) and not attr.startswith("__")]
614 for attr in constants:
615 if getattr(CTFTypeId, attr) == id:
616 name = attr
617 break
618 return name
619
620 class CTFScope:
621 TRACE_PACKET_HEADER = 0
622 STREAM_PACKET_CONTEXT = 1
623 STREAM_EVENT_HEADER = 2
624 STREAM_EVENT_CONTEXT = 3
625 EVENT_CONTEXT = 4
626 EVENT_FIELDS = 5
627
628 def scope_name(scope):
629 name = "UNKNOWN_SCOPE"
630 constants = [attr for attr in dir(CTFScope) if not callable(getattr(CTFScope, attr)) and not attr.startswith("__")]
631 for attr in constants:
632 if getattr(CTFScope, attr) == scope:
633 name = attr
634 break
635 return name
636
637 # Priority of the scopes when searching for event fields
638 _scopes = [CTFScope.EVENT_FIELDS, CTFScope.EVENT_CONTEXT, CTFScope.STREAM_EVENT_CONTEXT,
639 CTFScope.STREAM_EVENT_HEADER, CTFScope.STREAM_PACKET_CONTEXT, CTFScope.TRACE_PACKET_HEADER]
640
641 import collections
642 class Event(collections.Mapping):
643 """
644 This class represents an event from the trace.
645 It is obtained using the TraceCollection generator functions.
646 Do not instantiate.
647 """
648 def __init__(self):
649 raise NotImplementedError("Event cannot be instantiated")
650
651 @property
652 def name(self):
653 """Return the name of the event or None on error."""
654 return _bt_ctf_event_name(self._e)
655
656 @property
657 def cycles(self):
658 """
659 Return the timestamp of the event as written in
660 the packet (in cycles) or -1ULL on error.
661 """
662 return _bt_ctf_get_cycles(self._e)
663
664 @property
665 def timestamp(self):
666 """
667 Return the timestamp of the event offset with the
668 system clock source or -1ULL on error.
669 """
670 return _bt_ctf_get_timestamp(self._e)
671
672 def field_with_scope(self, field_name, scope):
673 """
674 Get field_name's value in scope.
675 None is returned if no field matches field_name.
676 """
677 if not scope in _scopes:
678 raise ValueError("Invalid scope provided")
679 field = self._field_with_scope(field_name, scope)
680 if field is not None:
681 return field.value
682 return None
683
684 def field_list_with_scope(self, scope):
685 """Return a list of field names in scope."""
686 if not scope in _scopes:
687 raise ValueError("Invalid scope provided")
688 field_names = []
689 for field in self._field_list_with_scope(scope):
690 field_names.append(field.name)
691 return field_names
692
693 @property
694 def handle(self):
695 """
696 Get the TraceHandle associated with this event
697 Return None on error
698 """
699 ret = _bt_ctf_event_get_handle_id(self._e)
700 if ret < 0:
701 return None
702
703 th = TraceHandle.__new__(TraceHandle)
704 th._id = ret
705 th._trace_collection = self.get_trace_collection()
706 return th
707
708 @property
709 def trace_collection(self):
710 """
711 Get the TraceCollection associated with this event.
712 Return None on error.
713 """
714 trace_collection = TraceCollection()
715 trace_collection._tc = _bt_ctf_event_get_context(self._e);
716 if trace_collection._tc is None:
717 return None
718 else:
719 return trace_collection
720
721 def __getitem__(self, field_name):
722 """
723 Get field_name's value. If the field_name exists in multiple
724 scopes, the first field found is returned. The scopes are searched
725 in the following order:
726 1) EVENT_FIELDS
727 2) EVENT_CONTEXT
728 3) STREAM_EVENT_CONTEXT
729 4) STREAM_EVENT_HEADER
730 5) STREAM_PACKET_CONTEXT
731 6) TRACE_PACKET_HEADER
732 None is returned if no field matches field_name.
733
734 Use field_with_scope() to explicitly access fields in a given
735 scope.
736 """
737 field = self._field(field_name)
738 if field is not None:
739 return field.value
740 raise KeyError(field_name)
741
742 def __iter__(self):
743 for key in self.keys():
744 yield key
745
746 def __len__(self):
747 count = 0
748 for scope in _scopes:
749 scope_ptr = _bt_ctf_get_top_level_scope(self._e, scope)
750 ret = _bt_python_field_listcaller(self._e, scope_ptr)
751 if isinstance(ret, list):
752 count += ret[1]
753 return count
754
755 def __contains__(self, field_name):
756 return self._field(field_name) is not None
757
758 def keys(self):
759 """Return a list of field names."""
760 field_names = set()
761 for scope in _scopes:
762 for name in self.field_list_with_scope(scope):
763 field_names.add(name)
764 return list(field_names)
765
766 def get(self, field_name, default = None):
767 field = self._field(field_name)
768 if field is None:
769 return default
770 return field.value
771
772 def items(self):
773 for field in self.keys():
774 yield (field, self[field])
775
776 def _field_with_scope(self, field_name, scope):
777 scope_ptr = _bt_ctf_get_top_level_scope(self._e, scope)
778 if scope_ptr is None:
779 return None
780
781 definition_ptr = _bt_ctf_get_field(self._e, scope_ptr, field_name)
782 if definition_ptr is None:
783 return None
784
785 field = _Definition(definition_ptr, scope)
786 return field
787
788 def _field(self, field_name):
789 field = None
790 for scope in _scopes:
791 field = self._field_with_scope(field_name, scope)
792 if field is not None:
793 break
794 return field
795
796 def _field_list_with_scope(self, scope):
797 fields = []
798 scope_ptr = _bt_ctf_get_top_level_scope(self._e, scope)
799
800 # Returns a list [list_ptr, count]. If list_ptr is NULL, SWIG will only
801 # provide the "count" return value
802 count = 0
803 list_ptr = None
804 ret = _bt_python_field_listcaller(self._e, scope_ptr)
805 if isinstance(ret, list):
806 list_ptr, count = ret
807
808 for i in range(count):
809 definition_ptr = _bt_python_field_one_from_list(list_ptr, i)
810 if definition_ptr is not None:
811 definition = _Definition(definition_ptr, scope)
812 fields.append(definition)
813 return fields
814
815 class FieldError(Exception):
816 def __init__(self, value):
817 self.value = value
818
819 def __str__(self):
820 return repr(self.value)
821
822 class EventDeclaration(object):
823 """Event declaration class. Do not instantiate."""
824 MAX_UINT64 = 0xFFFFFFFFFFFFFFFF
825
826 def __init__(self):
827 raise NotImplementedError("EventDeclaration cannot be instantiated")
828
829 @property
830 def name(self):
831 """Return the name of the event or None on error"""
832 return _bt_ctf_get_decl_event_name(self._ed)
833
834 @property
835 def id(self):
836 """Return the event-ID of the event or -1 on error"""
837 id = _bt_ctf_get_decl_event_id(self._ed)
838 if id == self.MAX_UINT64:
839 id = -1
840 return id
841
842 @property
843 def fields(self):
844 """
845 Generator returning all FieldDeclarations of an event, going through
846 each scope in the following order:
847 1) EVENT_FIELDS
848 2) EVENT_CONTEXT
849 3) STREAM_EVENT_CONTEXT
850 4) STREAM_EVENT_HEADER
851 5) STREAM_PACKET_CONTEXT
852 6) TRACE_PACKET_HEADER
853 """
854 for scope in _scopes:
855 for declaration in self.fields_scope(scope):
856 yield declaration
857
858 def fields_scope(self, scope):
859 """
860 Generator returning FieldDeclarations of the current event in scope.
861 """
862 ret = _by_python_field_decl_listcaller(self._ed, scope)
863
864 if not isinstance(ret, list):
865 return
866
867 list_ptr, count = ret
868 for i in range(count):
869 field_declaration_ptr = _bt_python_field_decl_one_from_list(list_ptr, i)
870 if field_declaration_ptr is not None:
871 declaration_ptr = _bt_ctf_get_decl_from_field_decl(field_declaration_ptr)
872 field_declaration = _create_field_declaration(declaration_ptr, _bt_ctf_get_decl_field_name(field_declaration_ptr), scope)
873 yield field_declaration
874
875 class FieldDeclaration(object):
876 """Field declaration class. Do not instantiate."""
877 def __init__(self):
878 raise NotImplementedError("FieldDeclaration cannot be instantiated")
879
880 def __repr__(self):
881 return "({0}) {1} {2}".format(CTFScope.scope_name(self.scope), CTFTypeId.type_name(self.type), self.name)
882
883 @property
884 def name(self):
885 """Return the name of a FieldDeclaration or None on error."""
886 return self._name
887
888 @property
889 def type(self):
890 """
891 Return the FieldDeclaration's type. One of the entries in class
892 CTFTypeId.
893 """
894 return _bt_ctf_field_type(self._fd)
895
896 @property
897 def scope(self):
898 """
899 Return the FieldDeclaration's scope.
900 """
901 return self._s
902
903 class IntegerFieldDeclaration(FieldDeclaration):
904 """Do not instantiate."""
905 def __init__(self):
906 raise NotImplementedError("IntegerFieldDeclaration cannot be instantiated")
907
908 @property
909 def signedness(self):
910 """
911 Return the signedness of an integer:
912 0 if unsigned; 1 if signed; -1 on error.
913 """
914 return _bt_ctf_get_int_signedness(self._fd)
915
916 @property
917 def base(self):
918 """Return the base of an int or a negative value on error."""
919 return _bt_ctf_get_int_base(self._fd)
920
921 @property
922 def byte_order(self):
923 """
924 Return the byte order. One of class ByteOrder's entries.
925 """
926 ret = _bt_ctf_get_int_byte_order(self._fd)
927 if ret == 1234:
928 return ByteOrder.BYTE_ORDER_LITTLE_ENDIAN
929 elif ret == 4321:
930 return ByteOrder.BYTE_ORDER_BIG_ENDIAN
931 else:
932 return ByteOrder.BYTE_ORDER_UNKNOWN
933
934 @property
935 def length(self):
936 """
937 Return the size, in bits, of an int or a negative
938 value on error.
939 """
940 return _bt_ctf_get_int_len(self._fd)
941
942 @property
943 def encoding(self):
944 """
945 Return the encoding. One of class CTFStringEncoding's entries.
946 Return a negative value on error.
947 """
948 return _bt_ctf_get_encoding(self._fd)
949
950 class EnumerationFieldDeclaration(FieldDeclaration):
951 """Do not instantiate."""
952 def __init__(self):
953 raise NotImplementedError("EnumerationFieldDeclaration cannot be instantiated")
954
955 class ArrayFieldDeclaration(FieldDeclaration):
956 """Do not instantiate."""
957 def __init__(self):
958 raise NotImplementedError("ArrayFieldDeclaration cannot be instantiated")
959
960 @property
961 def length(self):
962 """
963 Return the length of an array or a negative
964 value on error.
965 """
966 return _bt_ctf_get_array_len(self._fd)
967
968 @property
969 def element_declaration(self):
970 """
971 Return element declaration.
972 """
973 field_decl_ptr = _bt_python_get_array_element_declaration(self._fd)
974 return _create_field_declaration(field_decl_ptr, "", self.scope)
975
976 class SequenceFieldDeclaration(FieldDeclaration):
977 """Do not instantiate."""
978 def __init__(self):
979 raise NotImplementedError("SequenceFieldDeclaration cannot be instantiated")
980
981 @property
982 def element_declaration(self):
983 """
984 Return element declaration.
985 """
986 field_decl_ptr = _bt_python_get_sequence_element_declaration(self._fd)
987 return _create_field_declaration(field_decl_ptr, "", self.scope)
988
989 class FloatFieldDeclaration(FieldDeclaration):
990 """Do not instantiate."""
991 def __init__(self):
992 raise NotImplementedError("FloatFieldDeclaration cannot be instantiated")
993
994 class StructureFieldDeclaration(FieldDeclaration):
995 """Do not instantiate."""
996 def __init__(self):
997 raise NotImplementedError("StructureFieldDeclaration cannot be instantiated")
998
999 class StringFieldDeclaration(FieldDeclaration):
1000 """Do not instantiate."""
1001 def __init__(self):
1002 raise NotImplementedError("StringFieldDeclaration cannot be instantiated")
1003
1004 class VariantFieldDeclaration(FieldDeclaration):
1005 """Do not instantiate."""
1006 def __init__(self):
1007 raise NotImplementedError("VariantFieldDeclaration cannot be instantiated")
1008
1009 def field_error():
1010 """
1011 Return the last error code encountered while
1012 accessing a field and reset the error flag.
1013 Return 0 if no error, a negative value otherwise.
1014 """
1015 return _bt_ctf_field_get_error()
1016
1017 def _create_field_declaration(declaration_ptr, name, scope):
1018 """
1019 Private field declaration factory.
1020 """
1021 if declaration_ptr is None:
1022 raise ValueError("declaration_ptr must be valid")
1023 if not scope in _scopes:
1024 raise ValueError("Invalid scope provided")
1025
1026 type = _bt_ctf_field_type(declaration_ptr)
1027 declaration = None
1028 if type == CTFTypeId.INTEGER:
1029 declaration = IntegerFieldDeclaration.__new__(IntegerFieldDeclaration)
1030 elif type == CTFTypeId.ENUM:
1031 declaration = EnumerationFieldDeclaration.__new__(EnumerationFieldDeclaration)
1032 elif type == CTFTypeId.ARRAY:
1033 declaration = ArrayFieldDeclaration.__new__(ArrayFieldDeclaration)
1034 elif type == CTFTypeId.SEQUENCE:
1035 declaration = SequenceFieldDeclaration.__new__(SequenceFieldDeclaration)
1036 elif type == CTFTypeId.FLOAT:
1037 declaration = FloatFieldDeclaration.__new__(FloatFieldDeclaration)
1038 elif type == CTFTypeId.STRUCT:
1039 declaration = StructureFieldDeclaration.__new__(StructureFieldDeclaration)
1040 elif type == CTFTypeId.STRING:
1041 declaration = StringFieldDeclaration.__new__(StringFieldDeclaration)
1042 elif type == CTFTypeId.VARIANT:
1043 declaration = VariantFieldDeclaration.__new__(VariantFieldDeclaration)
1044 else:
1045 return declaration
1046
1047 declaration._fd = declaration_ptr
1048 declaration._s = scope
1049 declaration._name = name
1050 return declaration
1051
1052 class _Definition(object):
1053 def __init__(self, definition_ptr, scope):
1054 self._d = definition_ptr
1055 self._s = scope
1056 if not scope in _scopes:
1057 ValueError("Invalid scope provided")
1058
1059 @property
1060 def name(self):
1061 """Return the name of a field or None on error."""
1062 return _bt_ctf_field_name(self._d)
1063
1064 @property
1065 def type(self):
1066 """Return the type of a field or -1 if unknown."""
1067 return _bt_ctf_field_type(_bt_ctf_get_decl_from_def(self._d))
1068
1069 @property
1070 def declaration(self):
1071 """Return the associated Definition object."""
1072 return _create_field_declaration(_bt_ctf_get_decl_from_def(self._d), self.name, self.scope)
1073
1074 def _get_enum_str(self):
1075 """
1076 Return the string matching the current enumeration.
1077 Return None on error.
1078 """
1079 return _bt_ctf_get_enum_str(self._d)
1080
1081 def _get_array_element_at(self, index):
1082 """
1083 Return the array's element at position index.
1084 Return None on error
1085 """
1086 array_ptr = _bt_python_get_array_from_def(self._d)
1087 if array_ptr is None:
1088 return None
1089
1090 definition_ptr = _bt_array_index(array_ptr, index)
1091 if definition_ptr is None:
1092 return None
1093 return _Definition(definition_ptr, self.scope)
1094
1095 def _get_sequence_len(self):
1096 """
1097 Return the len of a sequence or a negative
1098 value on error.
1099 """
1100 seq = _bt_python_get_sequence_from_def(self._d)
1101 return _bt_sequence_len(seq)
1102
1103 def _get_sequence_element_at(self, index):
1104 """
1105 Return the sequence's element at position index,
1106 otherwise return None
1107 """
1108 seq = _bt_python_get_sequence_from_def(self._d)
1109 if seq is not None:
1110 definition_ptr = _bt_sequence_index(seq, index)
1111 if definition_ptr is not None:
1112 return _Definition(definition_ptr, self.scope)
1113 return None
1114
1115 def _get_uint64(self):
1116 """
1117 Return the value associated with the field.
1118 If the field does not exist or is not of the type requested,
1119 the value returned is undefined. To check if an error occured,
1120 use the field_error() function after accessing a field.
1121 """
1122 return _bt_ctf_get_uint64(self._d)
1123
1124 def _get_int64(self):
1125 """
1126 Return the value associated with the field.
1127 If the field does not exist or is not of the type requested,
1128 the value returned is undefined. To check if an error occured,
1129 use the field_error() function after accessing a field.
1130 """
1131 return _bt_ctf_get_int64(self._d)
1132
1133 def _get_char_array(self):
1134 """
1135 Return the value associated with the field.
1136 If the field does not exist or is not of the type requested,
1137 the value returned is undefined. To check if an error occurred,
1138 use the field_error() function after accessing a field.
1139 """
1140 return _bt_ctf_get_char_array(self._d)
1141
1142 def _get_str(self):
1143 """
1144 Return the value associated with the field.
1145 If the field does not exist or is not of the type requested,
1146 the value returned is undefined. To check if an error occurred,
1147 use the field_error() function after accessing a field.
1148 """
1149 return _bt_ctf_get_string(self._d)
1150
1151 def _get_float(self):
1152 """
1153 Return the value associated with the field.
1154 If the field does not exist or is not of the type requested,
1155 the value returned is undefined. To check if an error occurred,
1156 use the field_error() function after accessing a field.
1157 """
1158 return _bt_ctf_get_float(self._d)
1159
1160 def _get_variant(self):
1161 """
1162 Return the variant's selected field.
1163 If the field does not exist or is not of the type requested,
1164 the value returned is undefined. To check if an error occurred,
1165 use the field_error() function after accessing a field.
1166 """
1167 return _bt_ctf_get_variant(self._d)
1168
1169 def _get_struct_field_count(self):
1170 """
1171 Return the number of fields contained in the structure.
1172 If the field does not exist or is not of the type requested,
1173 the value returned is undefined.
1174 """
1175 return _bt_ctf_get_struct_field_count(self._d)
1176
1177 def _get_struct_field_at(self, i):
1178 """
1179 Return the structure's field at position i.
1180 If the field does not exist or is not of the type requested,
1181 the value returned is undefined. To check if an error occurred,
1182 use the field_error() function after accessing a field.
1183 """
1184 return _bt_ctf_get_struct_field_index(self._d, i)
1185
1186 @property
1187 def value(self):
1188 """
1189 Return the value associated with the field according to its type.
1190 Return None on error.
1191 """
1192 id = self.type
1193 value = None
1194
1195 if id == CTFTypeId.STRING:
1196 value = self._get_str()
1197 elif id == CTFTypeId.ARRAY:
1198 element_decl = self.declaration.element_declaration
1199 if ((element_decl.type == CTFTypeId.INTEGER
1200 and element_decl.length == 8)
1201 and (element_decl.encoding == CTFStringEncoding.ASCII or element_decl.encoding == CTFStringEncoding.UTF8)):
1202 value = _bt_python_get_array_string(self._d)
1203 else:
1204 value = []
1205 for i in range(self.declaration.length):
1206 element = self._get_array_element_at(i)
1207 value.append(element.value)
1208 elif id == CTFTypeId.INTEGER:
1209 if self.declaration.signedness == 0:
1210 value = self._get_uint64()
1211 else:
1212 value = self._get_int64()
1213 elif id == CTFTypeId.ENUM:
1214 value = self._get_enum_str()
1215 elif id == CTFTypeId.SEQUENCE:
1216 element_decl = self.declaration.element_declaration
1217 if ((element_decl.type == CTFTypeId.INTEGER
1218 and element_decl.length == 8)
1219 and (element_decl.encoding == CTFStringEncoding.ASCII or element_decl.encoding == CTFStringEncoding.UTF8)):
1220 value = _bt_python_get_sequence_string(self._d)
1221 else:
1222 seq_len = self._get_sequence_len()
1223 value = []
1224 for i in range(seq_len):
1225 evDef = self._get_sequence_element_at(i)
1226 value.append(evDef.value)
1227 elif id == CTFTypeId.FLOAT:
1228 value = self._get_float()
1229 elif id == CTFTypeId.VARIANT:
1230 variant = _Definition.__new__(_Definition)
1231 variant._d = self._get_variant();
1232 value = variant.value
1233 elif id == CTFTypeId.STRUCT:
1234 value = {}
1235 for i in range(self._get_struct_field_count()):
1236 member = _Definition(self._get_struct_field_at(i), self.scope)
1237 value[member.name] = member.value
1238
1239 if field_error():
1240 raise FieldError("Error occurred while accessing field {} of type {}".format(self.name, CTFTypeId.type_name(id)))
1241 return value
1242
1243 @property
1244 def scope(self):
1245 """Return the scope of a field or None on error."""
1246 return self._s
1247
1248 %}
1249
1250
1251 // =================================================================
1252 // CTF Writer
1253 // =================================================================
1254
1255 /* =================================================================
1256 CLOCK.H
1257 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
1258 */
1259 %rename("_bt_ctf_clock_create") bt_ctf_clock_create(const char *name);
1260 %rename("_bt_ctf_clock_get_name") bt_ctf_clock_get_name(struct bt_ctf_clock *clock);
1261 %rename("_bt_ctf_clock_get_description") bt_ctf_clock_get_description(struct bt_ctf_clock *clock);
1262 %rename("_bt_ctf_clock_set_description") bt_ctf_clock_set_description(struct bt_ctf_clock *clock, const char *desc);
1263 %rename("_bt_ctf_clock_get_frequency") bt_ctf_clock_get_frequency(struct bt_ctf_clock *clock);
1264 %rename("_bt_ctf_clock_set_frequency") bt_ctf_clock_set_frequency(struct bt_ctf_clock *clock, uint64_t freq);
1265 %rename("_bt_ctf_clock_get_precision") bt_ctf_clock_get_precision(struct bt_ctf_clock *clock);
1266 %rename("_bt_ctf_clock_set_precision") bt_ctf_clock_set_precision(struct bt_ctf_clock *clock, uint64_t precision);
1267 %rename("_bt_ctf_clock_get_offset_s") bt_ctf_clock_get_offset_s(struct bt_ctf_clock *clock);
1268 %rename("_bt_ctf_clock_set_offset_s") bt_ctf_clock_set_offset_s(struct bt_ctf_clock *clock, uint64_t offset_s);
1269 %rename("_bt_ctf_clock_get_offset") bt_ctf_clock_get_offset(struct bt_ctf_clock *clock);
1270 %rename("_bt_ctf_clock_set_offset") bt_ctf_clock_set_offset(struct bt_ctf_clock *clock, uint64_t offset);
1271 %rename("_bt_ctf_clock_get_is_absolute") bt_ctf_clock_get_is_absolute(struct bt_ctf_clock *clock);
1272 %rename("_bt_ctf_clock_set_is_absolute") bt_ctf_clock_set_is_absolute(struct bt_ctf_clock *clock, int is_absolute);
1273 %rename("_bt_ctf_clock_get_time") bt_ctf_clock_get_time(struct bt_ctf_clock *clock);
1274 %rename("_bt_ctf_clock_set_time") bt_ctf_clock_set_time(struct bt_ctf_clock *clock, uint64_t time);
1275 %rename("_bt_ctf_clock_get") bt_ctf_clock_get(struct bt_ctf_clock *clock);
1276 %rename("_bt_ctf_clock_put") bt_ctf_clock_put(struct bt_ctf_clock *clock);
1277
1278 struct bt_ctf_clock *bt_ctf_clock_create(const char *name);
1279 const char *bt_ctf_clock_get_name(struct bt_ctf_clock *clock);
1280 const char *bt_ctf_clock_get_description(struct bt_ctf_clock *clock);
1281 int bt_ctf_clock_set_description(struct bt_ctf_clock *clock, const char *desc);
1282 uint64_t bt_ctf_clock_get_frequency(struct bt_ctf_clock *clock);
1283 int bt_ctf_clock_set_frequency(struct bt_ctf_clock *clock, uint64_t freq);
1284 uint64_t bt_ctf_clock_get_precision(struct bt_ctf_clock *clock);
1285 int bt_ctf_clock_set_precision(struct bt_ctf_clock *clock, uint64_t precision);
1286 uint64_t bt_ctf_clock_get_offset_s(struct bt_ctf_clock *clock);
1287 int bt_ctf_clock_set_offset_s(struct bt_ctf_clock *clock, uint64_t offset_s);
1288 uint64_t bt_ctf_clock_get_offset(struct bt_ctf_clock *clock);
1289 int bt_ctf_clock_set_offset(struct bt_ctf_clock *clock, uint64_t offset);
1290 int bt_ctf_clock_get_is_absolute(struct bt_ctf_clock *clock);
1291 int bt_ctf_clock_set_is_absolute(struct bt_ctf_clock *clock, int is_absolute);
1292 uint64_t bt_ctf_clock_get_time(struct bt_ctf_clock *clock);
1293 int bt_ctf_clock_set_time(struct bt_ctf_clock *clock, uint64_t time);
1294 void bt_ctf_clock_get(struct bt_ctf_clock *clock);
1295 void bt_ctf_clock_put(struct bt_ctf_clock *clock);
1296
1297 /* =================================================================
1298 EVENT-TYPES.H
1299 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
1300 */
1301 %rename("_bt_ctf_field_type_integer_create") bt_ctf_field_type_integer_create(unsigned int size);
1302 %rename("_bt_ctf_field_type_integer_get_size") bt_ctf_field_type_integer_get_size(struct bt_ctf_field_type *integer);
1303 %rename("_bt_ctf_field_type_integer_get_signed") bt_ctf_field_type_integer_get_signed(struct bt_ctf_field_type *integer);
1304 %rename("_bt_ctf_field_type_integer_set_signed") bt_ctf_field_type_integer_set_signed(struct bt_ctf_field_type *integer, int is_signed);
1305 %rename("_bt_ctf_field_type_integer_get_base") bt_ctf_field_type_integer_get_base(struct bt_ctf_field_type *integer);
1306 %rename("_bt_ctf_field_type_integer_set_base") bt_ctf_field_type_integer_set_base(struct bt_ctf_field_type *integer, enum bt_ctf_integer_base base);
1307 %rename("_bt_ctf_field_type_integer_get_encoding") bt_ctf_field_type_integer_get_encoding(struct bt_ctf_field_type *integer);
1308 %rename("_bt_ctf_field_type_integer_set_encoding") bt_ctf_field_type_integer_set_encoding(struct bt_ctf_field_type *integer, enum ctf_string_encoding encoding);
1309 %rename("_bt_ctf_field_type_enumeration_create") bt_ctf_field_type_enumeration_create(struct bt_ctf_field_type *integer_container_type);
1310 %rename("_bt_ctf_field_type_enumeration_get_container_type") bt_ctf_field_type_enumeration_get_container_type(struct bt_ctf_field_type *enumeration);
1311 %rename("_bt_ctf_field_type_enumeration_add_mapping") bt_ctf_field_type_enumeration_add_mapping(struct bt_ctf_field_type *enumeration, const char *name, int64_t range_start, int64_t range_end);
1312 %rename("_bt_ctf_field_type_enumeration_add_mapping_unsigned") bt_ctf_field_type_enumeration_add_mapping_unsigned(struct bt_ctf_field_type *enumeration, const char *name, uint64_t range_start, uint64_t range_end);
1313 %rename("_bt_ctf_field_type_enumeration_get_mapping_count") bt_ctf_field_type_enumeration_get_mapping_count(struct bt_ctf_field_type *enumeration);
1314 %rename("_bt_ctf_field_type_enumeration_get_mapping") bt_ctf_field_type_enumeration_get_mapping(struct bt_ctf_field_type *enumeration, size_t index, const char **name, int64_t *range_start, int64_t *range_end);
1315 %rename("_bt_ctf_field_type_enumeration_get_mapping_unsigned") bt_ctf_field_type_enumeration_get_mapping_unsigned(struct bt_ctf_field_type *enumeration, size_t index, const char **name, uint64_t *range_start, uint64_t *range_end);
1316 %rename("_bt_ctf_field_type_enumeration_get_mapping_index_by_name") bt_ctf_field_type_enumeration_get_mapping_index_by_name(struct bt_ctf_field_type *enumeration, const char *name, size_t *index);
1317 %rename("_bt_ctf_field_type_enumeration_get_mapping_index_by_value") bt_ctf_field_type_enumeration_get_mapping_index_by_value(struct bt_ctf_field_type *enumeration, int64_t value, size_t *index);
1318 %rename("_bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value") bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value(struct bt_ctf_field_type *enumeration, uint64_t value, size_t *index);
1319 %rename("_bt_ctf_field_type_floating_point_create") bt_ctf_field_type_floating_point_create(void);
1320 %rename("_bt_ctf_field_type_floating_point_get_exponent_digits") bt_ctf_field_type_floating_point_get_exponent_digits(struct bt_ctf_field_type *floating_point);
1321 %rename("_bt_ctf_field_type_floating_point_set_exponent_digits") bt_ctf_field_type_floating_point_set_exponent_digits(struct bt_ctf_field_type *floating_point, unsigned int exponent_digits);
1322 %rename("_bt_ctf_field_type_floating_point_get_mantissa_digits") bt_ctf_field_type_floating_point_get_mantissa_digits(struct bt_ctf_field_type *floating_point);
1323 %rename("_bt_ctf_field_type_floating_point_set_mantissa_digits") bt_ctf_field_type_floating_point_set_mantissa_digits(struct bt_ctf_field_type *floating_point, unsigned int mantissa_digits);
1324 %rename("_bt_ctf_field_type_structure_create") bt_ctf_field_type_structure_create(void);
1325 %rename("_bt_ctf_field_type_structure_add_field") bt_ctf_field_type_structure_add_field(struct bt_ctf_field_type *structure, struct bt_ctf_field_type *field_type, const char *field_name);
1326 %rename("_bt_ctf_field_type_structure_get_field_count") bt_ctf_field_type_structure_get_field_count(struct bt_ctf_field_type *structure);
1327 %rename("_bt_ctf_field_type_structure_get_field") bt_ctf_field_type_structure_get_field(struct bt_ctf_field_type *structure, const char **field_name, struct bt_ctf_field_type **field_type, size_t index);
1328 %rename("_bt_ctf_field_type_structure_get_field_type_by_name") bt_ctf_field_type_structure_get_field_type_by_name(struct bt_ctf_field_type *structure, const char *field_name);
1329 %rename("_bt_ctf_field_type_variant_create") bt_ctf_field_type_variant_create(struct bt_ctf_field_type *enum_tag, const char *tag_name);
1330 %rename("_bt_ctf_field_type_variant_get_tag_type") bt_ctf_field_type_variant_get_tag_type(struct bt_ctf_field_type *variant);
1331 %rename("_bt_ctf_field_type_variant_get_tag_name") bt_ctf_field_type_variant_get_tag_name(struct bt_ctf_field_type *variant);
1332 %rename("_bt_ctf_field_type_variant_add_field") bt_ctf_field_type_variant_add_field(struct bt_ctf_field_type *variant, struct bt_ctf_field_type *field_type, const char *field_name);
1333 %rename("_bt_ctf_field_type_variant_get_field_type_by_name") bt_ctf_field_type_variant_get_field_type_by_name(struct bt_ctf_field_type *variant, const char *field_name);
1334 %rename("_bt_ctf_field_type_variant_get_field_type_from_tag") bt_ctf_field_type_variant_get_field_type_from_tag(struct bt_ctf_field_type *variant, struct bt_ctf_field *tag);
1335 %rename("_bt_ctf_field_type_variant_get_field_count") bt_ctf_field_type_variant_get_field_count(struct bt_ctf_field_type *variant);
1336 %rename("_bt_ctf_field_type_variant_get_field") bt_ctf_field_type_variant_get_field(struct bt_ctf_field_type *variant, const char **field_name, struct bt_ctf_field_type **field_type, size_t index);
1337 %rename("_bt_ctf_field_type_array_create") bt_ctf_field_type_array_create(struct bt_ctf_field_type *element_type, unsigned int length);
1338 %rename("_bt_ctf_field_type_array_get_element_type") bt_ctf_field_type_array_get_element_type(struct bt_ctf_field_type *array);
1339 %rename("_bt_ctf_field_type_array_get_length") bt_ctf_field_type_array_get_length(struct bt_ctf_field_type *array);
1340 %rename("_bt_ctf_field_type_sequence_create") bt_ctf_field_type_sequence_create(struct bt_ctf_field_type *element_type, const char *length_field_name);
1341 %rename("_bt_ctf_field_type_sequence_get_element_type") bt_ctf_field_type_sequence_get_element_type(struct bt_ctf_field_type *sequence);
1342 %rename("_bt_ctf_field_type_sequence_get_length_field_name") bt_ctf_field_type_sequence_get_length_field_name(struct bt_ctf_field_type *sequence);
1343 %rename("_bt_ctf_field_type_string_create") bt_ctf_field_type_string_create(void);
1344 %rename("_bt_ctf_field_type_string_get_encoding") bt_ctf_field_type_string_get_encoding(struct bt_ctf_field_type *string_type);
1345 %rename("_bt_ctf_field_type_string_set_encoding") bt_ctf_field_type_string_set_encoding(struct bt_ctf_field_type *string_type, enum ctf_string_encoding encoding);
1346 %rename("_bt_ctf_field_type_get_alignment") bt_ctf_field_type_get_alignment(struct bt_ctf_field_type *type);
1347 %rename("_bt_ctf_field_type_set_alignment") bt_ctf_field_type_set_alignment(struct bt_ctf_field_type *type, unsigned int alignment);
1348 %rename("_bt_ctf_field_type_get_byte_order") bt_ctf_field_type_get_byte_order(struct bt_ctf_field_type *type);
1349 %rename("_bt_ctf_field_type_set_byte_order") bt_ctf_field_type_set_byte_order(struct bt_ctf_field_type *type, enum bt_ctf_byte_order byte_order);
1350 %rename("_bt_ctf_field_type_get_type_id") bt_ctf_field_type_get_type_id(struct bt_ctf_field_type *type);
1351 %rename("_bt_ctf_field_type_get") bt_ctf_field_type_get(struct bt_ctf_field_type *type);
1352 %rename("_bt_ctf_field_type_put") bt_ctf_field_type_put(struct bt_ctf_field_type *type);
1353
1354 struct bt_ctf_field_type *bt_ctf_field_type_integer_create(unsigned int size);
1355 int bt_ctf_field_type_integer_get_size(struct bt_ctf_field_type *integer);
1356 int bt_ctf_field_type_integer_get_signed(struct bt_ctf_field_type *integer);
1357 int bt_ctf_field_type_integer_set_signed(struct bt_ctf_field_type *integer, int is_signed);
1358 enum bt_ctf_integer_base bt_ctf_field_type_integer_get_base(struct bt_ctf_field_type *integer);
1359 int bt_ctf_field_type_integer_set_base(struct bt_ctf_field_type *integer, enum bt_ctf_integer_base base);
1360 enum ctf_string_encoding bt_ctf_field_type_integer_get_encoding(struct bt_ctf_field_type *integer);
1361 int bt_ctf_field_type_integer_set_encoding(struct bt_ctf_field_type *integer, enum ctf_string_encoding encoding);
1362 struct bt_ctf_field_type *bt_ctf_field_type_enumeration_create(struct bt_ctf_field_type *integer_container_type);
1363 struct bt_ctf_field_type *bt_ctf_field_type_enumeration_get_container_type(struct bt_ctf_field_type *enumeration);
1364 int bt_ctf_field_type_enumeration_add_mapping(struct bt_ctf_field_type *enumeration, const char *name, int64_t range_start, int64_t range_end);
1365 int bt_ctf_field_type_enumeration_add_mapping_unsigned(struct bt_ctf_field_type *enumeration, const char *name, uint64_t range_start, uint64_t range_end);
1366 int64_t bt_ctf_field_type_enumeration_get_mapping_count(struct bt_ctf_field_type *enumeration);
1367 int bt_ctf_field_type_enumeration_get_mapping(struct bt_ctf_field_type *enumeration, size_t index, const char **OUTPUT, int64_t *OUTPUT, int64_t *OUTPUT);
1368 int bt_ctf_field_type_enumeration_get_mapping_unsigned(struct bt_ctf_field_type *enumeration, size_t index, const char **OUTPUT, uint64_t *OUTPUT, uint64_t *OUTPUT);
1369 int bt_ctf_field_type_enumeration_get_mapping_index_by_name(struct bt_ctf_field_type *enumeration, const char *name, size_t *OUTPUT);
1370 int bt_ctf_field_type_enumeration_get_mapping_index_by_value(struct bt_ctf_field_type *enumeration, int64_t value, size_t *OUTPUT);
1371 int bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value(struct bt_ctf_field_type *enumeration, uint64_t value, size_t *OUTPUT);
1372 struct bt_ctf_field_type *bt_ctf_field_type_floating_point_create(void);
1373 int bt_ctf_field_type_floating_point_get_exponent_digits(struct bt_ctf_field_type *floating_point);
1374 int bt_ctf_field_type_floating_point_set_exponent_digits(struct bt_ctf_field_type *floating_point, unsigned int exponent_digits);
1375 int bt_ctf_field_type_floating_point_get_mantissa_digits(struct bt_ctf_field_type *floating_point);
1376 int bt_ctf_field_type_floating_point_set_mantissa_digits(struct bt_ctf_field_type *floating_point, unsigned int mantissa_digits);
1377 struct bt_ctf_field_type *bt_ctf_field_type_structure_create(void);
1378 int bt_ctf_field_type_structure_add_field(struct bt_ctf_field_type *structure, struct bt_ctf_field_type *field_type, const char *field_name);
1379 int64_t bt_ctf_field_type_structure_get_field_count(struct bt_ctf_field_type *structure);
1380 int bt_ctf_field_type_structure_get_field(struct bt_ctf_field_type *structure, const char **OUTPUT, struct bt_ctf_field_type **OUTPUT, size_t index);
1381 struct bt_ctf_field_type *bt_ctf_field_type_structure_get_field_type_by_name(struct bt_ctf_field_type *structure, const char *field_name);
1382 struct bt_ctf_field_type *bt_ctf_field_type_variant_create(struct bt_ctf_field_type *enum_tag, const char *tag_name);
1383 struct bt_ctf_field_type *bt_ctf_field_type_variant_get_tag_type(struct bt_ctf_field_type *variant);
1384 const char *bt_ctf_field_type_variant_get_tag_name(struct bt_ctf_field_type *variant);
1385 int bt_ctf_field_type_variant_add_field(struct bt_ctf_field_type *variant, struct bt_ctf_field_type *field_type, const char *field_name);
1386 struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_by_name(struct bt_ctf_field_type *variant, const char *field_name);
1387 struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_from_tag(struct bt_ctf_field_type *variant, struct bt_ctf_field *tag);
1388 int64_t bt_ctf_field_type_variant_get_field_count(struct bt_ctf_field_type *variant);
1389 int bt_ctf_field_type_variant_get_field(struct bt_ctf_field_type *variant, const char **OUTPUT, struct bt_ctf_field_type **OUTPUT, size_t index);
1390 struct bt_ctf_field_type *bt_ctf_field_type_array_create(struct bt_ctf_field_type *element_type, unsigned int length);
1391 struct bt_ctf_field_type *bt_ctf_field_type_array_get_element_type(struct bt_ctf_field_type *array);
1392 int64_t bt_ctf_field_type_array_get_length(struct bt_ctf_field_type *array);
1393 struct bt_ctf_field_type *bt_ctf_field_type_sequence_create(struct bt_ctf_field_type *element_type, const char *length_field_name);
1394 struct bt_ctf_field_type *bt_ctf_field_type_sequence_get_element_type(struct bt_ctf_field_type *sequence);
1395 const char *bt_ctf_field_type_sequence_get_length_field_name(struct bt_ctf_field_type *sequence);
1396 struct bt_ctf_field_type *bt_ctf_field_type_string_create(void);
1397 enum ctf_string_encoding bt_ctf_field_type_string_get_encoding(struct bt_ctf_field_type *string_type);
1398 int bt_ctf_field_type_string_set_encoding(struct bt_ctf_field_type *string_type, enum ctf_string_encoding encoding);
1399 int bt_ctf_field_type_get_alignment(struct bt_ctf_field_type *type);
1400 int bt_ctf_field_type_set_alignment(struct bt_ctf_field_type *type, unsigned int alignment);
1401 enum bt_ctf_byte_order bt_ctf_field_type_get_byte_order(struct bt_ctf_field_type *type);
1402 int bt_ctf_field_type_set_byte_order(struct bt_ctf_field_type *type, enum bt_ctf_byte_order byte_order);
1403 enum ctf_type_id bt_ctf_field_type_get_type_id(struct bt_ctf_field_type *type);
1404 void bt_ctf_field_type_get(struct bt_ctf_field_type *type);
1405 void bt_ctf_field_type_put(struct bt_ctf_field_type *type);
1406
1407 /* =================================================================
1408 EVENT-FIELDS.H
1409 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
1410 */
1411 %rename("_bt_ctf_field_create") bt_ctf_field_create(struct bt_ctf_field_type *type);
1412 %rename("_bt_ctf_field_structure_get_field") bt_ctf_field_structure_get_field(struct bt_ctf_field *structure, const char *name);
1413 %rename("_bt_ctf_field_array_get_field") bt_ctf_field_array_get_field(struct bt_ctf_field *array, uint64_t index);
1414 %rename("_bt_ctf_field_sequence_get_length") bt_ctf_field_sequence_get_length(struct bt_ctf_field *sequence);
1415 %rename("_bt_ctf_field_sequence_set_length") bt_ctf_field_sequence_set_length(struct bt_ctf_field *sequence, struct bt_ctf_field *length_field);
1416 %rename("_bt_ctf_field_sequence_get_field") bt_ctf_field_sequence_get_field(struct bt_ctf_field *sequence, uint64_t index);
1417 %rename("_bt_ctf_field_variant_get_field") bt_ctf_field_variant_get_field(struct bt_ctf_field *variant, struct bt_ctf_field *tag);
1418 %rename("_bt_ctf_field_enumeration_get_container") bt_ctf_field_enumeration_get_container(struct bt_ctf_field *enumeration);
1419 %rename("_bt_ctf_field_enumeration_get_mapping_name") bt_ctf_field_enumeration_get_mapping_name(struct bt_ctf_field *enumeration);
1420 %rename("_bt_ctf_field_signed_integer_get_value") bt_ctf_field_signed_integer_get_value(struct bt_ctf_field *integer, int64_t *value);
1421 %rename("_bt_ctf_field_signed_integer_set_value") bt_ctf_field_signed_integer_set_value(struct bt_ctf_field *integer, int64_t value);
1422 %rename("_bt_ctf_field_unsigned_integer_get_value") bt_ctf_field_unsigned_integer_get_value(struct bt_ctf_field *integer, uint64_t *value);
1423 %rename("_bt_ctf_field_unsigned_integer_set_value") bt_ctf_field_unsigned_integer_set_value(struct bt_ctf_field *integer, uint64_t value);
1424 %rename("_bt_ctf_field_floating_point_get_value") bt_ctf_field_floating_point_get_value(struct bt_ctf_field *floating_point, double *value);
1425 %rename("_bt_ctf_field_floating_point_set_value") bt_ctf_field_floating_point_set_value(struct bt_ctf_field *floating_point, double value);
1426 %rename("_bt_ctf_field_string_get_value") bt_ctf_field_string_get_value(struct bt_ctf_field *string_field);
1427 %rename("_bt_ctf_field_string_set_value") bt_ctf_field_string_set_value(struct bt_ctf_field *string_field, const char *value);
1428 %rename("_bt_ctf_field_get_type") bt_ctf_field_get_type(struct bt_ctf_field *field);
1429 %rename("_bt_ctf_field_get") bt_ctf_field_get(struct bt_ctf_field *field);
1430 %rename("_bt_ctf_field_put") bt_ctf_field_put(struct bt_ctf_field *field);
1431
1432 struct bt_ctf_field *bt_ctf_field_create(struct bt_ctf_field_type *type);
1433 struct bt_ctf_field *bt_ctf_field_structure_get_field(struct bt_ctf_field *structure, const char *name);
1434 struct bt_ctf_field *bt_ctf_field_array_get_field(struct bt_ctf_field *array, uint64_t index);
1435 struct bt_ctf_field * bt_ctf_field_sequence_get_length(struct bt_ctf_field *sequence);
1436 int bt_ctf_field_sequence_set_length(struct bt_ctf_field *sequence, struct bt_ctf_field *length_field);
1437 struct bt_ctf_field *bt_ctf_field_sequence_get_field(struct bt_ctf_field *sequence, uint64_t index);
1438 struct bt_ctf_field *bt_ctf_field_variant_get_field(struct bt_ctf_field *variant, struct bt_ctf_field *tag);
1439 struct bt_ctf_field *bt_ctf_field_enumeration_get_container(struct bt_ctf_field *enumeration);
1440 const char *bt_ctf_field_enumeration_get_mapping_name(struct bt_ctf_field *enumeration);
1441 int bt_ctf_field_signed_integer_get_value(struct bt_ctf_field *integer, int64_t *OUTPUT);
1442 int bt_ctf_field_signed_integer_set_value(struct bt_ctf_field *integer, int64_t value);
1443 int bt_ctf_field_unsigned_integer_get_value(struct bt_ctf_field *integer, uint64_t *OUTPUT);
1444 int bt_ctf_field_unsigned_integer_set_value(struct bt_ctf_field *integer, uint64_t value);
1445 int bt_ctf_field_floating_point_get_value(struct bt_ctf_field *floating_point, double *OUTPUT);
1446 int bt_ctf_field_floating_point_set_value(struct bt_ctf_field *floating_point, double value);
1447 const char *bt_ctf_field_string_get_value(struct bt_ctf_field *string_field);
1448 int bt_ctf_field_string_set_value(struct bt_ctf_field *string_field, const char *value);
1449 struct bt_ctf_field_type *bt_ctf_field_get_type(struct bt_ctf_field *field);
1450 void bt_ctf_field_get(struct bt_ctf_field *field);
1451 void bt_ctf_field_put(struct bt_ctf_field *field);
1452
1453 /* =================================================================
1454 EVENT.H
1455 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
1456 */
1457 %rename("_bt_ctf_event_class_create") bt_ctf_event_class_create(const char *name);
1458 %rename("_bt_ctf_event_class_add_field") bt_ctf_event_class_add_field(struct bt_ctf_event_class *event_class, struct bt_ctf_field_type *type, const char *name);
1459 %rename("_bt_ctf_event_class_get") bt_ctf_event_class_get(struct bt_ctf_event_class *event_class);
1460 %rename("_bt_ctf_event_class_put") bt_ctf_event_class_put(struct bt_ctf_event_class *event_class);
1461 %rename("_bt_ctf_event_create") bt_ctf_event_create(struct bt_ctf_event_class *event_class);
1462 %rename("_bt_ctf_event_set_payload") bt_ctf_event_set_payload(struct bt_ctf_event *event, const char *name, struct bt_ctf_field *value);
1463 %rename("_bt_ctf_event_get_payload") bt_ctf_event_get_payload(struct bt_ctf_event *event, const char *name);
1464 %rename("_bt_ctf_event_get") bt_ctf_event_get(struct bt_ctf_event *event);
1465 %rename("_bt_ctf_event_put") bt_ctf_event_put(struct bt_ctf_event *event);
1466
1467 struct bt_ctf_event_class *bt_ctf_event_class_create(const char *name);
1468 int bt_ctf_event_class_add_field(struct bt_ctf_event_class *event_class, struct bt_ctf_field_type *type, const char *name);
1469 void bt_ctf_event_class_get(struct bt_ctf_event_class *event_class);
1470 void bt_ctf_event_class_put(struct bt_ctf_event_class *event_class);
1471 struct bt_ctf_event *bt_ctf_event_create(struct bt_ctf_event_class *event_class);
1472 int bt_ctf_event_set_payload(struct bt_ctf_event *event, const char *name, struct bt_ctf_field *value);
1473 struct bt_ctf_field *bt_ctf_event_get_payload(struct bt_ctf_event *event, const char *name);
1474 void bt_ctf_event_get(struct bt_ctf_event *event);
1475 void bt_ctf_event_put(struct bt_ctf_event *event);
1476
1477 /* =================================================================
1478 STREAM.H
1479 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
1480 */
1481 %rename("_bt_ctf_stream_class_create") bt_ctf_stream_class_create(const char *name);
1482 %rename("_bt_ctf_stream_class_set_clock") bt_ctf_stream_class_set_clock(struct bt_ctf_stream_class *stream_class, struct bt_ctf_clock *clock);
1483 %rename("_bt_ctf_stream_class_add_event_class") bt_ctf_stream_class_add_event_class(struct bt_ctf_stream_class *stream_class, struct bt_ctf_event_class *event_class);
1484 %rename("_bt_ctf_stream_class_get") bt_ctf_stream_class_get(struct bt_ctf_stream_class *stream_class);
1485 %rename("_bt_ctf_stream_class_put") bt_ctf_stream_class_put(struct bt_ctf_stream_class *stream_class);
1486 %rename("_bt_ctf_stream_append_discarded_events") bt_ctf_stream_append_discarded_events(struct bt_ctf_stream *stream, uint64_t event_count);
1487 %rename("_bt_ctf_stream_append_event") bt_ctf_stream_append_event(struct bt_ctf_stream *stream, struct bt_ctf_event *event);
1488 %rename("_bt_ctf_stream_flush") bt_ctf_stream_flush(struct bt_ctf_stream *stream);
1489 %rename("_bt_ctf_stream_get") bt_ctf_stream_get(struct bt_ctf_stream *stream);
1490 %rename("_bt_ctf_stream_put") bt_ctf_stream_put(struct bt_ctf_stream *stream);
1491
1492 struct bt_ctf_stream_class *bt_ctf_stream_class_create(const char *name);
1493 int bt_ctf_stream_class_set_clock(struct bt_ctf_stream_class *stream_class, struct bt_ctf_clock *clock);
1494 int bt_ctf_stream_class_add_event_class(struct bt_ctf_stream_class *stream_class, struct bt_ctf_event_class *event_class);
1495 void bt_ctf_stream_class_get(struct bt_ctf_stream_class *stream_class);
1496 void bt_ctf_stream_class_put(struct bt_ctf_stream_class *stream_class);
1497 void bt_ctf_stream_append_discarded_events(struct bt_ctf_stream *stream, uint64_t event_count);
1498 int bt_ctf_stream_append_event(struct bt_ctf_stream *stream, struct bt_ctf_event *event);
1499 int bt_ctf_stream_flush(struct bt_ctf_stream *stream);
1500 void bt_ctf_stream_get(struct bt_ctf_stream *stream);
1501 void bt_ctf_stream_put(struct bt_ctf_stream *stream);
1502
1503 /* =================================================================
1504 WRITER.H
1505 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
1506 */
1507 %rename("_bt_ctf_writer_create") bt_ctf_writer_create(const char *path);
1508 %rename("_bt_ctf_writer_create_stream") bt_ctf_writer_create_stream(struct bt_ctf_writer *writer, struct bt_ctf_stream_class *stream_class);
1509 %rename("_bt_ctf_writer_add_environment_field") bt_ctf_writer_add_environment_field(struct bt_ctf_writer *writer, const char *name, const char *value);
1510 %rename("_bt_ctf_writer_add_clock") bt_ctf_writer_add_clock(struct bt_ctf_writer *writer, struct bt_ctf_clock *clock);
1511 %newobject bt_ctf_writer_get_metadata_string;
1512 %rename("_bt_ctf_writer_get_metadata_string") bt_ctf_writer_get_metadata_string(struct bt_ctf_writer *writer);
1513 %rename("_bt_ctf_writer_flush_metadata") bt_ctf_writer_flush_metadata(struct bt_ctf_writer *writer);
1514 %rename("_bt_ctf_writer_set_byte_order") bt_ctf_writer_set_byte_order(struct bt_ctf_writer *writer, enum bt_ctf_byte_order byte_order);
1515 %rename("_bt_ctf_writer_get") bt_ctf_writer_get(struct bt_ctf_writer *writer);
1516 %rename("_bt_ctf_writer_put") bt_ctf_writer_put(struct bt_ctf_writer *writer);
1517
1518 struct bt_ctf_writer *bt_ctf_writer_create(const char *path);
1519 struct bt_ctf_stream *bt_ctf_writer_create_stream(struct bt_ctf_writer *writer, struct bt_ctf_stream_class *stream_class);
1520 int bt_ctf_writer_add_environment_field(struct bt_ctf_writer *writer, const char *name, const char *value);
1521 int bt_ctf_writer_add_clock(struct bt_ctf_writer *writer, struct bt_ctf_clock *clock);
1522 char *bt_ctf_writer_get_metadata_string(struct bt_ctf_writer *writer);
1523 void bt_ctf_writer_flush_metadata(struct bt_ctf_writer *writer);
1524 int bt_ctf_writer_set_byte_order(struct bt_ctf_writer *writer, enum bt_ctf_byte_order byte_order);
1525 void bt_ctf_writer_get(struct bt_ctf_writer *writer);
1526 void bt_ctf_writer_put(struct bt_ctf_writer *writer);
1527
1528 %pythoncode %{
1529
1530 class CTFWriter:
1531 # Used to compare to -1ULL in error checks
1532 _MAX_UINT64 = 0xFFFFFFFFFFFFFFFF
1533
1534 """
1535 Enumeration mapping class. start and end values are inclusive.
1536 """
1537 class EnumerationMapping:
1538 def __init__(self, name, start, end):
1539 self.name = name
1540 self.start = start
1541 self.end = end
1542
1543 class Clock:
1544 def __init__(self, name):
1545 self._c = _bt_ctf_clock_create(name)
1546 if self._c is None:
1547 raise ValueError("Invalid clock name.")
1548
1549 def __del__(self):
1550 _bt_ctf_clock_put(self._c)
1551
1552 """
1553 Get the clock's name.
1554 """
1555 @property
1556 def name(self):
1557 name = _bt_ctf_clock_get_name(self._c)
1558 if name is None:
1559 raise ValueError("Invalid clock instance.")
1560 return name
1561
1562 """
1563 Get the clock's description. None if unset.
1564 """
1565 @property
1566 def description(self):
1567 return _bt_ctf_clock_get_description(self._c)
1568
1569 """
1570 Set the clock's description. The description appears in the clock's TSDL
1571 meta-data.
1572 """
1573 @description.setter
1574 def description(self, desc):
1575 ret = _bt_ctf_clock_set_description(self._c, str(desc))
1576 if ret < 0:
1577 raise ValueError("Invalid clock description.")
1578
1579 """
1580 Get the clock's frequency (Hz).
1581 """
1582 @property
1583 def frequency(self):
1584 freq = _bt_ctf_clock_get_frequency(self._c)
1585 if freq == CTFWriter._MAX_UINT64:
1586 raise ValueError("Invalid clock instance")
1587 return freq
1588
1589 """
1590 Set the clock's frequency (Hz).
1591 """
1592 @frequency.setter
1593 def frequency(self, freq):
1594 ret = _bt_ctf_clock_set_frequency(self._c, freq)
1595 if ret < 0:
1596 raise ValueError("Invalid frequency value.")
1597
1598 """
1599 Get the clock's precision (in clock ticks).
1600 """
1601 @property
1602 def precision(self):
1603 precision = _bt_ctf_clock_get_precision(self._c)
1604 if precision == CTFWriter._MAX_UINT64:
1605 raise ValueError("Invalid clock instance")
1606 return precision
1607
1608 """
1609 Set the clock's precision (in clock ticks).
1610 """
1611 @precision.setter
1612 def precision(self, precision):
1613 ret = _bt_ctf_clock_set_precision(self._c, precision)
1614
1615 """
1616 Get the clock's offset in seconds from POSIX.1 Epoch.
1617 """
1618 @property
1619 def offset_seconds(self):
1620 offset_s = _bt_ctf_clock_get_offset_s(self._c)
1621 if offset_s == CTFWriter._MAX_UINT64:
1622 raise ValueError("Invalid clock instance")
1623 return offset_s
1624
1625 """
1626 Set the clock's offset in seconds from POSIX.1 Epoch.
1627 """
1628 @offset_seconds.setter
1629 def offset_seconds(self, offset_s):
1630 ret = _bt_ctf_clock_set_offset_s(self._c, offset_s)
1631 if ret < 0:
1632 raise ValueError("Invalid offset value.")
1633
1634 """
1635 Get the clock's offset in ticks from POSIX.1 Epoch + offset in seconds.
1636 """
1637 @property
1638 def offset(self):
1639 offset = _bt_ctf_clock_get_offset(self._c)
1640 if offset == CTFWriter._MAX_UINT64:
1641 raise ValueError("Invalid clock instance")
1642 return offset
1643
1644 """
1645 Set the clock's offset in ticks from POSIX.1 Epoch + offset in seconds.
1646 """
1647 @offset.setter
1648 def offset(self, offset):
1649 ret = _bt_ctf_clock_set_offset(self._c, offset)
1650 if ret < 0:
1651 raise ValueError("Invalid offset value.")
1652
1653 """
1654 Get a clock's absolute attribute. A clock is absolute if the clock
1655 is a global reference across the trace's other clocks.
1656 """
1657 @property
1658 def absolute(self):
1659 is_absolute = _bt_ctf_clock_get_is_absolute(self._c)
1660 if is_absolute == -1:
1661 raise ValueError("Invalid clock instance")
1662 return False if is_absolute == 0 else True
1663
1664 """
1665 Set a clock's absolute attribute. A clock is absolute if the clock
1666 is a global reference across the trace's other clocks.
1667 """
1668 @absolute.setter
1669 def absolute(self, is_absolute):
1670 ret = _bt_ctf_clock_set_is_absolute(self._c, int(is_absolute))
1671 if ret < 0:
1672 raise ValueError("Could not set the clock's absolute attribute.")
1673
1674 """
1675 Get the current time in nanoseconds since the clock's origin (offset and
1676 offset_s attributes).
1677 """
1678 @property
1679 def time(self):
1680 time = _bt_ctf_clock_get_time(self._c)
1681 if time == CTFWriter._MAX_UINT64:
1682 raise ValueError("Invalid clock instance")
1683 return time
1684
1685 """
1686 Set the current time in nanoseconds since the clock's origin (offset and
1687 offset_s attributes). The clock's value will be sampled as events are
1688 appended to a stream.
1689 """
1690 @time.setter
1691 def time(self, time):
1692 ret = _bt_ctf_clock_set_time(self._c, time)
1693 if ret < 0:
1694 raise ValueError("Invalid time value.")
1695
1696 class FieldDeclaration:
1697 """
1698 FieldDeclaration should not be instantiated directly. Instantiate
1699 one of the concrete FieldDeclaration classes.
1700 """
1701 class IntegerBase:
1702 # These values are based on the bt_ctf_integer_base enum
1703 # declared in event-types.h.
1704 INTEGER_BASE_UNKNOWN = -1
1705 INTEGER_BASE_BINARY = 2
1706 INTEGER_BASE_OCTAL = 8
1707 INTEGER_BASE_DECIMAL = 10
1708 INTEGER_BASE_HEXADECIMAL = 16
1709
1710 def __init__(self):
1711 if self._ft is None:
1712 raise ValueError("FieldDeclaration creation failed.")
1713
1714 def __del__(self):
1715 _bt_ctf_field_type_put(self._ft)
1716
1717 @staticmethod
1718 def _create_field_declaration_from_native_instance(native_field_declaration):
1719 type_dict = {
1720 CTFTypeId.INTEGER : CTFWriter.IntegerFieldDeclaration,
1721 CTFTypeId.FLOAT : CTFWriter.FloatFieldDeclaration,
1722 CTFTypeId.ENUM : CTFWriter.EnumerationFieldDeclaration,
1723 CTFTypeId.STRING : CTFWriter.StringFieldDeclaration,
1724 CTFTypeId.STRUCT : CTFWriter.StructureFieldDeclaration,
1725 CTFTypeId.VARIANT : CTFWriter.VariantFieldDeclaration,
1726 CTFTypeId.ARRAY : CTFWriter.ArrayFieldDeclaration,
1727 CTFTypeId.SEQUENCE : CTFWriter.SequenceFieldDeclaration
1728 }
1729
1730 field_type_id = _bt_ctf_field_type_get_type_id(native_field_declaration)
1731 if field_type_id == CTFTypeId.UNKNOWN:
1732 raise TypeError("Invalid field instance")
1733
1734 declaration = CTFWriter.Field.__new__(CTFWriter.Field)
1735 declaration._ft = native_field_declaration
1736 declaration.__class__ = type_dict[field_type_id]
1737 return declaration
1738
1739 """
1740 Get the field declaration's alignment. Returns -1 on error.
1741 """
1742 @property
1743 def alignment(self):
1744 return _bt_ctf_field_type_get_alignment(self._ft)
1745
1746 """
1747 Set the field declaration's alignment. Defaults to 1 (bit-aligned). However,
1748 some types, such as structures and string, may impose other alignment
1749 constraints.
1750 """
1751 @alignment.setter
1752 def alignment(self, alignment):
1753 ret = _bt_ctf_field_type_set_alignment(self._ft, alignment)
1754 if ret < 0:
1755 raise ValueError("Invalid alignment value.")
1756
1757 """
1758 Get the field declaration's byte order. One of the ByteOrder's constant.
1759 """
1760 @property
1761 def byte_order(self):
1762 return _bt_ctf_field_type_get_byte_order(self._ft)
1763
1764 """
1765 Set the field declaration's byte order. Use constants defined in the ByteOrder
1766 class.
1767 """
1768 @byte_order.setter
1769 def byte_order(self, byte_order):
1770 ret = _bt_ctf_field_type_set_byte_order(self._ft, byte_order)
1771 if ret < 0:
1772 raise ValueError("Could not set byte order value.")
1773
1774 class IntegerFieldDeclaration(FieldDeclaration):
1775 """
1776 Create a new integer field declaration of the given size.
1777 """
1778 def __init__(self, size):
1779 self._ft = _bt_ctf_field_type_integer_create(size)
1780 super().__init__()
1781
1782 """
1783 Get an integer's size.
1784 """
1785 @property
1786 def size(self):
1787 ret = _bt_ctf_field_type_integer_get_size(self._ft)
1788 if ret < 0:
1789 raise ValueError("Could not get Integer's size attribute.")
1790 else:
1791 return ret
1792
1793 """
1794 Get an integer's signedness attribute.
1795 """
1796 @property
1797 def signed(self):
1798 ret = _bt_ctf_field_type_integer_get_signed(self._ft)
1799 if ret < 0:
1800 raise ValueError("Could not get Integer's signed attribute.")
1801 elif ret > 0:
1802 return True
1803 else:
1804 return False
1805
1806 """
1807 Set an integer's signedness attribute.
1808 """
1809 @signed.setter
1810 def signed(self, signed):
1811 ret = _bt_ctf_field_type_integer_set_signed(self._ft, signed)
1812 if ret < 0:
1813 raise ValueError("Could not set Integer's signed attribute.")
1814
1815 """
1816 Get the integer's base used to pretty-print the resulting trace.
1817 Returns a constant from the FieldDeclaration.IntegerBase class.
1818 """
1819 @property
1820 def base(self):
1821 return _bt_ctf_field_type_integer_get_base(self._ft)
1822
1823 """
1824 Set the integer's base used to pretty-print the resulting trace.
1825 The base must be a constant of the FieldDeclarationIntegerBase class.
1826 """
1827 @base.setter
1828 def base(self, base):
1829 ret = _bt_ctf_field_type_integer_set_base(self._ft, base)
1830 if ret < 0:
1831 raise ValueError("Could not set Integer's base.")
1832
1833 """
1834 Get the integer's encoding (one of the constants of the
1835 CTFStringEncoding class).
1836 Returns a constant from the CTFStringEncoding class.
1837 """
1838 @property
1839 def encoding(self):
1840 return _bt_ctf_field_type_integer_get_encoding(self._ft)
1841
1842 """
1843 An integer encoding may be set to signal that the integer must be printed
1844 as a text character. Must be a constant from the CTFStringEncoding class.
1845 """
1846 @encoding.setter
1847 def encoding(self, encoding):
1848 ret = _bt_ctf_field_type_integer_set_encoding(self._ft, encoding)
1849 if ret < 0:
1850 raise ValueError("Could not set Integer's encoding.")
1851
1852 class EnumerationFieldDeclaration(FieldDeclaration):
1853 """
1854 Create a new enumeration field declaration with the given underlying container type.
1855 """
1856 def __init__(self, integer_type):
1857 if integer_type is None or not isinstance(integer_type, CTFWriter.IntegerFieldDeclaration):
1858 raise TypeError("Invalid integer container.")
1859
1860 self._ft = _bt_ctf_field_type_enumeration_create(integer_type._ft)
1861 super().__init__()
1862
1863 """
1864 Get the enumeration's underlying container type.
1865 """
1866 @property
1867 def container(self):
1868 ret = _bt_ctf_field_type_enumeration_get_container_type(self._ft)
1869 if ret is None:
1870 raise TypeError("Invalid enumeration declaration")
1871 return CTFWriter.FieldDeclaration._create_field_declaration_from_native_instance(ret)
1872
1873 """
1874 Add a mapping to the enumeration. The range's values are inclusive.
1875 """
1876 def add_mapping(self, name, range_start, range_end):
1877 if range_start < 0 or range_end < 0:
1878 ret = _bt_ctf_field_type_enumeration_add_mapping(self._ft, str(name), range_start, range_end)
1879 else:
1880 ret = _bt_ctf_field_type_enumeration_add_mapping_unsigned(self._ft, str(name), range_start, range_end)
1881
1882 if ret < 0:
1883 raise ValueError("Could not add mapping to enumeration declaration.")
1884
1885 """
1886 Generator returning instances of EnumerationMapping.
1887 """
1888 @property
1889 def mappings(self):
1890 signed = self.container.signed
1891
1892 count = _bt_ctf_field_type_enumeration_get_mapping_count(self._ft)
1893 for i in range(count):
1894 if signed:
1895 ret = _bt_python_ctf_field_type_enumeration_get_mapping(self._ft, i)
1896 else:
1897 ret = _bt_python_ctf_field_type_enumeration_get_mapping_unsigned(self._ft, i)
1898
1899 if len(ret) != 3:
1900 raise TypeError("Could not get Enumeration mapping at index {}".format(i))
1901 name, range_start, range_end = ret
1902 yield CTFWriter.EnumerationMapping(name, range_start, range_end)
1903
1904 """
1905 Get a mapping by name (EnumerationMapping).
1906 """
1907 def get_mapping_by_name(self, name):
1908 ret, index = _bt_ctf_field_type_enumeration_get_mapping_index_by_name(self._ft, name);
1909 if ret < 0:
1910 return None
1911
1912 if self.container.signed:
1913 ret = _bt_python_ctf_field_type_enumeration_get_mapping(self._ft, index)
1914 else:
1915 ret = _bt_python_ctf_field_type_enumeration_get_mapping_unsigned(self._ft, index)
1916
1917 if len(ret) != 3:
1918 raise TypeError("Could not get Enumeration mapping at index {}".format(i))
1919 name, range_start, range_end = ret
1920 return CTFWriter.EnumerationMapping(name, range_start, range_end)
1921
1922 """
1923 Get a mapping by value (EnumerationMapping).
1924 """
1925 def get_mapping_by_value(self, value):
1926 if value < 0:
1927 ret, index = _bt_ctf_field_type_enumeration_get_mapping_index_by_value(self._ft, value);
1928 else:
1929 ret, index = _bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value(self._ft, value);
1930
1931 if ret < 0:
1932 return None
1933
1934 if self.container.signed:
1935 ret = _bt_python_ctf_field_type_enumeration_get_mapping(self._ft, index)
1936 else:
1937 ret = _bt_python_ctf_field_type_enumeration_get_mapping_unsigned(self._ft, index)
1938
1939 if len(ret) != 3:
1940 raise TypeError("Could not get Enumeration mapping at index {}".format(i))
1941 name, range_start, range_end = ret
1942 return CTFWriter.EnumerationMapping(name, range_start, range_end)
1943
1944 class FloatFieldDeclaration(FieldDeclaration):
1945 FLT_EXP_DIG = 8
1946 DBL_EXP_DIG = 11
1947 FLT_MANT_DIG = 24
1948 DBL_MANT_DIG = 53
1949
1950 """
1951 Create a new floating point field declaration.
1952 """
1953 def __init__(self):
1954 self._ft = _bt_ctf_field_type_floating_point_create()
1955 super().__init__()
1956
1957 """
1958 Get the number of exponent digits used to store the floating point field.
1959 """
1960 @property
1961 def exponent_digits(self):
1962 ret = _bt_ctf_field_type_floating_point_get_exponent_digits(self._ft)
1963 if ret < 0:
1964 raise TypeError("Could not get Floating point exponent digit count")
1965 return ret
1966
1967 """
1968 Set the number of exponent digits to use to store the floating point field.
1969 The only values currently supported are FLT_EXP_DIG and DBL_EXP_DIG which
1970 are defined as constants of this class.
1971 """
1972 @exponent_digits.setter
1973 def exponent_digits(self, exponent_digits):
1974 ret = _bt_ctf_field_type_floating_point_set_exponent_digits(self._ft, exponent_digits)
1975 if ret < 0:
1976 raise ValueError("Could not set exponent digit count.")
1977
1978 """
1979 Get the number of mantissa digits used to store the floating point field.
1980 """
1981 @property
1982 def mantissa_digits(self):
1983 ret = _bt_ctf_field_type_floating_point_get_mantissa_digits(self._ft)
1984 if ret < 0:
1985 raise TypeError("Could not get Floating point mantissa digit count")
1986 return ret
1987
1988 """
1989 Set the number of mantissa digits to use to store the floating point field.
1990 The only values currently supported are FLT_MANT_DIG and DBL_MANT_DIG which
1991 are defined as constants of this class.
1992 """
1993 @mantissa_digits.setter
1994 def mantissa_digits(self, mantissa_digits):
1995 ret = _bt_ctf_field_type_floating_point_set_mantissa_digits(self._ft, mantissa_digits)
1996 if ret < 0:
1997 raise ValueError("Could not set mantissa digit count.")
1998
1999 class StructureFieldDeclaration(FieldDeclaration):
2000 """
2001 Create a new structure field declaration.
2002 """
2003 def __init__(self):
2004 self._ft = _bt_ctf_field_type_structure_create()
2005 super().__init__()
2006
2007 """
2008 Add a field of type "field_type" to the structure.
2009 """
2010 def add_field(self, field_type, field_name):
2011 ret = _bt_ctf_field_type_structure_add_field(self._ft, field_type._ft, str(field_name))
2012 if ret < 0:
2013 raise ValueError("Could not add field to structure.")
2014
2015 """
2016 Generator returning the structure's field as tuples of (field name, field declaration).
2017 """
2018 @property
2019 def fields(self):
2020 count = _bt_ctf_field_type_structure_get_field_count(self._ft)
2021 if count < 0:
2022 raise TypeError("Could not get Structure field count")
2023
2024 for i in range(count):
2025 field_name = _bt_python_ctf_field_type_structure_get_field_name(self._ft, i)
2026 if field_name is None:
2027 raise TypeError("Could not get Structure field name at index {}".format(i))
2028
2029 field_type_native = _bt_python_ctf_field_type_structure_get_field_type(self._ft, i)
2030 if field_type_native is None:
2031 raise TypeError("Could not get Structure field type at index {}".format(i))
2032
2033 field_type = CTFWriter.FieldDeclaration._create_field_declaration_from_native_instance(field_type_native)
2034 yield (field_name, field_type)
2035
2036 """
2037 Get a field declaration by name (FieldDeclaration).
2038 """
2039 def get_field_by_name(self, name):
2040 field_type_native = _bt_ctf_field_type_structure_get_field_type_by_name(self._ft, name)
2041 if field_type_native is None:
2042 raise TypeError("Could not find Structure field with name {}".format(name))
2043
2044 return CTFWriter.FieldDeclaration._create_field_declaration_from_native_instance(field_type_native)
2045
2046 class VariantFieldDeclaration(FieldDeclaration):
2047 """
2048 Create a new variant field declaration.
2049 """
2050 def __init__(self, enum_tag, tag_name):
2051 if enum_tag is None or not isinstance(enum_tag, CTFWriter.EnumerationFieldDeclaration):
2052 raise TypeError("Invalid tag type; must be of type EnumerationFieldDeclaration.")
2053
2054 self._ft = _bt_ctf_field_type_variant_create(enum_tag._ft, str(tag_name))
2055 super().__init__()
2056
2057 """
2058 Get the variant's tag name.
2059 """
2060 @property
2061 def tag_name(self):
2062 ret = _bt_ctf_field_type_variant_get_tag_name(self._ft)
2063 if ret is None:
2064 raise TypeError("Could not get Variant tag name")
2065 return ret
2066
2067 """
2068 Get the variant's tag type.
2069 """
2070 @property
2071 def tag_type(self):
2072 ret = _bt_ctf_field_type_variant_get_tag_type(self._ft)
2073 if ret is None:
2074 raise TypeError("Could not get Variant tag type")
2075 return CTFWriter.FieldDeclaration._create_field_declaration_from_native_instance(ret)
2076
2077 """
2078 Add a field of type "field_type" to the variant.
2079 """
2080 def add_field(self, field_type, field_name):
2081 ret = _bt_ctf_field_type_variant_add_field(self._ft, field_type._ft, str(field_name))
2082 if ret < 0:
2083 raise ValueError("Could not add field to variant.")
2084
2085 """
2086 Generator returning the variant's field as tuples of (field name, field declaration).
2087 """
2088 @property
2089 def fields(self):
2090 count = _bt_ctf_field_type_variant_get_field_count(self._ft)
2091 if count < 0:
2092 raise TypeError("Could not get Variant field count")
2093
2094 for i in range(count):
2095 field_name = _bt_python_ctf_field_type_variant_get_field_name(self._ft, i)
2096 if field_name is None:
2097 raise TypeError("Could not get Variant field name at index {}".format(i))
2098
2099 field_type_native = _bt_python_ctf_field_type_variant_get_field_type(self._ft, i)
2100 if field_type_native is None:
2101 raise TypeError("Could not get Variant field type at index {}".format(i))
2102
2103 field_type = CTFWriter.FieldDeclaration._create_field_declaration_from_native_instance(field_type_native)
2104 yield (field_name, field_type)
2105
2106 """
2107 Get a field declaration by name (FieldDeclaration).
2108 """
2109 def get_field_by_name(self, name):
2110 field_type_native = _bt_ctf_field_type_variant_get_field_type_by_name(self._ft, name)
2111 if field_type_native is None:
2112 raise TypeError("Could not find Variant field with name {}".format(name))
2113
2114 return CTFWriter.FieldDeclaration._create_field_declaration_from_native_instance(field_type_native)
2115
2116 """
2117 Get a field declaration from tag (EnumerationField).
2118 """
2119 def get_field_from_tag(self, tag):
2120 field_type_native = _bt_ctf_field_type_variant_get_field_type_from_tag(self._ft, tag._f)
2121 if field_type_native is None:
2122 raise TypeError("Could not find Variant field with tag value {}".format(tag.value))
2123
2124 return CTFWriter.FieldDeclaration._create_field_declaration_from_native_instance(field_type_native)
2125
2126 class ArrayFieldDeclaration(FieldDeclaration):
2127 """
2128 Create a new array field declaration.
2129 """
2130 def __init__(self, element_type, length):
2131 self._ft = _bt_ctf_field_type_array_create(element_type._ft, length)
2132 super().__init__()
2133
2134 """
2135 Get the array's element type.
2136 """
2137 @property
2138 def element_type(self):
2139 ret = _bt_ctf_field_type_array_get_element_type(self._ft)
2140 if ret is None:
2141 raise TypeError("Could not get Array element type")
2142 return CTFWriter.FieldDeclaration._create_field_declaration_from_native_instance(ret)
2143
2144 """
2145 Get the array's length.
2146 """
2147 @property
2148 def length(self):
2149 ret = _bt_ctf_field_type_array_get_length(self._ft)
2150 if ret < 0:
2151 raise TypeError("Could not get Array length")
2152 return ret
2153
2154 class SequenceFieldDeclaration(FieldDeclaration):
2155 """
2156 Create a new sequence field declaration.
2157 """
2158 def __init__(self, element_type, length_field_name):
2159 self._ft = _bt_ctf_field_type_sequence_create(element_type._ft, str(length_field_name))
2160 super().__init__()
2161
2162 """
2163 Get the sequence's element type.
2164 """
2165 @property
2166 def element_type(self):
2167 ret = _bt_ctf_field_type_sequence_get_element_type(self._ft)
2168 if ret is None:
2169 raise TypeError("Could not get Sequence element type")
2170 return CTFWriter.FieldDeclaration._create_field_declaration_from_native_instance(ret)
2171
2172 """
2173 Get the sequence's length field name.
2174 """
2175 @property
2176 def length_field_name(self):
2177 ret = _bt_ctf_field_type_sequence_get_length_field_name(self._ft)
2178 if ret is None:
2179 raise TypeError("Could not get Sequence length field name")
2180 return ret
2181
2182 class StringFieldDeclaration(FieldDeclaration):
2183 """
2184 Create a new string field declaration.
2185 """
2186 def __init__(self):
2187 self._ft = _bt_ctf_field_type_string_create()
2188 super().__init__()
2189
2190 """
2191 Get a string declaration's encoding (a constant from the CTFStringEncoding class).
2192 """
2193 @property
2194 def encoding(self):
2195 return _bt_ctf_field_type_string_get_encoding(self._ft)
2196
2197 """
2198 Set a string declaration's encoding. Must be a constant from the CTFStringEncoding class.
2199 """
2200 @encoding.setter
2201 def encoding(self, encoding):
2202 ret = _bt_ctf_field_type_string_set_encoding(self._ft, encoding)
2203 if ret < 0:
2204 raise ValueError("Could not set string encoding.")
2205
2206 """
2207 Create an instance of a field.
2208 """
2209 @staticmethod
2210 def create_field(field_type):
2211 if field_type is None or not isinstance(field_type, CTFWriter.FieldDeclaration):
2212 raise TypeError("Invalid field_type. Type must be a FieldDeclaration-derived class.")
2213
2214 if isinstance(field_type, CTFWriter.IntegerFieldDeclaration):
2215 return CTFWriter.IntegerField(field_type)
2216 elif isinstance(field_type, CTFWriter.EnumerationFieldDeclaration):
2217 return CTFWriter.EnumerationField(field_type)
2218 elif isinstance(field_type, CTFWriter.FloatFieldDeclaration):
2219 return CTFWriter.FloatFieldingPoint(field_type)
2220 elif isinstance(field_type, CTFWriter.StructureFieldDeclaration):
2221 return CTFWriter.StructureField(field_type)
2222 elif isinstance(field_type, CTFWriter.VariantFieldDeclaration):
2223 return CTFWriter.VariantField(field_type)
2224 elif isinstance(field_type, CTFWriter.ArrayFieldDeclaration):
2225 return CTFWriter.ArrayField(field_type)
2226 elif isinstance(field_type, CTFWriter.SequenceFieldDeclaration):
2227 return CTFWriter.SequenceField(field_type)
2228 elif isinstance(field_type, CTFWriter.StringFieldDeclaration):
2229 return CTFWriter.StringField(field_type)
2230
2231 class Field:
2232 """
2233 Base class, do not instantiate.
2234 """
2235 def __init__(self, field_type):
2236 if not isinstance(field_type, CTFWriter.FieldDeclaration):
2237 raise TypeError("Invalid field_type argument.")
2238
2239 self._f = _bt_ctf_field_create(field_type._ft)
2240 if self._f is None:
2241 raise ValueError("Field creation failed.")
2242
2243 def __del__(self):
2244 _bt_ctf_field_put(self._f)
2245
2246 @staticmethod
2247 def _create_field_from_native_instance(native_field_instance):
2248 type_dict = {
2249 CTFTypeId.INTEGER : CTFWriter.IntegerField,
2250 CTFTypeId.FLOAT : CTFWriter.FloatFieldingPoint,
2251 CTFTypeId.ENUM : CTFWriter.EnumerationField,
2252 CTFTypeId.STRING : CTFWriter.StringField,
2253 CTFTypeId.STRUCT : CTFWriter.StructureField,
2254 CTFTypeId.VARIANT : CTFWriter.VariantField,
2255 CTFTypeId.ARRAY : CTFWriter.ArrayField,
2256 CTFTypeId.SEQUENCE : CTFWriter.SequenceField
2257 }
2258
2259 field_type = _bt_python_get_field_type(native_field_instance)
2260 if field_type == CTFTypeId.UNKNOWN:
2261 raise TypeError("Invalid field instance")
2262
2263 field = CTFWriter.Field.__new__(CTFWriter.Field)
2264 field._f = native_field_instance
2265 field.__class__ = type_dict[field_type]
2266 return field
2267
2268 @property
2269 def declaration(self):
2270 native_field_type = _bt_ctf_field_get_type(self._f)
2271 if native_field_type is None:
2272 raise TypeError("Invalid field instance")
2273 return CTFWriter.FieldDeclaration._create_field_declaration_from_native_instance(native_field_type)
2274
2275 class IntegerField(Field):
2276 """
2277 Get an integer field's value.
2278 """
2279 @property
2280 def value(self):
2281 signedness = _bt_python_field_integer_get_signedness(self._f)
2282 if signedness < 0:
2283 raise TypeError("Invalid integer instance.")
2284
2285 if signedness == 0:
2286 ret, value = _bt_ctf_field_unsigned_integer_get_value(self._f)
2287 else:
2288 ret, value = _bt_ctf_field_signed_integer_get_value(self._f)
2289
2290 if ret < 0:
2291 raise ValueError("Could not get integer field value.")
2292 return value
2293
2294 """
2295 Set an integer field's value.
2296 """
2297 @value.setter
2298 def value(self, value):
2299 if not isinstance(value, int):
2300 raise TypeError("IntegerField's value must be an int")
2301
2302 signedness = _bt_python_field_integer_get_signedness(self._f)
2303 if signedness < 0:
2304 raise TypeError("Invalid integer instance.")
2305
2306 if signedness == 0:
2307 ret = _bt_ctf_field_unsigned_integer_set_value(self._f, value)
2308 else:
2309 ret = _bt_ctf_field_signed_integer_set_value(self._f, value)
2310
2311 if ret < 0:
2312 raise ValueError("Could not set integer field value.")
2313
2314 class EnumerationField(Field):
2315 """
2316 Return the enumeration's underlying container field (an integer field).
2317 """
2318 @property
2319 def container(self):
2320 container = CTFWriter.IntegerField.__new__(CTFWriter.IntegerField)
2321 container._f = _bt_ctf_field_enumeration_get_container(self._f)
2322 if container._f is None:
2323 raise TypeError("Invalid enumeration field type.")
2324 return container
2325
2326 """
2327 Get the enumeration field's mapping name.
2328 """
2329 @property
2330 def value(self):
2331 value = _bt_ctf_field_enumeration_get_mapping_name(self._f)
2332 if value is None:
2333 raise ValueError("Could not get enumeration's mapping name.")
2334 return value
2335
2336 """
2337 Set the enumeration field's value. Must be an integer as mapping names
2338 may be ambiguous.
2339 """
2340 @value.setter
2341 def value(self, value):
2342 if not isinstance(value, int):
2343 raise TypeError("EnumerationField value must be an int")
2344 self.container.value = value
2345
2346 class FloatFieldingPoint(Field):
2347 """
2348 Get a floating point field's value.
2349 """
2350 @property
2351 def value(self):
2352 ret, value = _bt_ctf_field_floating_point_get_value(self._f)
2353 if ret < 0:
2354 raise ValueError("Could not get floating point field value.")
2355 return value
2356
2357 """
2358 Set a floating point field's value.
2359 """
2360 @value.setter
2361 def value(self, value):
2362 if not isinstance(value, int) and not isinstance(value, float):
2363 raise TypeError("Value must be either a float or an int")
2364
2365 ret = _bt_ctf_field_floating_point_set_value(self._f, float(value))
2366 if ret < 0:
2367 raise ValueError("Could not set floating point field value.")
2368
2369 class StructureField(Field):
2370 """
2371 Get the structure's field corresponding to the provided field name.
2372 """
2373 def field(self, field_name):
2374 native_instance = _bt_ctf_field_structure_get_field(self._f, str(field_name))
2375 if native_instance is None:
2376 raise ValueError("Invalid field_name provided.")
2377 return CTFWriter.Field._create_field_from_native_instance(native_instance)
2378
2379 class VariantField(Field):
2380 """
2381 Return the variant's selected field. The "tag" field is the selector enum field.
2382 """
2383 def field(self, tag):
2384 native_instance = _bt_ctf_field_variant_get_field(self._f, tag._f)
2385 if native_instance is None:
2386 raise ValueError("Invalid tag provided.")
2387 return CTFWriter.Field._create_field_from_native_instance(native_instance)
2388
2389 class ArrayField(Field):
2390 """
2391 Return the array's field at position "index".
2392 """
2393 def field(self, index):
2394 native_instance = _bt_ctf_field_array_get_field(self._f, index)
2395 if native_instance is None:
2396 raise IndexError("Invalid index provided.")
2397 return CTFWriter.Field._create_field_from_native_instance(native_instance)
2398
2399 class SequenceField(Field):
2400 """
2401 Get the sequence's length field (IntegerField).
2402 """
2403 @property
2404 def length(self):
2405 native_instance = _bt_ctf_field_sequence_get_length(self._f)
2406 if native_instance is None:
2407 length = -1
2408 return CTFWriter.Field._create_field_from_native_instance(native_instance)
2409
2410 """
2411 Set the sequence's length field (IntegerField).
2412 """
2413 @length.setter
2414 def length(self, length_field):
2415 if not isinstance(length_field, CTFWriter.IntegerField):
2416 raise TypeError("Invalid length field.")
2417 if length_field.declaration.signed:
2418 raise TypeError("Sequence field length must be unsigned")
2419 ret = _bt_ctf_field_sequence_set_length(self._f, length_field._f)
2420 if ret < 0:
2421 raise ValueError("Could not set sequence length.")
2422
2423 """
2424 Return the sequence's field at position "index".
2425 """
2426 def field(self, index):
2427 native_instance = _bt_ctf_field_sequence_get_field(self._f, index)
2428 if native_instance is None:
2429 raise ValueError("Could not get sequence element at index.")
2430 return CTFWriter.Field._create_field_from_native_instance(native_instance)
2431
2432 class StringField(Field):
2433 """
2434 Get a string field's value.
2435 """
2436 @property
2437 def value(self):
2438 return _bt_ctf_field_string_get_value(self._f)
2439
2440 """
2441 Set a string field's value.
2442 """
2443 @value.setter
2444 def value(self, value):
2445 ret = _bt_ctf_field_string_set_value(self._f, str(value))
2446 if ret < 0:
2447 raise ValueError("Could not set string field value.")
2448
2449 class EventClass:
2450 """
2451 Create a new event class of the given name.
2452 """
2453 def __init__(self, name):
2454 self._ec = _bt_ctf_event_class_create(name)
2455 if self._ec is None:
2456 raise ValueError("Event class creation failed.")
2457
2458 def __del__(self):
2459 _bt_ctf_event_class_put(self._ec)
2460
2461 """
2462 Add a field of type "field_type" to the event class.
2463 """
2464 def add_field(self, field_type, field_name):
2465 ret = _bt_ctf_event_class_add_field(self._ec, field_type._ft, str(field_name))
2466 if ret < 0:
2467 raise ValueError("Could not add field to event class.")
2468
2469 class Event:
2470 """
2471 Create a new event of the given event class.
2472 """
2473 def __init__(self, event_class):
2474 if not isinstance(event_class, CTFWriter.EventClass):
2475 raise TypeError("Invalid event_class argument.")
2476
2477 self._e = _bt_ctf_event_create(event_class._ec)
2478 if self._e is None:
2479 raise ValueError("Event creation failed.")
2480
2481 def __del__(self):
2482 _bt_ctf_event_put(self._e)
2483
2484 """
2485 Set a manually created field as an event's payload.
2486 """
2487 def set_payload(self, field_name, value_field):
2488 if not isinstance(value, CTFWriter.Field):
2489 raise TypeError("Invalid value type.")
2490 ret = _bt_ctf_event_set_payload(self._e, str(field_name), value_field._f)
2491 if ret < 0:
2492 raise ValueError("Could not set event field payload.")
2493
2494 """
2495 Get a field from event.
2496 """
2497 def payload(self, field_name):
2498 native_instance = _bt_ctf_event_get_payload(self._e, str(field_name))
2499 if native_instance is None:
2500 raise ValueError("Could not get event payload.")
2501 return CTFWriter.Field._create_field_from_native_instance(native_instance)
2502
2503 class StreamClass:
2504 """
2505 Create a new stream class of the given name.
2506 """
2507 def __init__(self, name):
2508 self._sc = _bt_ctf_stream_class_create(name)
2509 if self._sc is None:
2510 raise ValueError("Stream class creation failed.")
2511
2512 def __del__(self):
2513 _bt_ctf_stream_class_put(self._sc)
2514
2515 """
2516 Get a stream class' clock.
2517 """
2518 @property
2519 def clock(self):
2520 raise NotImplementedError("Getter not implemented.")
2521
2522 """
2523 Assign a clock to a stream class.
2524 """
2525 @clock.setter
2526 def clock(self, clock):
2527 if not isinstance(clock, CTFWriter.Clock):
2528 raise TypeError("Invalid clock type.")
2529
2530 ret = _bt_ctf_stream_class_set_clock(self._sc, clock._c)
2531 if ret < 0:
2532 raise ValueError("Could not set stream class clock.")
2533
2534 """
2535 Add an event class to a stream class. New events can be added even after a
2536 stream has been instantiated and events have been appended. However, a stream
2537 will not accept events of a class that has not been registered beforehand.
2538 """
2539 def add_event_class(self, event_class):
2540 if not isinstance(event_class, CTFWriter.EventClass):
2541 raise TypeError("Invalid event_class type.")
2542
2543 ret = _bt_ctf_stream_class_add_event_class(self._sc, event_class._ec)
2544 if ret < 0:
2545 raise ValueError("Could not add event class.")
2546
2547 class Stream:
2548 """
2549 Create a stream of the given class.
2550 """
2551 def __init__(self, stream_class):
2552 if not isinstance(stream_class, CTFWriter.StreamClass):
2553 raise TypeError("Invalid stream_class type.")
2554
2555 self._s = _bt_ctf_stream_create(stream_class._sc)
2556 if self._s is None:
2557 raise ValueError("Stream creation failed.")
2558
2559 def __del__(self):
2560 _bt_ctf_stream_put(self._s)
2561
2562 """
2563 Increase the current packet's discarded event count.
2564 """
2565 def append_discarded_events(self, event_count):
2566 _bt_ctf_stream_append_discarded_events(self._s, event_count)
2567
2568 """
2569 Append "event" to the stream's current packet. The stream's associated clock
2570 will be sampled during this call. The event shall not be modified after
2571 being appended to a stream.
2572 """
2573 def append_event(self, event):
2574 ret = _bt_ctf_stream_append_event(self._s, event._e)
2575 if ret < 0:
2576 raise ValueError("Could not append event to stream.")
2577
2578 """
2579 The stream's current packet's events will be flushed to disk. Events
2580 subsequently appended to the stream will be added to a new packet.
2581 """
2582 def flush(self):
2583 ret = _bt_ctf_stream_flush(self._s)
2584 if ret < 0:
2585 raise ValueError("Could not flush stream.")
2586
2587 class Writer:
2588 """
2589 Create a new writer that will produce a trace in the given path.
2590 """
2591 def __init__(self, path):
2592 self._w = _bt_ctf_writer_create(path)
2593 if self._w is None:
2594 raise ValueError("Writer creation failed.")
2595
2596 def __del__(self):
2597 _bt_ctf_writer_put(self._w)
2598
2599 """
2600 Create a new stream instance and register it to the writer.
2601 """
2602 def create_stream(self, stream_class):
2603 if not isinstance(stream_class, CTFWriter.StreamClass):
2604 raise TypeError("Invalid stream_class type.")
2605
2606 stream = CTFWriter.Stream.__new__(CTFWriter.Stream)
2607 stream._s = _bt_ctf_writer_create_stream(self._w, stream_class._sc)
2608 return stream
2609
2610 """
2611 Add an environment field to the trace.
2612 """
2613 def add_environment_field(self, name, value):
2614 ret = _bt_ctf_writer_add_environment_field(self._w, str(name), str(value))
2615 if ret < 0:
2616 raise ValueError("Could not add environment field to trace.")
2617
2618 """
2619 Add a clock to the trace. Clocks assigned to stream classes must be
2620 registered to the writer.
2621 """
2622 def add_clock(self, clock):
2623 ret = _bt_ctf_writer_add_clock(self._w, clock._c)
2624 if ret < 0:
2625 raise ValueError("Could not add clock to Writer.")
2626
2627 """
2628 Get the trace's TSDL meta-data.
2629 """
2630 @property
2631 def metadata(self):
2632 return _bt_ctf_writer_get_metadata_string(self._w)
2633
2634 """
2635 Flush the trace's metadata to the metadata file.
2636 """
2637 def flush_metadata(self):
2638 _bt_ctf_writer_flush_metadata(self._w)
2639
2640 """
2641 Get the trace's byte order. Must be a constant from the ByteOrder
2642 class.
2643 """
2644 @property
2645 def byte_order(self):
2646 raise NotImplementedError("Getter not implemented.")
2647
2648 """
2649 Set the trace's byte order. Must be a constant from the ByteOrder
2650 class. Defaults to BYTE_ORDER_NATIVE, the host machine's endianness.
2651 """
2652 @byte_order.setter
2653 def byte_order(self, byte_order):
2654 ret = _bt_ctf_writer_set_byte_order(self._w, byte_order)
2655 if ret < 0:
2656 raise ValueError("Could not set trace's byte order.")
2657
2658 %}
This page took 0.112519 seconds and 5 git commands to generate.