flt.utils.muxer: add IWYU pragma
[babeltrace.git] / include / babeltrace2 / trace-ir / trace.h
... / ...
CommitLineData
1/*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright (C) 2010-2019 EfficiOS Inc. and Linux Foundation
5 */
6
7#ifndef BABELTRACE2_TRACE_IR_TRACE_H
8#define BABELTRACE2_TRACE_IR_TRACE_H
9
10/* IWYU pragma: private, include <babeltrace2/babeltrace.h> */
11
12#ifndef __BT_IN_BABELTRACE_H
13# error "Please include <babeltrace2/babeltrace.h> instead."
14#endif
15
16#include <stdint.h>
17
18#include <babeltrace2/types.h>
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24/*!
25@defgroup api-tir-trace Trace
26@ingroup api-tir
27
28@brief
29 Trace (set of \bt_p_stream).
30
31A <strong><em>trace</em></strong> is a set of \bt_p_stream with
32properties:
33
34@image html trace-structure.png
35
36In the illustration above, notice that a trace is an instance of a
37\bt_trace_cls and that it contains streams.
38
39Borrow the class of a trace with bt_trace_borrow_class() and
40bt_trace_borrow_class_const().
41
42A trace is a \ref api-tir "trace IR" data object.
43
44A trace is a \ref api-fund-shared-object "shared object": get a
45new reference with bt_trace_get_ref() and put an existing
46reference with bt_trace_put_ref().
47
48Some library functions \ref api-fund-freezing "freeze" traces on
49success. The documentation of those functions indicate this
50postcondition. With a frozen trace, you can still:
51
52- Create \bt_p_stream from it with bt_stream_create() or
53 bt_stream_create_with_id().
54- Add a destruction listener to it with
55 bt_trace_add_destruction_listener().
56
57The type of a trace is #bt_trace.
58
59A trace contains \bt_p_stream. All the streams of a
60given trace have unique \ref api-tir-stream-prop-id "numeric IDs".
61Get the number of streams in a trace with bt_trace_get_stream_count().
62Borrow a specific stream from a trace with
63bt_trace_borrow_stream_by_index(),
64bt_trace_borrow_stream_by_index_const(), bt_trace_borrow_stream_by_id(),
65or bt_trace_borrow_stream_by_id_const().
66
67Create a default trace from a \bt_trace_cls with bt_trace_create().
68
69Add to and remove a destruction listener from a trace with
70bt_trace_add_destruction_listener() and
71bt_trace_remove_destruction_listener().
72
73<h1>Properties</h1>
74
75A trace has the following properties:
76
77<dl>
78 <dt>
79 \anchor api-tir-trace-prop-ns
80 \bt_dt_opt Namespace
81 (only available when the class of the trace was created
82 from a \bt_comp which belongs to a trace processing \bt_graph
83 with the effective \bt_mip version&nbsp;1)
84 </dt>
85 <dd>
86 Namespace of the trace.
87
88 Use bt_trace_set_namespace() and
89 bt_trace_get_namespace().
90 </dd>
91
92 <dt>
93 \anchor api-tir-trace-prop-name
94 \bt_dt_opt Name
95 </dt>
96 <dd>
97 Name of the trace.
98
99 Use bt_trace_set_name() and bt_trace_get_name().
100 </dd>
101
102 <dt>
103 \bt_dt_opt Depending on the effective \bt_mip (MIP) version of the
104 trace processing \bt_graph:
105 </dt>
106 <dd>
107 <dl>
108 <dt>
109 \anchor api-tir-trace-prop-uuid
110 MIP&nbsp;0: UUID
111 </dt>
112 <dd>
113 <a href="https://en.wikipedia.org/wiki/Universally_unique_identifier">UUID</a>
114 of the trace.
115
116 The trace's UUID uniquely identifies the trace.
117
118 Use bt_trace_set_uuid() and bt_trace_get_uuid().
119 </dd>
120
121 <dt>
122 \anchor api-tir-trace-prop-uid
123 MIP&nbsp;1: UID
124 </dt>
125 <dd>
126 <a href="https://en.wikipedia.org/wiki/Unique_identifier">Unique identifier</a>
127 (UID) of the trace.
128
129 The combination of the trace's
130 \link api-tir-trace-prop-name name\endlink and UID
131 uniquely identifies the trace.
132
133 Use bt_trace_set_uid() and bt_trace_get_uid().
134 </dd>
135 </dl>
136 </dd>
137 <dt>
138 \anchor api-tir-trace-prop-env
139 \bt_dt_opt Environment
140 </dt>
141 <dd>
142 Generic key-value store which describes the environment of the trace
143 (for example, the system's hostname, its network address, the
144 tracer's name and version, and the rest).
145
146 Trace environment keys are strings while values are signed integers
147 or strings.
148
149 Set a trace environment entry's value with
150 bt_trace_set_environment_entry_integer() and
151 bt_trace_set_environment_entry_string().
152
153 Get the number of environment entries in a trace with
154 bt_trace_get_environment_entry_count().
155
156 Borrow an environment entry from a trace with
157 bt_trace_borrow_environment_entry_value_by_name_const().
158 </dd>
159
160 <dt>
161 \anchor api-tir-trace-prop-user-attrs
162 \bt_dt_opt User attributes
163 </dt>
164 <dd>
165 User attributes of the trace.
166
167 User attributes are custom attributes attached to a trace.
168
169 Use bt_trace_set_user_attributes(),
170 bt_trace_borrow_user_attributes(), and
171 bt_trace_borrow_user_attributes_const().
172 </dd>
173</dl>
174*/
175
176/*! @{ */
177
178/*!
179@name Type
180@{
181
182@typedef struct bt_trace bt_trace;
183
184@brief
185 Trace.
186
187@}
188*/
189
190/*!
191@name Creation
192@{
193*/
194
195/*!
196@brief
197 Creates a default trace from the \bt_trace_cls \bt_p{trace_class}.
198
199This function instantiates \bt_p{trace_class}.
200
201On success, the returned trace has the following property values:
202
203<table>
204 <tr>
205 <th>Property
206 <th>Value
207 <tr>
208 <td>\bt_mip version&nbsp;1: \ref api-tir-trace-prop-ns "Namespace"
209 <td>\em None
210 <tr>
211 <td>\ref api-tir-trace-prop-name "Name"
212 <td>\em None
213 <tr>
214 <td>\bt_mip (MIP) version&nbsp;0: \ref api-tir-trace-prop-uuid "UUID"
215 <td>\em None
216 <tr>
217 <td>MIP&nbsp;1: \ref api-tir-trace-prop-uid "UID"
218 <td>\em None
219 <tr>
220 <td>\ref api-tir-trace-prop-env "Environment"
221 <td>Empty
222 <tr>
223 <td>\ref api-tir-trace-prop-user-attrs "User attributes"
224 <td>Empty \bt_map_val
225</table>
226
227@param[in] trace_class
228 Trace class from which to create the default trace.
229
230@returns
231 New trace reference, or \c NULL on memory error.
232*/
233extern bt_trace *bt_trace_create(bt_trace_class *trace_class) __BT_NOEXCEPT;
234
235/*! @} */
236
237/*!
238@name Class access
239@{
240*/
241
242/*!
243@brief
244 Borrows the \ref api-tir-trace-cls "class" of the trace
245 \bt_p{trace}.
246
247@param[in] trace
248 Trace of which to borrow the class.
249
250@returns
251 \em Borrowed reference of the class of \bt_p{trace}.
252
253@bt_pre_not_null{trace}
254
255@sa bt_trace_borrow_class_const() &mdash;
256 \c const version of this function.
257*/
258extern bt_trace_class *bt_trace_borrow_class(bt_trace *trace) __BT_NOEXCEPT;
259
260/*!
261@brief
262 Borrows the \ref api-tir-trace-cls "class" of the trace
263 \bt_p{trace} (\c const version).
264
265See bt_trace_borrow_class().
266*/
267extern const bt_trace_class *bt_trace_borrow_class_const(
268 const bt_trace *trace) __BT_NOEXCEPT;
269
270/*! @} */
271
272/*!
273@name Stream access
274@{
275*/
276
277/*!
278@brief
279 Returns the number of \bt_p_stream contained in the trace
280 \bt_p{trace}.
281
282@param[in] trace
283 Trace of which to get the number of contained streams.
284
285@returns
286 Number of contained streams in \bt_p{trace}.
287
288@bt_pre_not_null{trace}
289*/
290extern uint64_t bt_trace_get_stream_count(const bt_trace *trace) __BT_NOEXCEPT;
291
292/*!
293@brief
294 Borrows the \bt_stream at index \bt_p{index} from the
295 trace \bt_p{trace}.
296
297@param[in] trace
298 Trace from which to borrow the stream at index
299 \bt_p{index}.
300@param[in] index
301 Index of the stream to borrow from \bt_p{trace}.
302
303@returns
304 @parblock
305 \em Borrowed reference of the stream of
306 \bt_p{trace} at index \bt_p{index}.
307
308 The returned pointer remains valid as long as \bt_p{trace}
309 exists.
310 @endparblock
311
312@bt_pre_not_null{trace}
313@pre
314 \bt_p{index} is less than the number of streams in
315 \bt_p{trace} (as returned by
316 bt_trace_get_stream_count()).
317
318@sa bt_trace_get_stream_count() &mdash;
319 Returns the number of streams contained in a trace.
320@sa bt_trace_borrow_stream_by_index_const() &mdash;
321 \c const version of this function.
322*/
323extern bt_stream *bt_trace_borrow_stream_by_index(bt_trace *trace,
324 uint64_t index) __BT_NOEXCEPT;
325
326/*!
327@brief
328 Borrows the \bt_stream at index \bt_p{index} from the
329 trace \bt_p{trace} (\c const version).
330
331See bt_trace_borrow_stream_by_index().
332*/
333extern const bt_stream *bt_trace_borrow_stream_by_index_const(
334 const bt_trace *trace, uint64_t index) __BT_NOEXCEPT;
335
336/*!
337@brief
338 Borrows the \bt_stream having the numeric ID \bt_p{id} from the
339 trace \bt_p{trace}.
340
341If there's no stream having the numeric ID \bt_p{id} in
342\bt_p{trace}, this function returns \c NULL.
343
344@param[in] trace
345 Trace from which to borrow the stream having the
346 numeric ID \bt_p{id}.
347@param[in] id
348 ID of the stream to borrow from \bt_p{trace}.
349
350@returns
351 @parblock
352 \em Borrowed reference of the stream of
353 \bt_p{trace} having the numeric ID \bt_p{id}, or \c NULL
354 if none.
355
356 The returned pointer remains valid as long as \bt_p{trace}
357 exists.
358 @endparblock
359
360@bt_pre_not_null{trace}
361
362@sa bt_trace_borrow_stream_by_id_const() &mdash;
363 \c const version of this function.
364*/
365extern bt_stream *bt_trace_borrow_stream_by_id(bt_trace *trace,
366 uint64_t id) __BT_NOEXCEPT;
367
368/*!
369@brief
370 Borrows the \bt_stream having the numeric ID \bt_p{id} from the
371 trace \bt_p{trace} (\c const version).
372
373See bt_trace_borrow_stream_by_id().
374*/
375extern const bt_stream *bt_trace_borrow_stream_by_id_const(
376 const bt_trace *trace, uint64_t id) __BT_NOEXCEPT;
377
378/*! @} */
379
380/*!
381@name Properties
382@{
383*/
384
385/*!
386@brief
387 Status codes for bt_trace_set_namespace().
388*/
389typedef enum bt_trace_set_namespace_status {
390 /*!
391 @brief
392 Success.
393 */
394 BT_TRACE_SET_NAMESPACE_STATUS_OK = __BT_FUNC_STATUS_OK,
395
396 /*!
397 @brief
398 Out of memory.
399 */
400 BT_TRACE_SET_NAMESPACE_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
401} bt_trace_set_namespace_status;
402
403/*!
404@brief
405 Sets the namespace of the trace \bt_p{trace} to a copy of \bt_p{ns}.
406
407See the \ref api-tir-trace-prop-ns "namespace" property.
408
409@param[in] trace
410 Trace of which to set the namespace to \bt_p{ns}.
411@param[in] name
412 New namespace of \bt_p{trace} (copied).
413
414@retval #BT_TRACE_SET_NAMESPACE_STATUS_OK
415 Success.
416@retval #BT_TRACE_SET_NAMESPACE_STATUS_MEMORY_ERROR
417 Out of memory.
418
419@bt_pre_not_null{trace}
420@bt_pre_hot{trace}
421@bt_pre_trace_with_mip{trace, 1}
422@bt_pre_not_null{ns}
423
424@sa bt_trace_get_namespace() &mdash;
425 Returns the namespace of a trace.
426*/
427extern bt_trace_set_namespace_status bt_trace_set_namespace(bt_trace *trace,
428 const char *ns) __BT_NOEXCEPT;
429
430/*!
431@brief
432 Returns the namespace of the trace \bt_p{trace}.
433
434See the \ref api-tir-trace-prop-ns "namespace" property.
435
436If \bt_p{trace} has no namespace, this function returns \c NULL.
437
438@param[in] trace
439 Trace of which to get the namespace.
440
441@returns
442 @parblock
443 Namespace of \bt_p{trace}, or \c NULL if none.
444
445 The returned pointer remains valid as long as \bt_p{trace}
446 is not modified.
447 @endparblock
448
449@bt_pre_not_null{trace}
450@bt_pre_stream_cls_with_mip{trace, 1}
451
452@sa bt_trace_set_namespace() &mdash;
453 Sets the namespace of a trace.
454*/
455extern const char *bt_trace_get_namespace(const bt_trace *trace) __BT_NOEXCEPT;
456
457/*!
458@brief
459 Status codes for bt_trace_set_name().
460*/
461typedef enum bt_trace_set_name_status {
462 /*!
463 @brief
464 Success.
465 */
466 BT_TRACE_SET_NAME_STATUS_OK = __BT_FUNC_STATUS_OK,
467
468 /*!
469 @brief
470 Out of memory.
471 */
472 BT_TRACE_SET_NAME_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
473} bt_trace_set_name_status;
474
475/*!
476@brief
477 Sets the name of the trace \bt_p{trace} to a copy of \bt_p{name}.
478
479See the \ref api-tir-trace-prop-name "name" property.
480
481@param[in] trace
482 Trace of which to set the name to \bt_p{name}.
483@param[in] name
484 New name of \bt_p{trace} (copied).
485
486@retval #BT_TRACE_SET_NAME_STATUS_OK
487 Success.
488@retval #BT_TRACE_SET_NAME_STATUS_MEMORY_ERROR
489 Out of memory.
490
491@bt_pre_not_null{trace}
492@bt_pre_hot{trace}
493@bt_pre_not_null{name}
494
495@sa bt_trace_get_name() &mdash;
496 Returns the name of a trace.
497*/
498extern bt_trace_set_name_status bt_trace_set_name(bt_trace *trace,
499 const char *name) __BT_NOEXCEPT;
500
501/*!
502@brief
503 Returns the name of the trace \bt_p{trace}.
504
505See the \ref api-tir-trace-prop-name "name" property.
506
507If \bt_p{trace} has no name, this function returns \c NULL.
508
509@param[in] trace
510 Trace of which to get the name.
511
512@returns
513 @parblock
514 Name of \bt_p{trace}, or \c NULL if none.
515
516 The returned pointer remains valid as long as \bt_p{trace}
517 is not modified.
518 @endparblock
519
520@bt_pre_not_null{trace}
521
522@sa bt_trace_set_name() &mdash;
523 Sets the name of a trace.
524*/
525extern const char *bt_trace_get_name(const bt_trace *trace) __BT_NOEXCEPT;
526
527/*!
528@brief
529 Sets the
530 <a href="https://en.wikipedia.org/wiki/Universally_unique_identifier">UUID</a>
531 of the trace \bt_p{trace} to a copy of \bt_p{uuid}.
532
533@note
534 @parblock
535 This function is only available when the class of \bt_p{trace} was
536 created from a \bt_comp which belongs to a trace processing
537 \bt_graph with the effective \bt_mip (MIP) version&nbsp;0.
538
539 With MIP&nbsp;1, see the
540 \ref api-tir-trace-prop-uid "UID" property.
541 @endparblock
542
543See the \ref api-tir-trace-prop-uuid "UUID" property.
544
545@param[in] trace
546 Trace of which to set the UUID to \bt_p{uuid}.
547@param[in] uuid
548 New UUID of \bt_p{trace} (copied).
549
550@bt_pre_not_null{trace}
551@bt_pre_hot{trace}
552@bt_pre_trace_with_mip{trace, 0}
553@bt_pre_not_null{uuid}
554
555@sa bt_trace_get_uuid() &mdash;
556 Returns the UUID of a trace.
557*/
558extern void bt_trace_set_uuid(bt_trace *trace, bt_uuid uuid) __BT_NOEXCEPT;
559
560/*!
561@brief
562 Status codes for bt_trace_set_uid().
563*/
564typedef enum bt_trace_set_uid_status {
565 /*!
566 @brief
567 Success.
568 */
569 BT_TRACE_SET_UID_STATUS_OK = __BT_FUNC_STATUS_OK,
570
571 /*!
572 @brief
573 Out of memory.
574 */
575 BT_TRACE_SET_UID_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
576} bt_trace_set_uid_status;
577
578/*!
579@brief
580 Returns the UUID of the trace \bt_p{trace}.
581
582@note
583 @parblock
584 This function is only available when the class of \bt_p{trace} was
585 created from a \bt_comp which belongs to a trace processing
586 \bt_graph with the effective \bt_mip (MIP) version&nbsp;0.
587
588 With MIP&nbsp;1, see the
589 \ref api-tir-trace-prop-uid "UID" property.
590 @endparblock
591
592See the \ref api-tir-trace-prop-uuid "UUID" property.
593
594If \bt_p{trace} has no UUID, this function returns \c NULL.
595
596@param[in] trace
597 Trace of which to get the UUID.
598
599@returns
600 @parblock
601 UUID of \bt_p{trace}, or \c NULL if none.
602
603 The returned pointer remains valid as long as \bt_p{trace}
604 is not modified.
605 @endparblock
606
607@bt_pre_not_null{trace}
608@bt_pre_trace_with_mip{trace, 0}
609
610@sa bt_trace_set_uuid() &mdash;
611 Sets the UUID of a trace.
612*/
613extern bt_uuid bt_trace_get_uuid(const bt_trace *trace) __BT_NOEXCEPT;
614
615/*!
616@brief
617 Sets the
618 <a href="https://en.wikipedia.org/wiki/Unique_identifier">unique identifier</a>
619 (UID) of \bt_p{trace} to a copy of \bt_p{uid}.
620
621See the \ref api-tir-trace-prop-uid "UID" property.
622
623@param[in] trace
624 Trace of which to set the UID to \bt_p{uid}.
625@param[in] uid
626 New UID of \bt_p{trace} (copied).
627
628@bt_pre_not_null{trace}
629@bt_pre_hot{trace}
630@bt_pre_trace_with_mip{trace, 1}
631@bt_pre_not_null{uid}
632
633@sa bt_trace_get_uid() &mdash;
634 Returns the UID of a trace.
635*/
636extern bt_trace_set_uid_status bt_trace_set_uid(bt_trace *trace, const char *uid);
637
638/*!
639@brief
640 Returns the UID of the trace \bt_p{trace}.
641
642See the \ref api-tir-trace-prop-uid "UID" property.
643
644If \bt_p{trace} has no UID, this function returns \c NULL.
645
646@param[in] trace
647 Trace of which to get the UID.
648
649@returns
650 @parblock
651 UID of \bt_p{trace}, or \c NULL if none.
652
653 The returned pointer remains valid as long as \bt_p{trace}
654 is not modified.
655 @endparblock
656
657@bt_pre_not_null{trace}
658@bt_pre_trace_with_mip{trace, 1}
659
660@sa bt_trace_set_uid() &mdash;
661 Sets the UID of a trace.
662*/
663extern const char *bt_trace_get_uid(const bt_trace *trace);
664
665/*!
666@brief
667 Status codes for bt_trace_set_name().
668*/
669typedef enum bt_trace_set_environment_entry_status {
670 /*!
671 @brief
672 Success.
673 */
674 BT_TRACE_SET_ENVIRONMENT_ENTRY_STATUS_OK = __BT_FUNC_STATUS_OK,
675
676 /*!
677 @brief
678 Out of memory.
679 */
680 BT_TRACE_SET_ENVIRONMENT_ENTRY_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
681} bt_trace_set_environment_entry_status;
682
683/*!
684@brief
685 Sets the value of the environment entry of the trace \bt_p{trace}
686 named \bt_p{name} to the signed integer \bt_p{value}.
687
688See the \ref api-tir-trace-prop-env "environment" property.
689
690On success, if \bt_p{trace} already contains an environment entry named
691\bt_p{name}, this function replaces the existing entry's value with
692\bt_p{value}.
693
694@param[in] trace
695 Trace in which to insert or replace an environment entry named
696 \bt_p{name} with the value \bt_p{value}.
697@param[in] name
698 Name of the entry to insert or replace in \bt_p{trace} (copied).
699@param[in] value
700 Value of the environment entry to insert or replace in \bt_p{trace}.
701
702@retval #BT_TRACE_SET_ENVIRONMENT_ENTRY_STATUS_OK
703 Success.
704@retval #BT_TRACE_SET_ENVIRONMENT_ENTRY_STATUS_MEMORY_ERROR
705 Out of memory.
706
707@bt_pre_not_null{trace}
708@bt_pre_hot{trace}
709@bt_pre_not_null{name}
710
711@sa bt_trace_set_environment_entry_string() &mdash;
712 Sets a trace environment entry's value to a string.
713*/
714extern bt_trace_set_environment_entry_status
715bt_trace_set_environment_entry_integer(bt_trace *trace, const char *name,
716 int64_t value) __BT_NOEXCEPT;
717
718/*!
719@brief
720 Sets the value of the environment entry of the trace \bt_p{trace}
721 named \bt_p{name} to the string \bt_p{value}.
722
723See the \ref api-tir-trace-prop-env "environment" property.
724
725On success, if \bt_p{trace} already contains an environment entry named
726\bt_p{name}, this function replaces the existing entry's value with
727\bt_p{value}.
728
729@param[in] trace
730 Trace in which to insert or replace an environment entry named
731 \bt_p{name} with the value \bt_p{value}.
732@param[in] name
733 Name of the entry to insert or replace in \bt_p{trace} (copied).
734@param[in] value
735 Value of the environment entry to insert or replace in \bt_p{trace}.
736
737@retval #BT_TRACE_SET_ENVIRONMENT_ENTRY_STATUS_OK
738 Success.
739@retval #BT_TRACE_SET_ENVIRONMENT_ENTRY_STATUS_MEMORY_ERROR
740 Out of memory.
741
742@bt_pre_not_null{trace}
743@bt_pre_hot{trace}
744@bt_pre_not_null{name}
745@bt_pre_not_null{value}
746
747@sa bt_trace_set_environment_entry_integer() &mdash;
748 Sets a trace environment entry's value to a signed integer.
749*/
750extern bt_trace_set_environment_entry_status
751bt_trace_set_environment_entry_string(bt_trace *trace, const char *name,
752 const char *value) __BT_NOEXCEPT;
753
754/*!
755@brief
756 Returns the number of environment entries contained in the trace
757 \bt_p{trace}.
758
759See the \ref api-tir-trace-prop-env "environment" property.
760
761@param[in] trace
762 Trace of which to get the number of environment entries.
763
764@returns
765 Number of environment entries in \bt_p{trace}.
766
767@bt_pre_not_null{trace}
768*/
769extern uint64_t bt_trace_get_environment_entry_count(
770 const bt_trace *trace) __BT_NOEXCEPT;
771
772/*!
773@brief
774 Borrows the environment entry at index \bt_p{index} from the
775 trace \bt_p{trace}, setting \bt_p{*name} to its name and
776 \bt_p{*value} to its value.
777
778See the \ref api-tir-trace-prop-env "environment" property.
779
780@param[in] trace
781 Trace from which to borrow the environment entry at index
782 \bt_p{index}.
783@param[in] index
784 Index of the environment entry to borrow from \bt_p{trace}.
785@param[in] name
786 @parblock
787 <strong>On success</strong>, \bt_p{*name} is the name of the
788 environment entry at index \bt_p{index} in \bt_p{trace}.
789
790 The returned pointer remains valid as long as \bt_p{trace}
791 is not modified.
792 @endparblock
793@param[in] value
794 @parblock
795 <strong>On success</strong>, \bt_p{*value} is a \em borrowed
796 reference of the environment entry at index \bt_p{index} in
797 \bt_p{trace}.
798
799 \bt_p{*value} is either a \bt_sint_val
800 (#BT_VALUE_TYPE_SIGNED_INTEGER) or a \bt_string_val
801 (#BT_VALUE_TYPE_STRING).
802
803 The returned pointer remains valid as long as \bt_p{trace}
804 is not modified.
805 @endparblock
806
807@bt_pre_not_null{trace}
808@pre
809 \bt_p{index} is less than the number of environment entries in
810 \bt_p{trace} (as returned by
811 bt_trace_get_environment_entry_count()).
812@bt_pre_not_null{name}
813@bt_pre_not_null{value}
814
815@sa bt_trace_get_environment_entry_count() &mdash;
816 Returns the number of environment entries contained in a trace.
817*/
818extern void bt_trace_borrow_environment_entry_by_index_const(
819 const bt_trace *trace, uint64_t index,
820 const char **name, const bt_value **value) __BT_NOEXCEPT;
821
822/*!
823@brief
824 Borrows the value of the environment entry named \bt_p{name}
825 in the trace \bt_p{trace}.
826
827See the \ref api-tir-trace-prop-env "environment" property.
828
829If there's no environment entry named \bt_p{name} in \bt_p{trace}, this
830function returns \c NULL.
831
832@param[in] trace
833 Trace from which to borrow the value of the environment entry
834 named \bt_p{name}.
835@param[in] name
836 Name of the environment entry to borrow from \bt_p{trace}.
837
838@returns
839 @parblock
840 \em Borrowed reference of the value of the environment entry named
841 \bt_p{name} in \bt_p{trace}.
842
843 The returned value is either a \bt_sint_val
844 (#BT_VALUE_TYPE_SIGNED_INTEGER) or a \bt_string_val
845 (#BT_VALUE_TYPE_STRING).
846
847 The returned pointer remains valid as long as \bt_p{trace}
848 is not modified.
849 @endparblock
850
851@bt_pre_not_null{trace}
852@bt_pre_not_null{name}
853*/
854extern const bt_value *bt_trace_borrow_environment_entry_value_by_name_const(
855 const bt_trace *trace, const char *name) __BT_NOEXCEPT;
856
857/*!
858@brief
859 Sets the user attributes of the trace \bt_p{trace} to
860 \bt_p{user_attributes}.
861
862See the \ref api-tir-trace-prop-user-attrs "user attributes"
863property.
864
865@note
866 When you create a default trace with bt_trace_create(), the trace's
867 initial user attributes is an empty \bt_map_val. Therefore you can
868 borrow it with bt_trace_borrow_user_attributes() and fill it
869 directly instead of setting a new one with this function.
870
871@param[in] trace
872 Trace of which to set the user attributes to \bt_p{user_attributes}.
873@param[in] user_attributes
874 New user attributes of \bt_p{trace}.
875
876@bt_pre_not_null{trace}
877@bt_pre_hot{trace}
878@bt_pre_not_null{user_attributes}
879@bt_pre_is_map_val{user_attributes}
880
881@sa bt_trace_borrow_user_attributes() &mdash;
882 Borrows the user attributes of a trace.
883*/
884extern void bt_trace_set_user_attributes(
885 bt_trace *trace, const bt_value *user_attributes) __BT_NOEXCEPT;
886
887/*!
888@brief
889 Borrows the user attributes of the trace \bt_p{trace}.
890
891See the \ref api-tir-trace-prop-user-attrs "user attributes"
892property.
893
894@note
895 When you create a default trace with bt_trace_create(), the trace's
896 initial user attributes is an empty \bt_map_val.
897
898@param[in] trace
899 Trace from which to borrow the user attributes.
900
901@returns
902 User attributes of \bt_p{trace} (a \bt_map_val).
903
904@bt_pre_not_null{trace}
905
906@sa bt_trace_set_user_attributes() &mdash;
907 Sets the user attributes of a trace.
908@sa bt_trace_borrow_user_attributes_const() &mdash;
909 \c const version of this function.
910*/
911extern bt_value *bt_trace_borrow_user_attributes(bt_trace *trace) __BT_NOEXCEPT;
912
913/*!
914@brief
915 Borrows the user attributes of the trace \bt_p{trace}
916 (\c const version).
917
918See bt_trace_borrow_user_attributes().
919*/
920extern const bt_value *bt_trace_borrow_user_attributes_const(
921 const bt_trace *trace) __BT_NOEXCEPT;
922
923/*! @} */
924
925/*!
926@name Listeners
927@{
928*/
929
930/*!
931@brief
932 User function for bt_trace_add_destruction_listener().
933
934This is the user function type for a trace destruction listener.
935
936@param[in] trace
937 Trace being destroyed (\ref api-fund-freezing "frozen").
938@param[in] user_data
939 User data, as passed as the \bt_p{user_data} parameter of
940 bt_trace_add_destruction_listener().
941
942@bt_pre_not_null{trace}
943
944@post
945 The reference count of \bt_p{trace} is not changed.
946@bt_post_no_error
947
948@sa bt_trace_add_destruction_listener() &mdash;
949 Adds a destruction listener to a trace.
950*/
951typedef void (* bt_trace_destruction_listener_func)(
952 const bt_trace *trace, void *user_data);
953
954/*!
955@brief
956 Status codes for bt_trace_add_destruction_listener().
957*/
958typedef enum bt_trace_add_listener_status {
959 /*!
960 @brief
961 Success.
962 */
963 BT_TRACE_ADD_LISTENER_STATUS_OK = __BT_FUNC_STATUS_OK,
964
965 /*!
966 @brief
967 Out of memory.
968 */
969 BT_TRACE_ADD_LISTENER_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
970} bt_trace_add_listener_status;
971
972/*!
973@brief
974 Adds a destruction listener having the function \bt_p{user_func}
975 to the trace \bt_p{trace}.
976
977All the destruction listener user functions of a trace are called
978when it's being destroyed.
979
980If \bt_p{listener_id} is not \c NULL, then this function, on success,
981sets \bt_p{*listener_id} to the ID of the added destruction listener
982within \bt_p{trace}. You can then use this ID to remove the
983added destruction listener with bt_trace_remove_destruction_listener().
984
985@param[in] trace
986 Trace to add the destruction listener to.
987@param[in] user_func
988 User function of the destruction listener to add to
989 \bt_p{trace}.
990@param[in] user_data
991 User data to pass as the \bt_p{user_data} parameter of
992 \bt_p{user_func}.
993@param[out] listener_id
994 <strong>On success and if not \c NULL</strong>, \bt_p{*listener_id}
995 is the ID of the added destruction listener within
996 \bt_p{trace}.
997
998@retval #BT_TRACE_ADD_LISTENER_STATUS_OK
999 Success.
1000@retval #BT_TRACE_ADD_LISTENER_STATUS_MEMORY_ERROR
1001 Out of memory.
1002
1003@bt_pre_not_null{trace}
1004@bt_pre_not_null{user_func}
1005
1006@sa bt_trace_remove_destruction_listener() &mdash;
1007 Removes a destruction listener from a trace.
1008*/
1009extern bt_trace_add_listener_status bt_trace_add_destruction_listener(
1010 const bt_trace *trace,
1011 bt_trace_destruction_listener_func user_func,
1012 void *user_data, bt_listener_id *listener_id) __BT_NOEXCEPT;
1013
1014/*!
1015@brief
1016 Status codes for bt_trace_remove_destruction_listener().
1017*/
1018typedef enum bt_trace_remove_listener_status {
1019 /*!
1020 @brief
1021 Success.
1022 */
1023 BT_TRACE_REMOVE_LISTENER_STATUS_OK = __BT_FUNC_STATUS_OK,
1024
1025 /*!
1026 @brief
1027 Out of memory.
1028 */
1029 BT_TRACE_REMOVE_LISTENER_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
1030} bt_trace_remove_listener_status;
1031
1032/*!
1033@brief
1034 Removes the destruction listener having the ID \bt_p{listener_id}
1035 from the trace \bt_p{trace}.
1036
1037The destruction listener to remove from \bt_p{trace} was
1038previously added with bt_trace_add_destruction_listener().
1039
1040You can call this function when \bt_p{trace} is
1041\ref api-fund-freezing "frozen".
1042
1043@param[in] trace
1044 Trace from which to remove the destruction listener having
1045 the ID \bt_p{listener_id}.
1046@param[in] listener_id
1047 ID of the destruction listener to remove from \bt_p{trace}­.
1048
1049@retval #BT_TRACE_REMOVE_LISTENER_STATUS_OK
1050 Success.
1051@retval #BT_TRACE_REMOVE_LISTENER_STATUS_MEMORY_ERROR
1052 Out of memory.
1053
1054@bt_pre_not_null{trace}
1055@pre
1056 \bt_p{listener_id} is the ID of an existing destruction listener
1057 in \bt_p{trace}.
1058
1059@sa bt_trace_add_destruction_listener() &mdash;
1060 Adds a destruction listener to a trace.
1061*/
1062extern bt_trace_remove_listener_status bt_trace_remove_destruction_listener(
1063 const bt_trace *trace, bt_listener_id listener_id)
1064 __BT_NOEXCEPT;
1065
1066/*! @} */
1067
1068/*!
1069@name Reference count
1070@{
1071*/
1072
1073/*!
1074@brief
1075 Increments the \ref api-fund-shared-object "reference count" of
1076 the trace \bt_p{trace}.
1077
1078@param[in] trace
1079 @parblock
1080 Trace of which to increment the reference count.
1081
1082 Can be \c NULL.
1083 @endparblock
1084
1085@sa bt_trace_put_ref() &mdash;
1086 Decrements the reference count of a trace.
1087*/
1088extern void bt_trace_get_ref(const bt_trace *trace) __BT_NOEXCEPT;
1089
1090/*!
1091@brief
1092 Decrements the \ref api-fund-shared-object "reference count" of
1093 the trace \bt_p{trace}.
1094
1095@param[in] trace
1096 @parblock
1097 Trace of which to decrement the reference count.
1098
1099 Can be \c NULL.
1100 @endparblock
1101
1102@sa bt_trace_get_ref() &mdash;
1103 Increments the reference count of a trace.
1104*/
1105extern void bt_trace_put_ref(const bt_trace *trace) __BT_NOEXCEPT;
1106
1107/*!
1108@brief
1109 Decrements the reference count of the trace
1110 \bt_p{_trace}, and then sets \bt_p{_trace} to \c NULL.
1111
1112@param _trace
1113 @parblock
1114 Trace of which to decrement the reference count.
1115
1116 Can contain \c NULL.
1117 @endparblock
1118
1119@bt_pre_assign_expr{_trace}
1120*/
1121#define BT_TRACE_PUT_REF_AND_RESET(_trace) \
1122 do { \
1123 bt_trace_put_ref(_trace); \
1124 (_trace) = NULL; \
1125 } while (0)
1126
1127/*!
1128@brief
1129 Decrements the reference count of the trace \bt_p{_dst}, sets
1130 \bt_p{_dst} to \bt_p{_src}, and then sets \bt_p{_src} to \c NULL.
1131
1132This macro effectively moves a trace reference from the expression
1133\bt_p{_src} to the expression \bt_p{_dst}, putting the existing
1134\bt_p{_dst} reference.
1135
1136@param _dst
1137 @parblock
1138 Destination expression.
1139
1140 Can contain \c NULL.
1141 @endparblock
1142@param _src
1143 @parblock
1144 Source expression.
1145
1146 Can contain \c NULL.
1147 @endparblock
1148
1149@bt_pre_assign_expr{_dst}
1150@bt_pre_assign_expr{_src}
1151*/
1152#define BT_TRACE_MOVE_REF(_dst, _src) \
1153 do { \
1154 bt_trace_put_ref(_dst); \
1155 (_dst) = (_src); \
1156 (_src) = NULL; \
1157 } while (0)
1158
1159/*! @} */
1160
1161/*! @} */
1162
1163#ifdef __cplusplus
1164}
1165#endif
1166
1167#endif /* BABELTRACE2_TRACE_IR_TRACE_H */
This page took 0.02597 seconds and 5 git commands to generate.