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