1 #ifndef BABELTRACE_CTF_IR_TRACE_H
2 #define BABELTRACE_CTF_IR_TRACE_H
5 * BabelTrace - CTF IR: Trace
7 * Copyright 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
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:
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 * The Common Trace Format (CTF) Specification is available at
30 * http://www.efficios.com/ctf
34 #include <babeltrace/ctf-ir/visitor.h>
37 #include <babeltrace/types.h>
48 @defgroup ctfirtraceclass CTF IR trace class
50 @brief CTF IR trace class.
53 #include <babeltrace/ctf-ir/trace.h>
56 A CTF IR <strong><em>trace class</em></strong> is a descriptor of
59 You can obtain a trace class in two different modes:
61 - <strong>Normal mode</strong>: use bt_trace_create() to create a
62 default, empty trace class.
63 - <strong>CTF writer mode</strong>: use bt_writer_get_trace() to
64 get the trace class created by a given CTF writer object.
66 A trace class has the following properties:
69 - A <strong>native byte order</strong>: all the
70 \link ctfirfieldtypes field types\endlink eventually part of the trace
71 class with a byte order set to #BT_BYTE_ORDER_NATIVE have this
74 - An \b environment, which is a custom key-value mapping. Keys are
75 strings and values can be strings or integers.
77 In the Babeltrace CTF IR system, a trace class contains zero or more
78 \link ctfirstreamclass stream classes\endlink, and a stream class
79 contains zero or more \link ctfireventclass event classes\endlink. You
80 can add an event class to a stream class with
81 bt_stream_class_add_event_class(). You can add a stream class to a
82 trace class with bt_trace_add_stream_class().
84 You can access the streams of a trace, that is, the streams which were
85 created from the trace's stream classes with bt_stream_create(),
86 with bt_trace_get_stream_by_index().
88 A trace class owns the <strong>trace packet header</strong>
89 \link ctfirfieldtypes field type\endlink, which represents the
90 \c trace.packet.header CTF scope. This field type describes the
91 trace packet header fields of the traces that this trace class
94 The trace packet header field type \em must be a structure field type as
95 of Babeltrace \btversion.
97 As per the CTF specification, the trace packet header field type \em
98 must contain a field named \c stream_id if the trace class contains more
99 than one stream class.
101 As a reminder, here's the structure of a CTF packet:
105 A trace class also contains zero or more
106 \link ctfirclockclass CTF IR clock classes\endlink.
109 Elaborate about clock classes irt clock values.
111 As with any Babeltrace object, CTF IR trace class objects have
112 <a href="https://en.wikipedia.org/wiki/Reference_counting">reference
113 counts</a>. See \ref refs to learn more about the reference counting
114 management of Babeltrace objects.
116 The following functions \em freeze their trace class parameter on
119 - bt_trace_add_stream_class()
120 - bt_writer_create_stream()
121 (\link ctfwriter CTF writer\endlink mode only)
123 You cannot modify a frozen trace class: it is considered immutable,
126 - Adding a stream class to it with
127 bt_trace_add_stream_class().
128 - Adding a CTF IR clock class to it with bt_trace_add_clock_class().
129 - \link refs Reference counting\endlink.
136 @brief CTF IR trace class type and functions.
139 @addtogroup ctfirtraceclass
145 @brief A CTF IR trace class.
150 struct bt_stream_class
;
151 struct bt_clock_class
;
154 @brief User function type to use with
155 bt_trace_add_is_static_listener().
157 @param[in] trace_class Trace class which is now static.
158 @param[in] data User data as passed to
159 bt_trace_add_is_static_listener() when
160 you added the listener.
162 @prenotnull{trace_class}
164 typedef void (* bt_trace_is_static_listener
)(
165 struct bt_trace
*trace_class
, void *data
);
168 @brief User function type to use with
169 bt_trace_add_is_static_listener().
171 @param[in] trace_class Trace class to which the listener was added.
172 @param[in] data User data as passed to
173 bt_trace_add_is_static_listener() when
174 you added the listener.
176 @prenotnull{trace_class}
178 typedef void (* bt_trace_listener_removed
)(
179 struct bt_trace
*trace_class
, void *data
);
182 @name Creation function
187 @brief Creates a default CTF IR trace class.
189 On success, the trace packet header field type of the created trace
190 class is an empty structure field type. You can modify this default
191 trace packet header field type after the trace class is created with
192 bt_trace_get_packet_header_type() and
193 bt_trace_set_packet_header_type().
195 The created trace class has the following initial properties:
197 - <strong>Name</strong>: none. You can set a name
198 with bt_trace_set_name().
199 - <strong>UUID</strong>: none. You can set a UUID with
201 - <strong>Native byte order</strong>: #BT_BYTE_ORDER_UNSPECIFIED.
202 You can set a native byte order with
203 bt_trace_set_native_byte_order().
204 - <strong>Environment</strong>: empty. You can add environment entries
205 with bt_trace_set_environment_field(),
206 bt_trace_set_environment_field_integer(), and
207 bt_trace_set_environment_field_string().
209 @returns Created trace class, or \c NULL on error.
211 @postsuccessrefcountret1
213 extern struct bt_trace
*bt_trace_create(void);
218 @name Properties functions
223 @brief Returns the name of the CTF IR trace class \p trace_class.
225 On success, \p trace_class remains the sole owner of the returned
226 string. The returned string is valid as long as \p trace_class exists
229 @param[in] trace_class Trace class of which to get the name.
230 @returns Name of trace class \p trace_class, or
231 \c NULL if \p trace_class is unnamed or
234 @prenotnull{trace_class}
235 @postrefcountsame{trace_class}
237 @sa bt_trace_set_name(): Sets the name of a given trace class.
239 extern const char *bt_trace_get_name(struct bt_trace
*trace_class
);
242 @brief Sets the name of the CTF IR trace class \p trace_class
245 @param[in] trace_class Trace class of which to set the name.
246 @param[in] name Name of the trace class (copied on success).
247 @returns 0 on success, or a negative value on error.
249 @prenotnull{trace_class}
252 @postrefcountsame{trace_class}
254 @sa bt_trace_get_name(): Returns the name of a given trace class.
256 extern int bt_trace_set_name(struct bt_trace
*trace_class
,
260 @brief Returns the native byte order of the CTF IR trace class
263 @param[in] trace_class Trace class of which to get the default byte
265 @returns Native byte order of \p trace_class,
266 or #BT_BYTE_ORDER_UNKNOWN on error.
268 @prenotnull{trace_class}
269 @postrefcountsame{trace_class}
271 @sa bt_trace_set_native_byte_order(): Sets the native byte order of
274 extern enum bt_byte_order
bt_trace_get_native_byte_order(
275 struct bt_trace
*trace_class
);
278 @brief Sets the native byte order of the CTF IR trace class
279 \p trace_class to \p native_byte_order.
281 \p native_byte_order \em must be one of:
283 - #BT_BYTE_ORDER_LITTLE_ENDIAN
284 - #BT_BYTE_ORDER_BIG_ENDIAN
285 - #BT_BYTE_ORDER_NETWORK
286 - <strong>If the trace is not in CTF writer mode<strong>,
287 #BT_BYTE_ORDER_UNSPECIFIED.
289 @param[in] trace_class Trace class of which to set the native byte
291 @param[in] native_byte_order Native byte order of the trace class.
292 @returns 0 on success, or a negative value on error.
294 @prenotnull{trace_class}
296 @pre \p native_byte_order is either #BT_BYTE_ORDER_UNSPECIFIED (if the
297 trace is not in CTF writer mode),
298 #BT_BYTE_ORDER_LITTLE_ENDIAN, #BT_BYTE_ORDER_BIG_ENDIAN, or
299 #BT_BYTE_ORDER_NETWORK.
300 @postrefcountsame{trace_class}
302 @sa bt_trace_get_native_byte_order(): Returns the native byte order of a
305 extern int bt_trace_set_native_byte_order(struct bt_trace
*trace_class
,
306 enum bt_byte_order native_byte_order
);
309 @brief Returns the UUID of the CTF IR trace class \p trace_class.
311 On success, the return value is an array of 16 bytes.
313 @param[in] trace_class Trace class of which to get the UUID.
314 @returns UUID of trace class \p trace_class, or
315 \c NULL if \p trace_class has no UUID or on error.
317 @prenotnull{trace_class}
318 @postrefcountsame{trace_class}
320 @sa bt_trace_set_uuid(): Sets the UUID of a given trace class.
322 extern const unsigned char *bt_trace_get_uuid(
323 struct bt_trace
*trace_class
);
326 @brief Sets the UUID of the CTF IR trace class \p trace_class to
329 \p uuid \em must be an array of 16 bytes.
331 @param[in] trace_class Trace class of which to set the UUID.
332 @param[in] uuid UUID of the \p trace_class (copied on
334 @returns 0 on success, or a negative value on error.
336 @prenotnull{trace_class}
339 @pre \p uuid is an array of 16 bytes.
340 @postrefcountsame{trace_class}
342 @sa bt_trace_get_uuid(): Returns the UUID of a given trace class.
344 extern int bt_trace_set_uuid(struct bt_trace
*trace_class
,
345 const unsigned char *uuid
);
348 @brief Returns the number of entries contained in the environment of
349 the CTF IR trace class \p trace_class.
351 @param[in] trace_class Trace class of which to get the number
352 of environment entries.
353 @returns Number of environment entries
354 contained in \p trace_class, or
355 a negative value on error.
357 @prenotnull{trace_class}
358 @postrefcountsame{trace_class}
360 extern int64_t bt_trace_get_environment_field_count(
361 struct bt_trace
*trace_class
);
364 @brief Returns the field name of the environment entry at index
365 \p index in the CTF IR trace class \p trace_class.
367 On success, the returned string is valid as long as this trace class
368 exists and is \em not modified. \p trace_class remains the sole owner of
371 @param[in] trace_class Trace class of which to get the name of the
372 environment entry at index \p index.
373 @param[in] index Index of environment entry to find.
374 @returns Name of the environment entry at index \p index
375 in \p trace_class, or \c NULL on error.
377 @prenotnull{trace_class}
378 @pre \p index is lesser than the number of environment entries in
379 \p trace_class (see bt_trace_get_environment_field_count()).
380 @postrefcountsame{trace_class}
382 @sa bt_trace_get_environment_field_value_by_index(): Finds a trace class's
383 environment entry by index.
384 @sa bt_trace_get_environment_field_value_by_name(): Finds a trace
385 class's environment entry by name.
386 @sa bt_trace_set_environment_field(): Sets the value of a trace
387 class's environment entry.
390 bt_trace_get_environment_field_name_by_index(
391 struct bt_trace
*trace_class
, uint64_t index
);
394 @brief Returns the value of the environment entry at index
395 \p index in the CTF IR trace class \p trace_class.
397 @param[in] trace_class Trace class of which to get the value of the
398 environment entry at index \p index.
399 @param[in] index Index of the environment entry to find.
400 @returns Value of the environment entry at index \p index
401 in \p trace_class, or \c NULL on error.
403 @prenotnull{trace_class}
404 @pre \p index is lesser than the number of environment entries in
405 \p trace_class (see bt_trace_get_environment_field_count()).
406 @postrefcountsame{trace_class}
407 @postsuccessrefcountretinc
409 @sa bt_trace_get_environment_field_value_by_name(): Finds a trace
410 class's environment entry by name.
411 @sa bt_trace_set_environment_field(): Sets the value of a trace
412 class's environment entry.
414 extern struct bt_value
*
415 bt_trace_get_environment_field_value_by_index(struct bt_trace
*trace_class
,
419 @brief Returns the value of the environment entry named \p name
420 in the CTF IR trace class \p trace_class.
422 @param[in] trace_class Trace class of which to get the value of the
423 environment entry named \p name.
424 @param[in] name Name of the environment entry to find.
425 @returns Value of the environment entry named \p name
426 in \p trace_class, or \c NULL if there's no such
429 @prenotnull{trace_class}
431 @postrefcountsame{trace_class}
432 @postsuccessrefcountretinc
434 @sa bt_trace_get_environment_field_value_by_index(): Finds a trace class's
435 environment entry by index.
436 @sa bt_trace_set_environment_field(): Sets the value of a trace
437 class's environment entry.
439 extern struct bt_value
*
440 bt_trace_get_environment_field_value_by_name(
441 struct bt_trace
*trace_class
, const char *name
);
444 @brief Sets the environment entry named \p name in the
445 CTF IR trace class \p trace_class to \p value.
447 If an environment entry named \p name exists in \p trace_class, its
448 value is first put, and then replaced by \p value.
450 @param[in] trace_class Trace class of which to set the environment
452 @param[in] name Name of the environment entry to set (copied
454 @param[in] value Value of the environment entry named \p name.
455 @returns 0 on success, or a negative value on error.
457 @prenotnull{trace_class}
462 \link bt_value_integer_create() integer value object\endlink
464 \link bt_value_string_create() string value object\endlink.
465 @postrefcountsame{trace_class}
466 @postsuccessrefcountinc{value}
468 @sa bt_trace_get_environment_field_value_by_index(): Finds a trace class's
469 environment entry by index.
470 @sa bt_trace_get_environment_field_value_by_name(): Finds a trace
471 class's environment entry by name.
473 extern int bt_trace_set_environment_field(
474 struct bt_trace
*trace_class
, const char *name
,
475 struct bt_value
*value
);
478 @brief Sets the environment entry named \p name in the
479 CTF IR trace class \p trace_class to \p value.
481 If an environment entry named \p name exists in \p trace_class, its
482 value is first put, and then replaced by a new
483 \link bt_value_integer_create() integer value object\endlink
486 @param[in] trace_class Trace class of which to set the environment
488 @param[in] name Name of the environment entry to set (copied
490 @param[in] value Value of the environment entry named \p name.
491 @returns 0 on success, or a negative value on error.
493 @prenotnull{trace_class}
496 @postrefcountsame{trace_class}
498 @sa bt_trace_set_environment_field(): Sets the value of a trace
499 class's environment entry.
501 extern int bt_trace_set_environment_field_integer(
502 struct bt_trace
*trace_class
, const char *name
,
506 @brief Sets the environment entry named \p name in the
507 CTF IR trace class \p trace_class to \p value.
509 If an environment entry named \p name exists in \p trace_class, its
510 value is first put, and then replaced by a new
511 \link bt_value_string_create() string value object\endlink
514 @param[in] trace_class Trace class of which to set the environment
516 @param[in] name Name of the environment entry to set (copied
518 @param[in] value Value of the environment entry named \p name
520 @returns 0 on success, or a negative value on error.
522 @prenotnull{trace_class}
526 @postrefcountsame{trace_class}
528 @sa bt_trace_set_environment_field(): Sets the value of a trace
529 class's environment entry.
531 extern int bt_trace_set_environment_field_string(
532 struct bt_trace
*trace_class
, const char *name
,
538 @name Contained field types functions
543 @brief Returns the packet header field type of the CTF IR trace class
546 @param[in] trace_class Trace class of which to get the packet
548 @returns Packet header field type of \p trace_class,
549 or \c NULL if \p trace_class has no packet header field
552 @prenotnull{trace_class}
553 @postrefcountsame{trace_class}
554 @post <strong>On success, if the return value is a field type</strong>, its
555 reference count is incremented.
557 @sa bt_trace_set_packet_header_type(): Sets the packet
558 header field type of a given trace class.
560 extern struct bt_field_type
*bt_trace_get_packet_header_type(
561 struct bt_trace
*trace_class
);
564 @brief Sets the packet header field type of the CTF IR trace class
565 \p trace_class to \p packet_header_type, or unsets the current packet
566 header field type from \p trace_class.
568 If \p packet_header_type is \c NULL, then this function unsets the current
569 packet header field type from \p trace_class, effectively making \p trace_class
570 a trace without a packet header field type.
572 As of Babeltrace \btversion, if \p packet_header_type is not \c NULL,
573 \p packet_header_type \em must be a CTF IR structure field type object.
575 @param[in] trace_class Trace class of which to set the packet
577 @param[in] packet_header_type Packet header field type, or \c NULL to unset
578 the current packet header field type.
579 @returns 0 on success, or a negative value on error.
581 @prenotnull{trace_class}
583 @pre <strong>\p packet_header_type, if not \c NULL</strong>, is a CTF IR
584 structure field type.
585 @postrefcountsame{trace_class}
586 @post <strong>On success, if \p packet_header_type is not \c NULL</strong>,
587 the reference count of \p packet_header_type is incremented.
589 @sa bt_trace_get_packet_header_type(): Returns the packet
590 header field type of a given trace class.
592 extern int bt_trace_set_packet_header_type(struct bt_trace
*trace_class
,
593 struct bt_field_type
*packet_header_type
);
598 @name Contained clock classes functions
603 @brief Returns the number of CTF IR clock classes contained in the
604 CTF IR trace class \p trace_class.
606 @param[in] trace_class Trace class of which to get the number
607 of contained clock classes.
608 @returns Number of contained clock classes
609 contained in \p trace_class, or a negative
612 @prenotnull{trace_class}
613 @postrefcountsame{trace_class}
615 extern int64_t bt_trace_get_clock_class_count(
616 struct bt_trace
*trace_class
);
619 @brief Returns the CTF IR clock class at index \p index in the CTF
620 IR trace class \p trace_class.
622 @param[in] trace_class Trace class of which to get the clock class
623 contained at index \p index.
624 @param[in] index Index of the clock class to find in
626 @returns Clock class at index \p index in \p trace_class,
629 @prenotnull{trace_class}
630 @pre \p index is lesser than the number of clock classes contained in
631 the trace class \p trace_class (see
632 bt_trace_get_clock_class_count()).
633 @postrefcountsame{trace_class}
634 @postsuccessrefcountretinc
636 @sa bt_trace_get_clock_class_by_name(): Finds a clock class by name
637 in a given trace class.
638 @sa bt_trace_add_clock_class(): Adds a clock class to a trace class.
640 extern struct bt_clock_class
*bt_trace_get_clock_class_by_index(
641 struct bt_trace
*trace_class
, uint64_t index
);
644 @brief Returns the CTF IR clock class named \c name found in the CTF
645 IR trace class \p trace_class.
647 @param[in] trace_class Trace class of which to get the clock class
649 @param[in] name Name of the clock class to find in \p trace_class.
650 @returns Clock class named \p name in \p trace_class,
653 @prenotnull{trace_class}
655 @postrefcountsame{trace_class}
656 @postsuccessrefcountretinc
658 @sa bt_trace_get_clock_class_by_index(): Returns the clock class contained
659 in a given trace class at a given index.
660 @sa bt_trace_add_clock_class(): Adds a clock class to a trace class.
662 extern struct bt_clock_class
*bt_trace_get_clock_class_by_name(
663 struct bt_trace
*trace_class
, const char *name
);
666 @brief Adds the CTF IR clock class \p clock_class to the CTF IR
667 trace class \p trace_class.
669 On success, \p trace_class contains \p clock_class.
671 You can call this function even if \p trace_class or \p clock_class
674 @param[in] trace_class Trace class to which to add \p clock_class.
675 @param[in] clock_class Clock class to add to \p trace_class.
676 @returns 0 on success, or a negative value on error.
678 @prenotnull{trace_class}
679 @prenotnull{clock_class}
680 @postrefcountsame{trace_class}
681 @postsuccessrefcountinc{clock_class}
682 @post <strong>On success, if \p trace_class is frozen</strong>,
683 \p clock_class is frozen.
685 @sa bt_trace_get_clock_class_by_index(): Returns the clock class contained
686 in a given trace class at a given index.
687 @sa bt_trace_get_clock_class_by_name(): Finds a clock class by name
688 in a given trace class.
690 extern int bt_trace_add_clock_class(struct bt_trace
*trace_class
,
691 struct bt_clock_class
*clock_class
);
696 @name Stream class children functions
701 @brief Returns the number of stream classes contained in the
702 CTF IR trace class \p trace_class.
704 @param[in] trace_class Trace class of which to get the number
705 of children stream classes.
706 @returns Number of children stream classes
707 contained in \p trace_class, or a negative
710 @prenotnull{trace_class}
711 @postrefcountsame{trace_class}
713 extern int64_t bt_trace_get_stream_class_count(
714 struct bt_trace
*trace_class
);
717 @brief Returns the stream class at index \p index in the CTF IR trace
718 class \p trace_class.
720 @param[in] trace_class Trace class of which to get the stream class.
721 @param[in] index Index of the stream class to find.
722 @returns Stream class at index \p index, or \c NULL
725 @prenotnull{trace_class}
726 @pre \p index is lesser than the number of stream classes contained in
727 the trace class \p trace_class (see
728 bt_trace_get_stream_class_count()).
729 @postrefcountsame{trace_class}
731 @sa bt_trace_get_stream_class_by_id(): Finds a stream class by ID.
732 @sa bt_trace_add_stream_class(): Adds a stream class to a trace class.
734 extern struct bt_stream_class
*bt_trace_get_stream_class_by_index(
735 struct bt_trace
*trace_class
, uint64_t index
);
738 @brief Returns the stream class with ID \c id found in the CTF IR
739 trace class \p trace_class.
741 @param[in] trace_class Trace class of which to get the stream class.
742 @param[in] id ID of the stream class to find.
743 @returns Stream class with ID \p id, or \c NULL
746 @prenotnull{trace_class}
747 @postrefcountsame{trace_class}
748 @postsuccessrefcountretinc
750 @sa bt_trace_get_stream_class_by_index(): Returns the stream class contained
751 in a given trace class at a given index.
752 @sa bt_trace_add_stream_class(): Adds a stream class to a trace class.
754 extern struct bt_stream_class
*bt_trace_get_stream_class_by_id(
755 struct bt_trace
*trace_class
, uint64_t id
);
758 @brief Adds the CTF IR stream class \p stream_class to the
759 CTF IR trace class \p trace_class.
761 On success, \p stream_class becomes the child of \p trace_class.
763 You can only add a given stream class to one trace class.
765 You can call this function even if \p trace_class is frozen.
767 This function tries to resolve the needed
768 \link ctfirfieldtypes CTF IR field type\endlink of the dynamic field
769 types that are found anywhere in the root field types of
770 \p stream_class and of all its currently contained
771 \link ctfireventclass CTF IR event classes\endlink. If any automatic
772 resolving fails, then this function fails.
774 @param[in] trace_class Trace class to which to add \p stream_class.
775 @param[in] stream_class Stream class to add to \p trace_class.
776 @returns 0 on success, or a negative value on error.
778 @prenotnull{trace_class}
779 @prenotnull{stream_class}
780 @postrefcountsame{trace_class}
781 @postsuccessrefcountinc{stream_class}
782 @postsuccessfrozen{stream_class}
784 @sa bt_trace_get_stream_class_by_index(): Returns the stream class contained
785 in a given trace class at a given index.
786 @sa bt_trace_get_stream_class_by_id(): Finds a stream class by ID.
788 extern int bt_trace_add_stream_class(struct bt_trace
*trace_class
,
789 struct bt_stream_class
*stream_class
);
794 @name Stream children functions
799 @brief Returns the number of streams contained in the CTF IR trace
800 class \p trace_class.
802 @param[in] trace_class Trace class of which to get the number
804 @returns Number of children streams
805 contained in \p trace_class, or a negative
808 @prenotnull{trace_class}
809 @postrefcountsame{trace_class}
811 extern int64_t bt_trace_get_stream_count(struct bt_trace
*trace_class
);
814 @brief Returns the stream at index \p index in the CTF IR trace
815 class \p trace_class.
817 @param[in] trace_class Trace class of which to get the stream.
818 @param[in] index Index of the stream to find.
819 @returns Stream at index \p index, or \c NULL
822 @prenotnull{trace_class}
823 @pre \p index is lesser than the number of streams contained in
824 the trace class \p trace_class (see
825 bt_trace_get_stream_count()).
826 @postrefcountsame{trace_class}
828 extern struct bt_stream
*bt_trace_get_stream_by_index(
829 struct bt_trace
*trace_class
, uint64_t index
);
834 @name Misc. functions
839 @brief Returns whether or not the CTF IR trace class \p trace_class
842 It is guaranteed that a static trace class will never contain new
843 streams, stream classes, or clock classes. A static class is always
846 This function returns #BT_TRUE if bt_trace_set_is_static() was
847 previously called on it.
849 @param[in] trace_class Trace class to check.
850 @returns #BT_TRUE if \p trace_class is static,
852 @sa bt_trace_set_is_static(): Makes a trace class static.
854 extern bt_bool
bt_trace_is_static(struct bt_trace
*trace_class
);
857 @brief Makes the CTF IR trace class \p trace_class static.
859 A static trace class is frozen and you cannot call any modifying
862 - bt_trace_add_stream_class()
863 - bt_trace_add_clock_class()
864 - bt_trace_set_environment_field()
865 - bt_trace_set_environment_field_integer()
866 - bt_trace_set_environment_field_string()
867 - bt_trace_add_is_static_listener()
869 You cannot create a stream with bt_stream_create() with any of the
870 stream classes of a static trace class.
872 @param[in] trace_class Trace class to make static.
873 @returns 0 on success, or a negative value on error.
875 @prenotnull{trace_class}
876 @postrefcountsame{trace_class}
877 @postsuccessfrozen{trace_class}
879 @sa bt_trace_is_static(): Checks whether or not a given trace class
881 @sa bt_trace_add_is_static_listener(): Adds a listener to a trace
882 class which is called when the trace class is made static.
884 extern int bt_trace_set_is_static(struct bt_trace
*trace_class
);
887 @brief Adds the listener \p listener to the CTF IR trace class
888 \p trace_class which is called when the trace is made static.
890 \p listener is called with \p data, the user data, the first time
891 bt_trace_set_is_static() is called on \p trace_class.
893 When the trace is destroyed, or when you remove the added listener with
894 bt_trace_remove_is_static_listener(), \p listener_removed is called
895 if it's not \c NULL. You can use \p listener_removed to free any dynamic
896 data which exists only for the added listener. You cannot call
897 any function which modifies \p trace_class during the execution of
898 \p listener_removed, including bt_trace_remove_is_static_listener().
900 This function fails if \p trace_class is already static: you need to
901 check the condition first with bt_trace_is_static().
903 On success, this function returns a unique numeric identifier for this
904 listener within \p trace. You can use this identifier to remove the
905 specific listener you added with
906 bt_trace_remove_is_static_listener().
908 @param[in] trace_class Trace class to which to add the
910 @param[in] listener Listener to add to \p trace_class.
911 @param[in] listener_removed Remove listener called when \p listener
912 is removed from \p trace_class, or
913 \c NULL if you don't need a remove
915 @param[in] data User data passed when \p listener or
916 \p listener_removed is called.
917 @returns A unique numeric identifier for this
918 listener on success (0 or greater), or a
919 negative value on error.
921 @prenotnull{trace_class}
922 @prenotnull{listener}
923 @pre \p trace_class is not static.
924 @postrefcountsame{trace_class}
926 @sa bt_trace_remove_is_static_listener(): Removes a "trace is
927 static" listener from a trace class previously added with this
929 @sa bt_trace_is_static(): Checks whether or not a given trace class
931 @sa bt_trace_set_is_static(): Makes a trace class static.
933 extern int bt_trace_add_is_static_listener(
934 struct bt_trace
*trace_class
,
935 bt_trace_is_static_listener listener
,
936 bt_trace_listener_removed listener_removed
, void *data
);
939 @brief Removes the "trace is static" listener identified by
940 \p listener_id from the trace class \p trace_class.
942 @param[in] trace_class Trace class from which to remove the listener
943 identified by \p listener_id.
944 @param[in] listener_id Identifier of the listener to remove from
946 @returns 0 if this function removed the listener, or
947 a negative value on error.
949 @prenotnull{trace_class}
950 @pre \p listener_id is the identifier of a listener that you previously
951 added with bt_trace_add_is_static_listener() and did not
952 already remove with this function.
953 @postrefcountsame{trace_class}
955 @sa bt_trace_add_is_static_listener(): Adds a listener to a trace
956 class which is called when the trace class is made static.
958 extern int bt_trace_remove_is_static_listener(
959 struct bt_trace
*trace_class
, int listener_id
);
962 @brief Accepts the visitor \p visitor to visit the hierarchy of the
963 CTF IR trace class \p trace_class.
965 This function traverses the hierarchy of \p trace_class in pre-order
966 and calls \p visitor on each element.
968 The trace class itself is visited first, then, for each children stream
969 class, the stream class itself, and all its children event classes.
971 @param[in] trace_class Trace class to visit.
972 @param[in] visitor Visiting function.
973 @param[in] data User data.
974 @returns 0 on success, or a negative value on error.
976 @prenotnull{trace_class}
979 extern int bt_trace_visit(struct bt_trace
*trace_class
,
980 bt_visitor visitor
, void *data
);
986 /* Pre-2.0 CTF writer compatibility */
987 #define bt_ctf_trace bt_trace
993 #endif /* BABELTRACE_CTF_IR_TRACE_H */