lib: assign a unique ID to each pre/postcond. and report it on failure
[babeltrace.git] / src / lib / trace-ir / trace.c
CommitLineData
bc37ae52 1/*
0235b0db
MJ
2 * SPDX-License-Identifier: MIT
3 *
e2f7325d 4 * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
bc37ae52 5 * Copyright 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
bc37ae52
JG
6 */
7
350ad6c1 8#define BT_LOG_TAG "LIB/TRACE"
c2d9d9cf 9#include "lib/logging.h"
e011d2c1 10
d98421f2 11#include "lib/assert-cond.h"
3fadfbc0 12#include <babeltrace2/trace-ir/trace.h>
3fadfbc0 13#include <babeltrace2/trace-ir/event-class.h>
578e048b
MJ
14#include "ctf-writer/functor.h"
15#include "ctf-writer/clock.h"
16#include "compat/compiler.h"
3fadfbc0 17#include <babeltrace2/value.h>
578e048b 18#include "lib/value.h"
3fadfbc0 19#include <babeltrace2/types.h>
578e048b
MJ
20#include "compat/endian.h"
21#include "common/assert.h"
22#include "compat/glib.h"
dc3fffef 23#include <inttypes.h>
544d0515 24#include <stdint.h>
4a32fda0 25#include <string.h>
c4f23e30 26#include <stdbool.h>
0fbb9a9f 27#include <stdlib.h>
bc37ae52 28
578e048b
MJ
29#include "attributes.h"
30#include "clock-class.h"
31#include "event-class.h"
32#include "event.h"
33#include "field-class.h"
34#include "field-wrapper.h"
35#include "resolve-field-path.h"
36#include "stream-class.h"
37#include "stream.h"
38#include "trace-class.h"
39#include "trace.h"
40#include "utils.h"
c6962c96 41#include "lib/value.h"
d24d5663 42#include "lib/func-status.h"
578e048b 43
ad5268b5
FD
44struct bt_trace_destruction_listener_elem {
45 bt_trace_destruction_listener_func func;
3602afb0
PP
46 void *data;
47};
48
1778c2a4
PP
49#define BT_ASSERT_PRE_DEV_TRACE_HOT(_trace) \
50 BT_ASSERT_PRE_DEV_HOT("trace", (_trace), "Trace", ": %!+t", (_trace))
51
52#define DESTRUCTION_LISTENER_FUNC_NAME \
53 "bt_trace_class_destruction_listener_func"
cb6f1f7d 54
bc37ae52 55static
44c440bc 56void destroy_trace(struct bt_object *obj)
3dca2276
PP
57{
58 struct bt_trace *trace = (void *) obj;
bc37ae52 59
44c440bc 60 BT_LIB_LOGD("Destroying trace object: %!+t", trace);
c6962c96 61 BT_OBJECT_PUT_REF_AND_RESET(trace->user_attributes);
bc37ae52 62
3dca2276 63 /*
ad5268b5
FD
64 * Call destruction listener functions so that everything else
65 * still exists in the trace.
3dca2276 66 */
ad5268b5
FD
67 if (trace->destruction_listeners) {
68 uint64_t i;
42a63165
SM
69 const struct bt_error *saved_error;
70
3f7d4d90 71 BT_LIB_LOGD("Calling trace destruction listener(s): %!+t", trace);
c47a6bec
SM
72
73 /*
74 * The trace's reference count is 0 if we're here. Increment
75 * it to avoid a double-destroy (possibly infinitely recursive).
76 * This could happen for example if a destruction listener did
77 * bt_object_get_ref() (or anything that causes
78 * bt_object_get_ref() to be called) on the trace (ref.
79 * count goes from 0 to 1), and then bt_object_put_ref(): the
80 * reference count would go from 1 to 0 again and this function
81 * would be called again.
82 */
83 trace->base.ref_count++;
84
42a63165
SM
85 saved_error = bt_current_thread_take_error();
86
ad5268b5
FD
87 /* Call all the trace destruction listeners */
88 for (i = 0; i < trace->destruction_listeners->len; i++) {
89 struct bt_trace_destruction_listener_elem elem =
90 g_array_index(trace->destruction_listeners,
1778c2a4 91 struct bt_trace_destruction_listener_elem, i);
ad5268b5
FD
92
93 if (elem.func) {
94 elem.func(trace, elem.data);
1778c2a4
PP
95 BT_ASSERT_POST_NO_ERROR(
96 DESTRUCTION_LISTENER_FUNC_NAME);
3dca2276 97 }
c47a6bec
SM
98
99 /*
100 * The destruction listener should not have kept a
101 * reference to the trace.
102 */
1778c2a4
PP
103 BT_ASSERT_POST(DESTRUCTION_LISTENER_FUNC_NAME,
104 "trace-reference-count-not-changed",
105 trace->base.ref_count == 1,
106 "Destruction listener kept a reference to the trace being destroyed: %![trace-]+t",
107 trace);
3dca2276 108 }
ad5268b5
FD
109 g_array_free(trace->destruction_listeners, TRUE);
110 trace->destruction_listeners = NULL;
42a63165
SM
111
112 if (saved_error) {
113 BT_CURRENT_THREAD_MOVE_ERROR_AND_RESET(saved_error);
114 }
bc37ae52
JG
115 }
116
44c440bc
PP
117 if (trace->name.str) {
118 g_string_free(trace->name.str, TRUE);
238b7404
PP
119 trace->name.str = NULL;
120 trace->name.value = NULL;
95c09b3a
PP
121 }
122
335a2da5
PP
123 if (trace->environment) {
124 BT_LOGD_STR("Destroying environment attributes.");
125 bt_attributes_destroy(trace->environment);
126 trace->environment = NULL;
127 }
128
44c440bc
PP
129 if (trace->streams) {
130 BT_LOGD_STR("Destroying streams.");
131 g_ptr_array_free(trace->streams, TRUE);
238b7404 132 trace->streams = NULL;
bc37ae52
JG
133 }
134
44c440bc
PP
135 if (trace->stream_classes_stream_count) {
136 g_hash_table_destroy(trace->stream_classes_stream_count);
238b7404 137 trace->stream_classes_stream_count = NULL;
44c440bc 138 }
3dca2276 139
862ca4ed
PP
140 BT_LOGD_STR("Putting trace's class.");
141 bt_object_put_ref(trace->class);
142 trace->class = NULL;
44c440bc 143 g_free(trace);
3dca2276
PP
144}
145
862ca4ed 146struct bt_trace *bt_trace_create(struct bt_trace_class *tc)
3dca2276
PP
147{
148 struct bt_trace *trace = NULL;
3dca2276 149
17f3083a
SM
150 BT_ASSERT_PRE_NO_ERROR();
151
862ca4ed 152 BT_LIB_LOGD("Creating trace object: %![tc-]+T", tc);
3dca2276
PP
153 trace = g_new0(struct bt_trace, 1);
154 if (!trace) {
870631a2 155 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate one trace.");
3dca2276
PP
156 goto error;
157 }
158
862ca4ed 159 bt_object_init_shared(&trace->base, destroy_trace);
c6962c96
PP
160 trace->user_attributes = bt_value_map_create();
161 if (!trace->user_attributes) {
162 BT_LIB_LOGE_APPEND_CAUSE(
163 "Failed to create a map value object.");
164 goto error;
165 }
166
44c440bc
PP
167 trace->streams = g_ptr_array_new_with_free_func(
168 (GDestroyNotify) bt_object_try_spec_release);
169 if (!trace->streams) {
870631a2 170 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate one GPtrArray.");
3dca2276
PP
171 goto error;
172 }
173
44c440bc
PP
174 trace->stream_classes_stream_count = g_hash_table_new(g_direct_hash,
175 g_direct_equal);
176 if (!trace->stream_classes_stream_count) {
870631a2 177 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate one GHashTable.");
44c440bc
PP
178 goto error;
179 }
180
181 trace->name.str = g_string_new(NULL);
182 if (!trace->name.str) {
870631a2 183 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate one GString.");
44c440bc
PP
184 goto error;
185 }
186
335a2da5
PP
187 trace->environment = bt_attributes_create();
188 if (!trace->environment) {
189 BT_LIB_LOGE_APPEND_CAUSE("Cannot create empty attributes object.");
190 goto error;
191 }
192
ad5268b5
FD
193 trace->destruction_listeners = g_array_new(FALSE, TRUE,
194 sizeof(struct bt_trace_destruction_listener_elem));
195 if (!trace->destruction_listeners) {
870631a2 196 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate one GArray.");
3602afb0
PP
197 goto error;
198 }
199
862ca4ed 200 trace->class = tc;
6871026b 201 bt_object_get_ref_no_null_check(trace->class);
44c440bc
PP
202 BT_LIB_LOGD("Created trace object: %!+t", trace);
203 goto end;
bc37ae52 204
bc37ae52 205error:
65300d60 206 BT_OBJECT_PUT_REF_AND_RESET(trace);
44c440bc
PP
207
208end:
862ca4ed 209 return trace;
bc37ae52
JG
210}
211
40f4ba76 212const char *bt_trace_get_name(const struct bt_trace *trace)
e96045d4 213{
d5b13b9b 214 BT_ASSERT_PRE_DEV_TRACE_NON_NULL(trace);
44c440bc 215 return trace->name.value;
e96045d4
JG
216}
217
d24d5663
PP
218enum bt_trace_set_name_status bt_trace_set_name(struct bt_trace *trace,
219 const char *name)
e96045d4 220{
17f3083a 221 BT_ASSERT_PRE_NO_ERROR();
d5b13b9b
PP
222 BT_ASSERT_PRE_TRACE_NON_NULL(trace);
223 BT_ASSERT_PRE_NAME_NON_NULL(name);
bdb288b3 224 BT_ASSERT_PRE_DEV_TRACE_HOT(trace);
44c440bc
PP
225 g_string_assign(trace->name.str, name);
226 trace->name.value = trace->name.str->str;
3f7d4d90 227 BT_LIB_LOGD("Set trace's name: %!+t", trace);
d24d5663 228 return BT_FUNC_STATUS_OK;
e96045d4
JG
229}
230
335a2da5
PP
231bt_uuid bt_trace_get_uuid(const struct bt_trace *trace)
232{
d5b13b9b 233 BT_ASSERT_PRE_DEV_TRACE_NON_NULL(trace);
335a2da5
PP
234 return trace->uuid.value;
235}
236
237void bt_trace_set_uuid(struct bt_trace *trace, bt_uuid uuid)
238{
d5b13b9b
PP
239 BT_ASSERT_PRE_TRACE_NON_NULL(trace);
240 BT_ASSERT_PRE_UUID_NON_NULL(uuid);
bdb288b3 241 BT_ASSERT_PRE_DEV_TRACE_HOT(trace);
6162e6b7 242 bt_uuid_copy(trace->uuid.uuid, uuid);
335a2da5
PP
243 trace->uuid.value = trace->uuid.uuid;
244 BT_LIB_LOGD("Set trace's UUID: %!+t", trace);
245}
246
335a2da5
PP
247static
248bool trace_has_environment_entry(const struct bt_trace *trace, const char *name)
249{
250 BT_ASSERT(trace);
251
252 return bt_attributes_borrow_field_value_by_name(
5084732e 253 trace->environment, name);
335a2da5
PP
254}
255
256static
257enum bt_trace_set_environment_entry_status set_environment_entry(
258 struct bt_trace *trace,
259 const char *name, struct bt_value *value)
260{
261 int ret;
262
263 BT_ASSERT(trace);
264 BT_ASSERT(name);
265 BT_ASSERT(value);
1778c2a4
PP
266 BT_ASSERT_PRE("not-frozen:trace",
267 !trace->frozen ||
268 !trace_has_environment_entry(trace, name),
335a2da5
PP
269 "Trace is frozen: cannot replace environment entry: "
270 "%![trace-]+t, entry-name=\"%s\"", trace, name);
271 ret = bt_attributes_set_field_value(trace->environment, name,
272 value);
273 if (ret) {
274 ret = BT_FUNC_STATUS_MEMORY_ERROR;
275 BT_LIB_LOGE_APPEND_CAUSE(
276 "Cannot set trace's environment entry: "
277 "%![trace-]+t, entry-name=\"%s\"", trace, name);
278 } else {
279 bt_value_freeze(value);
280 BT_LIB_LOGD("Set trace's environment entry: "
281 "%![trace-]+t, entry-name=\"%s\"", trace, name);
282 }
283
284 return ret;
285}
286
287enum bt_trace_set_environment_entry_status
288bt_trace_set_environment_entry_string(
289 struct bt_trace *trace, const char *name, const char *value)
290{
291 int ret;
292 struct bt_value *value_obj;
17f3083a
SM
293
294 BT_ASSERT_PRE_NO_ERROR();
d5b13b9b
PP
295 BT_ASSERT_PRE_TRACE_NON_NULL(trace);
296 BT_ASSERT_PRE_NAME_NON_NULL(name);
1778c2a4 297 BT_ASSERT_PRE_NON_NULL("value", value, "Value");
17f3083a 298
335a2da5
PP
299 value_obj = bt_value_string_create_init(value);
300 if (!value_obj) {
301 BT_LIB_LOGE_APPEND_CAUSE(
302 "Cannot create a string value object.");
303 ret = -1;
304 goto end;
305 }
306
307 /* set_environment_entry() logs errors */
308 ret = set_environment_entry(trace, name, value_obj);
309
310end:
311 bt_object_put_ref(value_obj);
312 return ret;
313}
314
315enum bt_trace_set_environment_entry_status
316bt_trace_set_environment_entry_integer(
317 struct bt_trace *trace, const char *name, int64_t value)
318{
319 int ret;
320 struct bt_value *value_obj;
17f3083a
SM
321
322 BT_ASSERT_PRE_NO_ERROR();
d5b13b9b
PP
323 BT_ASSERT_PRE_TRACE_NON_NULL(trace);
324 BT_ASSERT_PRE_NAME_NON_NULL(name);
17f3083a 325
9c08c816 326 value_obj = bt_value_integer_signed_create_init(value);
335a2da5
PP
327 if (!value_obj) {
328 BT_LIB_LOGE_APPEND_CAUSE(
329 "Cannot create an integer value object.");
330 ret = BT_FUNC_STATUS_MEMORY_ERROR;
331 goto end;
332 }
333
334 /* set_environment_entry() logs errors */
335 ret = set_environment_entry(trace, name, value_obj);
336
337end:
338 bt_object_put_ref(value_obj);
339 return ret;
340}
341
342uint64_t bt_trace_get_environment_entry_count(const struct bt_trace *trace)
343{
d5b13b9b 344 BT_ASSERT_PRE_DEV_TRACE_NON_NULL(trace);
99b4b64b 345 return bt_attributes_get_count(trace->environment);
335a2da5
PP
346}
347
348void bt_trace_borrow_environment_entry_by_index_const(
349 const struct bt_trace *trace, uint64_t index,
350 const char **name, const struct bt_value **value)
351{
d5b13b9b
PP
352 BT_ASSERT_PRE_DEV_TRACE_NON_NULL(trace);
353 BT_ASSERT_PRE_DEV_NAME_NON_NULL(name);
1778c2a4
PP
354 BT_ASSERT_PRE_DEV_NON_NULL("value-object-output", value,
355 "Value object (output)");
bdb288b3 356 BT_ASSERT_PRE_DEV_VALID_INDEX(index,
335a2da5
PP
357 bt_attributes_get_count(trace->environment));
358 *value = bt_attributes_borrow_field_value(trace->environment, index);
359 BT_ASSERT(*value);
360 *name = bt_attributes_get_field_name(trace->environment, index);
361 BT_ASSERT(*name);
362}
363
364const struct bt_value *bt_trace_borrow_environment_entry_value_by_name_const(
365 const struct bt_trace *trace, const char *name)
366{
d5b13b9b
PP
367 BT_ASSERT_PRE_DEV_TRACE_NON_NULL(trace);
368 BT_ASSERT_PRE_DEV_NAME_NON_NULL(name);
335a2da5
PP
369 return bt_attributes_borrow_field_value_by_name(trace->environment,
370 name);
371}
372
40f4ba76 373uint64_t bt_trace_get_stream_count(const struct bt_trace *trace)
bc37ae52 374{
d5b13b9b 375 BT_ASSERT_PRE_DEV_TRACE_NON_NULL(trace);
44c440bc
PP
376 return (uint64_t) trace->streams->len;
377}
95c09b3a 378
44c440bc
PP
379struct bt_stream *bt_trace_borrow_stream_by_index(
380 struct bt_trace *trace, uint64_t index)
381{
d5b13b9b 382 BT_ASSERT_PRE_DEV_TRACE_NON_NULL(trace);
bdb288b3 383 BT_ASSERT_PRE_DEV_VALID_INDEX(index, trace->streams->len);
44c440bc
PP
384 return g_ptr_array_index(trace->streams, index);
385}
cb6f1f7d 386
40f4ba76
PP
387const struct bt_stream *bt_trace_borrow_stream_by_index_const(
388 const struct bt_trace *trace, uint64_t index)
e5be10ef 389{
40f4ba76 390 return bt_trace_borrow_stream_by_index((void *) trace, index);
e5be10ef
PP
391}
392
40f4ba76
PP
393struct bt_stream *bt_trace_borrow_stream_by_id(struct bt_trace *trace,
394 uint64_t id)
44c440bc
PP
395{
396 struct bt_stream *stream = NULL;
397 uint64_t i;
bc37ae52 398
d5b13b9b 399 BT_ASSERT_PRE_DEV_TRACE_NON_NULL(trace);
bc37ae52 400
44c440bc
PP
401 for (i = 0; i < trace->streams->len; i++) {
402 struct bt_stream *stream_candidate =
403 g_ptr_array_index(trace->streams, i);
cfeb617e 404
44c440bc
PP
405 if (stream_candidate->id == id) {
406 stream = stream_candidate;
407 goto end;
408 }
6474e016 409 }
95c09b3a 410
bc37ae52 411end:
44c440bc 412 return stream;
bc37ae52
JG
413}
414
40f4ba76
PP
415const struct bt_stream *bt_trace_borrow_stream_by_id_const(
416 const struct bt_trace *trace, uint64_t id)
e5be10ef 417{
40f4ba76 418 return bt_trace_borrow_stream_by_id((void *) trace, id);
e5be10ef
PP
419}
420
d24d5663 421enum bt_trace_add_listener_status bt_trace_add_destruction_listener(
40f4ba76 422 const struct bt_trace *c_trace,
ad5268b5 423 bt_trace_destruction_listener_func listener,
2054a0d1 424 void *data, bt_listener_id *listener_id)
3602afb0 425{
40f4ba76 426 struct bt_trace *trace = (void *) c_trace;
44c440bc 427 uint64_t i;
ad5268b5 428 struct bt_trace_destruction_listener_elem new_elem = {
3602afb0
PP
429 .func = listener,
430 .data = data,
431 };
432
17f3083a 433 BT_ASSERT_PRE_NO_ERROR();
d5b13b9b
PP
434 BT_ASSERT_PRE_TRACE_NON_NULL(trace);
435 BT_ASSERT_PRE_LISTENER_FUNC_NON_NULL(listener);
8480c8cc 436
3602afb0 437 /* Find the next available spot */
ad5268b5
FD
438 for (i = 0; i < trace->destruction_listeners->len; i++) {
439 struct bt_trace_destruction_listener_elem elem =
440 g_array_index(trace->destruction_listeners,
441 struct bt_trace_destruction_listener_elem, i);
3602afb0
PP
442
443 if (!elem.func) {
444 break;
445 }
446 }
447
ad5268b5
FD
448 if (i == trace->destruction_listeners->len) {
449 g_array_append_val(trace->destruction_listeners, new_elem);
3602afb0 450 } else {
ad5268b5 451 g_array_insert_val(trace->destruction_listeners, i, new_elem);
3602afb0
PP
452 }
453
44c440bc
PP
454 if (listener_id) {
455 *listener_id = i;
456 }
3602afb0 457
3f7d4d90 458 BT_LIB_LOGD("Added destruction listener: " "%![trace-]+t, "
ad5268b5 459 "listener-id=%" PRIu64, trace, i);
d24d5663 460 return BT_FUNC_STATUS_OK;
44c440bc
PP
461}
462
44c440bc 463static
40f4ba76 464bool has_listener_id(const struct bt_trace *trace, uint64_t listener_id)
44c440bc 465{
ad5268b5
FD
466 BT_ASSERT(listener_id < trace->destruction_listeners->len);
467 return (&g_array_index(trace->destruction_listeners,
468 struct bt_trace_destruction_listener_elem,
5084732e 469 listener_id))->func;
3602afb0
PP
470}
471
d24d5663 472enum bt_trace_remove_listener_status bt_trace_remove_destruction_listener(
2054a0d1 473 const struct bt_trace *c_trace, bt_listener_id listener_id)
3602afb0 474{
40f4ba76 475 struct bt_trace *trace = (void *) c_trace;
ad5268b5 476 struct bt_trace_destruction_listener_elem *elem;
3602afb0 477
17f3083a 478 BT_ASSERT_PRE_NO_ERROR();
d5b13b9b 479 BT_ASSERT_PRE_TRACE_NON_NULL(trace);
1778c2a4
PP
480 BT_ASSERT_PRE("listener-id-exists",
481 has_listener_id(trace, listener_id),
ad5268b5 482 "Trace has no such trace destruction listener ID: "
44c440bc 483 "%![trace-]+t, %" PRIu64, trace, listener_id);
ad5268b5
FD
484 elem = &g_array_index(trace->destruction_listeners,
485 struct bt_trace_destruction_listener_elem,
3602afb0 486 listener_id);
44c440bc 487 BT_ASSERT(elem->func);
3602afb0
PP
488
489 elem->func = NULL;
490 elem->data = NULL;
3f7d4d90 491 BT_LIB_LOGD("Removed \"trace destruction listener: "
44c440bc
PP
492 "%![trace-]+t, listener-id=%" PRIu64,
493 trace, listener_id);
d24d5663 494 return BT_FUNC_STATUS_OK;
44c440bc 495}
3602afb0 496
44c440bc 497BT_HIDDEN
40f4ba76 498void _bt_trace_freeze(const struct bt_trace *trace)
44c440bc 499{
44c440bc 500 BT_ASSERT(trace);
862ca4ed
PP
501 BT_LIB_LOGD("Freezing trace's class: %!+T", trace->class);
502 bt_trace_class_freeze(trace->class);
c6962c96
PP
503 BT_LIB_LOGD("Freezing trace's user attributes: %!+v",
504 trace->user_attributes);
505 bt_value_freeze(trace->user_attributes);
44c440bc 506 BT_LIB_LOGD("Freezing trace: %!+t", trace);
40f4ba76 507 ((struct bt_trace *) trace)->frozen = true;
5acf2ae6 508}
312c056a 509
44c440bc
PP
510BT_HIDDEN
511void bt_trace_add_stream(struct bt_trace *trace, struct bt_stream *stream)
512{
513 guint count = 0;
514
515 bt_object_set_parent(&stream->base, &trace->base);
516 g_ptr_array_add(trace->streams, stream);
cb6f1f7d 517 bt_trace_freeze(trace);
312c056a 518
44c440bc
PP
519 if (bt_g_hash_table_contains(trace->stream_classes_stream_count,
520 stream->class)) {
521 count = GPOINTER_TO_UINT(g_hash_table_lookup(
522 trace->stream_classes_stream_count, stream->class));
312c056a
PP
523 }
524
44c440bc
PP
525 g_hash_table_insert(trace->stream_classes_stream_count,
526 stream->class, GUINT_TO_POINTER(count + 1));
527}
528
529BT_HIDDEN
40f4ba76
PP
530uint64_t bt_trace_get_automatic_stream_id(const struct bt_trace *trace,
531 const struct bt_stream_class *stream_class)
44c440bc
PP
532{
533 gpointer orig_key;
534 gpointer value;
535 uint64_t id = 0;
536
537 BT_ASSERT(stream_class);
538 BT_ASSERT(trace);
539 if (g_hash_table_lookup_extended(trace->stream_classes_stream_count,
540 stream_class, &orig_key, &value)) {
541 id = (uint64_t) GPOINTER_TO_UINT(value);
542 }
543
544 return id;
312c056a 545}
862ca4ed
PP
546
547struct bt_trace_class *bt_trace_borrow_class(struct bt_trace *trace)
548{
d5b13b9b 549 BT_ASSERT_PRE_DEV_TRACE_NON_NULL(trace);
862ca4ed
PP
550 return trace->class;
551}
552
553const struct bt_trace_class *bt_trace_borrow_class_const(
554 const struct bt_trace *trace)
555{
556 return bt_trace_borrow_class((void *) trace);
557}
c5b9b441 558
c6962c96
PP
559const struct bt_value *bt_trace_borrow_user_attributes_const(
560 const struct bt_trace *trace)
561{
d5b13b9b 562 BT_ASSERT_PRE_DEV_TRACE_NON_NULL(trace);
c6962c96
PP
563 return trace->user_attributes;
564}
565
566struct bt_value *bt_trace_borrow_user_attributes(struct bt_trace *trace)
567{
568 return (void *) bt_trace_borrow_user_attributes_const((void *) trace);
569}
570
571void bt_trace_set_user_attributes(
572 struct bt_trace *trace,
573 const struct bt_value *user_attributes)
574{
d5b13b9b
PP
575 BT_ASSERT_PRE_TRACE_NON_NULL(trace);
576 BT_ASSERT_PRE_USER_ATTRS_NON_NULL(user_attributes);
577 BT_ASSERT_PRE_USER_ATTRS_IS_MAP(user_attributes);
c6962c96 578 BT_ASSERT_PRE_DEV_TRACE_HOT(trace);
6871026b 579 bt_object_put_ref_no_null_check(trace->user_attributes);
c6962c96 580 trace->user_attributes = (void *) user_attributes;
6871026b 581 bt_object_get_ref_no_null_check(trace->user_attributes);
c6962c96
PP
582}
583
c5b9b441
PP
584void bt_trace_get_ref(const struct bt_trace *trace)
585{
586 bt_object_get_ref(trace);
587}
588
589void bt_trace_put_ref(const struct bt_trace *trace)
590{
591 bt_object_put_ref(trace);
592}
This page took 0.12862 seconds and 4 git commands to generate.