| 1 | /* |
| 2 | * SPDX-License-Identifier: MIT |
| 3 | * |
| 4 | * Copyright 2018 Philippe Proulx <pproulx@efficios.com> |
| 5 | */ |
| 6 | |
| 7 | #define BT_LOG_TAG "LIB/LIB-LOGGING" |
| 8 | #include "lib/logging.h" |
| 9 | |
| 10 | #include <stdarg.h> |
| 11 | #include <stdio.h> |
| 12 | #include <stdlib.h> |
| 13 | #include <string.h> |
| 14 | #include <inttypes.h> |
| 15 | #include <stdbool.h> |
| 16 | #include <stdint.h> |
| 17 | #include <wchar.h> |
| 18 | #include <glib.h> |
| 19 | #include "common/common.h" |
| 20 | #include "common/uuid.h" |
| 21 | #include <babeltrace2/babeltrace.h> |
| 22 | |
| 23 | #include "logging.h" |
| 24 | #include "assert-cond.h" |
| 25 | #include "value.h" |
| 26 | #include "integer-range-set.h" |
| 27 | #include "object-pool.h" |
| 28 | #include "graph/interrupter.h" |
| 29 | #include "graph/component-class.h" |
| 30 | #include "graph/component-filter.h" |
| 31 | #include "graph/component.h" |
| 32 | #include "graph/component-sink.h" |
| 33 | #include "graph/component-source.h" |
| 34 | #include "graph/connection.h" |
| 35 | #include "graph/graph.h" |
| 36 | #include "graph/message/discarded-items.h" |
| 37 | #include "graph/message/event.h" |
| 38 | #include "graph/message/iterator.h" |
| 39 | #include "graph/message/message.h" |
| 40 | #include "graph/message/message-iterator-inactivity.h" |
| 41 | #include "graph/message/packet.h" |
| 42 | #include "graph/message/stream.h" |
| 43 | #include "graph/port.h" |
| 44 | #include "plugin/plugin.h" |
| 45 | #include "plugin/plugin-so.h" |
| 46 | #include "trace-ir/clock-class.h" |
| 47 | #include "trace-ir/clock-snapshot.h" |
| 48 | #include "trace-ir/event-class.h" |
| 49 | #include "trace-ir/event.h" |
| 50 | #include "trace-ir/field-class.h" |
| 51 | #include "trace-ir/field.h" |
| 52 | #include "trace-ir/field-path.h" |
| 53 | #include "trace-ir/packet.h" |
| 54 | #include "trace-ir/stream-class.h" |
| 55 | #include "trace-ir/stream.h" |
| 56 | #include "trace-ir/trace-class.h" |
| 57 | #include "trace-ir/trace.h" |
| 58 | #include "trace-ir/utils.h" |
| 59 | #include "error.h" |
| 60 | |
| 61 | #define LIB_LOGGING_BUF_SIZE (4096 * 4) |
| 62 | |
| 63 | static __thread char lib_logging_buf[LIB_LOGGING_BUF_SIZE]; |
| 64 | |
| 65 | #define BUF_APPEND(_fmt, ...) \ |
| 66 | do { \ |
| 67 | int _count; \ |
| 68 | size_t _size = LIB_LOGGING_BUF_SIZE - \ |
| 69 | (size_t) (*buf_ch - lib_logging_buf); \ |
| 70 | _count = snprintf(*buf_ch, _size, (_fmt), __VA_ARGS__); \ |
| 71 | BT_ASSERT(_count >= 0); \ |
| 72 | *buf_ch += MIN(_count, _size); \ |
| 73 | if (*buf_ch >= lib_logging_buf + LIB_LOGGING_BUF_SIZE - 1) { \ |
| 74 | return; \ |
| 75 | } \ |
| 76 | } while (0) |
| 77 | |
| 78 | #define BUF_APPEND_UUID(_uuid) \ |
| 79 | do { \ |
| 80 | BUF_APPEND(", %suuid=", prefix); \ |
| 81 | format_uuid(buf_ch, (_uuid)); \ |
| 82 | } while (0) |
| 83 | |
| 84 | #define PRFIELD(_expr) prefix, (_expr) |
| 85 | |
| 86 | #define PRFIELD_GSTRING(_expr) PRFIELD((_expr) ? (_expr)->str : NULL) |
| 87 | |
| 88 | #define TMP_PREFIX_LEN 128 |
| 89 | #define SET_TMP_PREFIX(_prefix2) \ |
| 90 | do { \ |
| 91 | int snprintf_ret = \ |
| 92 | snprintf(tmp_prefix, TMP_PREFIX_LEN - 1, "%s%s", \ |
| 93 | prefix, (_prefix2)); \ |
| 94 | \ |
| 95 | if (snprintf_ret < 0 || snprintf_ret >= TMP_PREFIX_LEN - 1) { \ |
| 96 | bt_common_abort(); \ |
| 97 | } \ |
| 98 | \ |
| 99 | tmp_prefix[TMP_PREFIX_LEN - 1] = '\0'; \ |
| 100 | } while (0) |
| 101 | |
| 102 | static inline void format_component(char **buf_ch, bool extended, |
| 103 | const char *prefix, const struct bt_component *component); |
| 104 | |
| 105 | static inline void format_port(char **buf_ch, bool extended, |
| 106 | const char *prefix, const struct bt_port *port); |
| 107 | |
| 108 | static inline void format_connection(char **buf_ch, bool extended, |
| 109 | const char *prefix, const struct bt_connection *connection); |
| 110 | |
| 111 | static inline void format_clock_snapshot(char **buf_ch, bool extended, |
| 112 | const char *prefix, const struct bt_clock_snapshot *clock_snapshot); |
| 113 | |
| 114 | static inline void format_field_path(char **buf_ch, bool extended, |
| 115 | const char *prefix, const struct bt_field_path *field_path); |
| 116 | |
| 117 | static inline void format_object(char **buf_ch, bool extended, |
| 118 | const char *prefix, const struct bt_object *obj) |
| 119 | { |
| 120 | BUF_APPEND(", %sref-count=%llu", prefix, obj->ref_count); |
| 121 | } |
| 122 | |
| 123 | static inline void format_uuid(char **buf_ch, bt_uuid uuid) |
| 124 | { |
| 125 | BUF_APPEND("\"" BT_UUID_FMT "\"", BT_UUID_FMT_VALUES(uuid)); |
| 126 | } |
| 127 | |
| 128 | static inline void format_object_pool(char **buf_ch, bool extended, |
| 129 | const char *prefix, const struct bt_object_pool *pool) |
| 130 | { |
| 131 | BUF_APPEND(", %ssize=%zu", PRFIELD(pool->size)); |
| 132 | |
| 133 | if (pool->objects) { |
| 134 | BUF_APPEND(", %scap=%u", PRFIELD(pool->objects->len)); |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | static inline void format_integer_field_class(char **buf_ch, |
| 139 | bool extended, const char *prefix, |
| 140 | const struct bt_field_class *field_class) |
| 141 | { |
| 142 | const struct bt_field_class_integer *int_fc = |
| 143 | (const void *) field_class; |
| 144 | |
| 145 | BUF_APPEND(", %srange-size=%" PRIu64 ", %sbase=%s", |
| 146 | PRFIELD(int_fc->range), |
| 147 | PRFIELD(bt_common_field_class_integer_preferred_display_base_string(int_fc->base))); |
| 148 | } |
| 149 | |
| 150 | static inline void format_array_field_class(char **buf_ch, |
| 151 | bool extended, const char *prefix, |
| 152 | const struct bt_field_class *field_class) |
| 153 | { |
| 154 | const struct bt_field_class_array *array_fc = |
| 155 | (const void *) field_class; |
| 156 | |
| 157 | BUF_APPEND(", %selement-fc-addr=%p, %selement-fc-type=%s", |
| 158 | PRFIELD(array_fc->element_fc), |
| 159 | PRFIELD(bt_common_field_class_type_string(array_fc->element_fc->type))); |
| 160 | } |
| 161 | |
| 162 | static inline void format_field_class(char **buf_ch, bool extended, |
| 163 | const char *prefix, const struct bt_field_class *field_class) |
| 164 | { |
| 165 | char tmp_prefix[TMP_PREFIX_LEN]; |
| 166 | |
| 167 | BUF_APPEND(", %stype=%s", |
| 168 | PRFIELD(bt_common_field_class_type_string(field_class->type))); |
| 169 | |
| 170 | if (extended) { |
| 171 | BUF_APPEND(", %sis-frozen=%d", PRFIELD(field_class->frozen)); |
| 172 | BUF_APPEND(", %sis-part-of-trace-class=%d", |
| 173 | PRFIELD(field_class->part_of_trace_class)); |
| 174 | } else { |
| 175 | return; |
| 176 | } |
| 177 | |
| 178 | switch (field_class->type) { |
| 179 | case BT_FIELD_CLASS_TYPE_BIT_ARRAY: |
| 180 | { |
| 181 | const struct bt_field_class_bit_array *ba_fc = |
| 182 | (const void *) field_class; |
| 183 | |
| 184 | BUF_APPEND(", %slength=%" PRIu64, PRFIELD(ba_fc->length)); |
| 185 | break; |
| 186 | } |
| 187 | case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER: |
| 188 | case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER: |
| 189 | { |
| 190 | format_integer_field_class(buf_ch, extended, prefix, field_class); |
| 191 | break; |
| 192 | } |
| 193 | case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION: |
| 194 | case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION: |
| 195 | { |
| 196 | const struct bt_field_class_enumeration *enum_fc = |
| 197 | (const void *) field_class; |
| 198 | |
| 199 | format_integer_field_class(buf_ch, extended, prefix, field_class); |
| 200 | BUF_APPEND(", %smapping-count=%u", |
| 201 | PRFIELD(enum_fc->mappings->len)); |
| 202 | break; |
| 203 | } |
| 204 | case BT_FIELD_CLASS_TYPE_STRUCTURE: |
| 205 | { |
| 206 | const struct bt_field_class_structure *struct_fc = |
| 207 | (const void *) field_class; |
| 208 | |
| 209 | if (struct_fc->common.named_fcs) { |
| 210 | BUF_APPEND(", %smember-count=%u", |
| 211 | PRFIELD(struct_fc->common.named_fcs->len)); |
| 212 | } |
| 213 | |
| 214 | break; |
| 215 | } |
| 216 | case BT_FIELD_CLASS_TYPE_STATIC_ARRAY: |
| 217 | { |
| 218 | const struct bt_field_class_array_static *array_fc = |
| 219 | (const void *) field_class; |
| 220 | |
| 221 | format_array_field_class(buf_ch, extended, prefix, field_class); |
| 222 | BUF_APPEND(", %slength=%" PRIu64, PRFIELD(array_fc->length)); |
| 223 | break; |
| 224 | } |
| 225 | case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD: |
| 226 | case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD: |
| 227 | { |
| 228 | const struct bt_field_class_array_dynamic *array_fc = |
| 229 | (const void *) field_class; |
| 230 | |
| 231 | format_array_field_class(buf_ch, extended, prefix, field_class); |
| 232 | |
| 233 | if (array_fc->length_fc) { |
| 234 | SET_TMP_PREFIX("length-fc-"); |
| 235 | format_field_class(buf_ch, extended, tmp_prefix, |
| 236 | array_fc->length_fc); |
| 237 | } |
| 238 | |
| 239 | if (array_fc->length_field_path) { |
| 240 | SET_TMP_PREFIX("length-field-path-"); |
| 241 | format_field_path(buf_ch, extended, tmp_prefix, |
| 242 | array_fc->length_field_path); |
| 243 | } |
| 244 | |
| 245 | break; |
| 246 | } |
| 247 | case BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD: |
| 248 | case BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD: |
| 249 | case BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD: |
| 250 | case BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD: |
| 251 | { |
| 252 | const struct bt_field_class_option *opt_fc = |
| 253 | (const void *) field_class; |
| 254 | |
| 255 | BUF_APPEND(", %scontent-fc-addr=%p, %scontent-fc-type=%s", |
| 256 | PRFIELD(opt_fc->content_fc), |
| 257 | PRFIELD(bt_common_field_class_type_string(opt_fc->content_fc->type))); |
| 258 | |
| 259 | if (field_class->type != |
| 260 | BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD) { |
| 261 | const struct bt_field_class_option_with_selector_field *opt_with_sel_fc = |
| 262 | (const void *) field_class; |
| 263 | |
| 264 | if (opt_with_sel_fc->selector_fc) { |
| 265 | SET_TMP_PREFIX("selector-fc-"); |
| 266 | format_field_class(buf_ch, extended, tmp_prefix, |
| 267 | opt_with_sel_fc->selector_fc); |
| 268 | } |
| 269 | |
| 270 | if (opt_with_sel_fc->selector_field_path) { |
| 271 | SET_TMP_PREFIX("selector-field-path-"); |
| 272 | format_field_path(buf_ch, extended, tmp_prefix, |
| 273 | opt_with_sel_fc->selector_field_path); |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | break; |
| 278 | } |
| 279 | case BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD: |
| 280 | case BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD: |
| 281 | case BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD: |
| 282 | { |
| 283 | const struct bt_field_class_variant *var_fc = |
| 284 | (const void *) field_class; |
| 285 | |
| 286 | if (var_fc->common.named_fcs) { |
| 287 | BUF_APPEND(", %soption-count=%u", |
| 288 | PRFIELD(var_fc->common.named_fcs->len)); |
| 289 | } |
| 290 | |
| 291 | if (field_class->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || |
| 292 | field_class->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD) { |
| 293 | const struct bt_field_class_variant_with_selector_field *var_with_sel_fc = |
| 294 | (const void *) var_fc; |
| 295 | |
| 296 | if (var_with_sel_fc->selector_fc) { |
| 297 | SET_TMP_PREFIX("selector-fc-"); |
| 298 | format_field_class(buf_ch, extended, tmp_prefix, |
| 299 | var_with_sel_fc->selector_fc); |
| 300 | } |
| 301 | |
| 302 | if (var_with_sel_fc->selector_field_path) { |
| 303 | SET_TMP_PREFIX("selector-field-path-"); |
| 304 | format_field_path(buf_ch, extended, tmp_prefix, |
| 305 | var_with_sel_fc->selector_field_path); |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | break; |
| 310 | } |
| 311 | default: |
| 312 | break; |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | static inline void format_field_integer_extended(char **buf_ch, |
| 317 | const char *prefix, const struct bt_field *field) |
| 318 | { |
| 319 | const struct bt_field_integer *integer = (void *) field; |
| 320 | const struct bt_field_class_integer *field_class = |
| 321 | (void *) field->class; |
| 322 | const char *fmt = NULL; |
| 323 | |
| 324 | BT_ASSERT(field_class); |
| 325 | |
| 326 | if (field_class->base == BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL) { |
| 327 | fmt = ", %svalue=%" PRIo64; |
| 328 | } else if (field_class->base == BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL) { |
| 329 | fmt = ", %svalue=%" PRIx64; |
| 330 | } |
| 331 | |
| 332 | #pragma GCC diagnostic push |
| 333 | #pragma GCC diagnostic ignored "-Wformat-nonliteral" |
| 334 | if (field_class->common.type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || |
| 335 | field_class->common.type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION) { |
| 336 | if (!fmt) { |
| 337 | fmt = ", %svalue=%" PRId64; |
| 338 | } |
| 339 | |
| 340 | BUF_APPEND(fmt, PRFIELD(integer->value.i)); |
| 341 | } else { |
| 342 | if (!fmt) { |
| 343 | fmt = ", %svalue=%" PRIu64; |
| 344 | } |
| 345 | |
| 346 | BUF_APPEND(fmt, PRFIELD(integer->value.u)); |
| 347 | } |
| 348 | #pragma GCC diagnostic pop |
| 349 | } |
| 350 | |
| 351 | static inline void format_field(char **buf_ch, bool extended, |
| 352 | const char *prefix, const struct bt_field *field) |
| 353 | { |
| 354 | BUF_APPEND(", %sis-set=%d", PRFIELD(field->is_set)); |
| 355 | |
| 356 | if (extended) { |
| 357 | BUF_APPEND(", %sis-frozen=%d", PRFIELD(field->frozen)); |
| 358 | } |
| 359 | |
| 360 | BUF_APPEND(", %sclass-addr=%p", PRFIELD(field->class)); |
| 361 | |
| 362 | if (!field->class) { |
| 363 | return; |
| 364 | } |
| 365 | |
| 366 | BUF_APPEND(", %sclass-type=%s", |
| 367 | PRFIELD(bt_common_field_class_type_string(field->class->type))); |
| 368 | |
| 369 | if (!extended || !field->is_set) { |
| 370 | return; |
| 371 | } |
| 372 | |
| 373 | switch (field->class->type) { |
| 374 | case BT_FIELD_CLASS_TYPE_BOOL: |
| 375 | { |
| 376 | const struct bt_field_bool *bool_field = (const void *) field; |
| 377 | |
| 378 | BUF_APPEND(", %svalue=%d", PRFIELD(bool_field->value)); |
| 379 | break; |
| 380 | } |
| 381 | case BT_FIELD_CLASS_TYPE_BIT_ARRAY: |
| 382 | { |
| 383 | const struct bt_field_bit_array *ba_field = (const void *) field; |
| 384 | |
| 385 | BUF_APPEND(", %svalue-as-int=%" PRIx64, |
| 386 | PRFIELD(ba_field->value_as_int)); |
| 387 | break; |
| 388 | } |
| 389 | case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER: |
| 390 | case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER: |
| 391 | case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION: |
| 392 | case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION: |
| 393 | { |
| 394 | format_field_integer_extended(buf_ch, prefix, field); |
| 395 | break; |
| 396 | } |
| 397 | case BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL: |
| 398 | case BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL: |
| 399 | { |
| 400 | const struct bt_field_real *real_field = (const void *) field; |
| 401 | |
| 402 | BUF_APPEND(", %svalue=%f", PRFIELD(real_field->value)); |
| 403 | break; |
| 404 | } |
| 405 | case BT_FIELD_CLASS_TYPE_STRING: |
| 406 | { |
| 407 | const struct bt_field_string *str = (const void *) field; |
| 408 | |
| 409 | if (str->buf) { |
| 410 | BT_ASSERT(str->buf->data); |
| 411 | BUF_APPEND(", %spartial-value=\"%.32s\"", |
| 412 | PRFIELD(str->buf->data)); |
| 413 | } |
| 414 | |
| 415 | break; |
| 416 | } |
| 417 | case BT_FIELD_CLASS_TYPE_STATIC_ARRAY: |
| 418 | case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD: |
| 419 | case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD: |
| 420 | { |
| 421 | const struct bt_field_array *array_field = (const void *) field; |
| 422 | |
| 423 | BUF_APPEND(", %slength=%" PRIu64, PRFIELD(array_field->length)); |
| 424 | |
| 425 | if (array_field->fields) { |
| 426 | BUF_APPEND(", %sallocated-length=%u", |
| 427 | PRFIELD(array_field->fields->len)); |
| 428 | } |
| 429 | |
| 430 | break; |
| 431 | } |
| 432 | case BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD: |
| 433 | case BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD: |
| 434 | case BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD: |
| 435 | { |
| 436 | const struct bt_field_variant *var_field = (const void *) field; |
| 437 | |
| 438 | BUF_APPEND(", %sselected-field-index=%" PRIu64, |
| 439 | PRFIELD(var_field->selected_index)); |
| 440 | break; |
| 441 | } |
| 442 | default: |
| 443 | break; |
| 444 | } |
| 445 | } |
| 446 | |
| 447 | static inline void format_field_path(char **buf_ch, bool extended, |
| 448 | const char *prefix, const struct bt_field_path *field_path) |
| 449 | { |
| 450 | uint64_t i; |
| 451 | |
| 452 | if (field_path->items) { |
| 453 | BT_ASSERT(field_path->items); |
| 454 | BUF_APPEND(", %sitem-count=%u", |
| 455 | PRFIELD(field_path->items->len)); |
| 456 | } |
| 457 | |
| 458 | if (!extended || !field_path->items) { |
| 459 | return; |
| 460 | } |
| 461 | |
| 462 | BUF_APPEND(", %spath=[%s", |
| 463 | PRFIELD(bt_common_scope_string(field_path->root))); |
| 464 | |
| 465 | for (i = 0; i < bt_field_path_get_item_count(field_path); i++) { |
| 466 | const struct bt_field_path_item *fp_item = |
| 467 | bt_field_path_borrow_item_by_index_const(field_path, i); |
| 468 | |
| 469 | switch (bt_field_path_item_get_type(fp_item)) { |
| 470 | case BT_FIELD_PATH_ITEM_TYPE_INDEX: |
| 471 | BUF_APPEND(", %" PRIu64, |
| 472 | bt_field_path_item_index_get_index(fp_item)); |
| 473 | break; |
| 474 | case BT_FIELD_PATH_ITEM_TYPE_CURRENT_ARRAY_ELEMENT: |
| 475 | BUF_APPEND("%s", ", <CUR>"); |
| 476 | break; |
| 477 | default: |
| 478 | bt_common_abort(); |
| 479 | } |
| 480 | } |
| 481 | |
| 482 | BUF_APPEND("%s", "]"); |
| 483 | } |
| 484 | |
| 485 | static inline void format_trace_class(char **buf_ch, bool extended, |
| 486 | const char *prefix, const struct bt_trace_class *trace_class) |
| 487 | { |
| 488 | if (!extended) { |
| 489 | return; |
| 490 | } |
| 491 | |
| 492 | BUF_APPEND(", %sis-frozen=%d", PRFIELD(trace_class->frozen)); |
| 493 | |
| 494 | if (trace_class->stream_classes) { |
| 495 | BUF_APPEND(", %sstream-class-count=%u", |
| 496 | PRFIELD(trace_class->stream_classes->len)); |
| 497 | } |
| 498 | |
| 499 | BUF_APPEND(", %sassigns-auto-sc-id=%d", |
| 500 | PRFIELD(trace_class->assigns_automatic_stream_class_id)); |
| 501 | } |
| 502 | |
| 503 | static inline void format_trace(char **buf_ch, bool extended, |
| 504 | const char *prefix, const struct bt_trace *trace) |
| 505 | { |
| 506 | char tmp_prefix[TMP_PREFIX_LEN]; |
| 507 | |
| 508 | if (trace->name.value) { |
| 509 | BUF_APPEND(", %sname=\"%s\"", PRFIELD(trace->name.value)); |
| 510 | } |
| 511 | |
| 512 | if (!extended) { |
| 513 | return; |
| 514 | } |
| 515 | |
| 516 | if (trace->uuid.value) { |
| 517 | BUF_APPEND_UUID(trace->uuid.value); |
| 518 | } |
| 519 | |
| 520 | BUF_APPEND(", %sis-frozen=%d", PRFIELD(trace->frozen)); |
| 521 | |
| 522 | if (trace->streams) { |
| 523 | BUF_APPEND(", %sstream-count=%u", |
| 524 | PRFIELD(trace->streams->len)); |
| 525 | } |
| 526 | |
| 527 | if (!trace->class) { |
| 528 | return; |
| 529 | } |
| 530 | |
| 531 | BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace->class)); |
| 532 | SET_TMP_PREFIX("trace-class-"); |
| 533 | format_trace_class(buf_ch, false, tmp_prefix, trace->class); |
| 534 | } |
| 535 | |
| 536 | static inline void format_stream_class(char **buf_ch, bool extended, |
| 537 | const char *prefix, |
| 538 | const struct bt_stream_class *stream_class) |
| 539 | { |
| 540 | const struct bt_trace_class *trace_class; |
| 541 | char tmp_prefix[TMP_PREFIX_LEN]; |
| 542 | |
| 543 | BUF_APPEND(", %sid=%" PRIu64, PRFIELD(stream_class->id)); |
| 544 | |
| 545 | if (stream_class->name.value) { |
| 546 | BUF_APPEND(", %sname=\"%s\"", |
| 547 | PRFIELD(stream_class->name.value)); |
| 548 | } |
| 549 | |
| 550 | if (!extended) { |
| 551 | return; |
| 552 | } |
| 553 | |
| 554 | BUF_APPEND(", %sis-frozen=%d", PRFIELD(stream_class->frozen)); |
| 555 | |
| 556 | if (stream_class->event_classes) { |
| 557 | BUF_APPEND(", %sevent-class-count=%u", |
| 558 | PRFIELD(stream_class->event_classes->len)); |
| 559 | } |
| 560 | |
| 561 | BUF_APPEND(", %spacket-context-fc-addr=%p, " |
| 562 | "%sevent-common-context-fc-addr=%p", |
| 563 | PRFIELD(stream_class->packet_context_fc), |
| 564 | PRFIELD(stream_class->event_common_context_fc)); |
| 565 | trace_class = bt_stream_class_borrow_trace_class_inline(stream_class); |
| 566 | if (!trace_class) { |
| 567 | return; |
| 568 | } |
| 569 | |
| 570 | BUF_APPEND(", %sassigns-auto-ec-id=%d, %sassigns-auto-stream-id=%d, " |
| 571 | "%ssupports-packets=%d, " |
| 572 | "%spackets-have-begin-default-cs=%d, " |
| 573 | "%spackets-have-end-default-cs=%d, " |
| 574 | "%ssupports-discarded-events=%d, " |
| 575 | "%sdiscarded-events-have-default-cs=%d, " |
| 576 | "%ssupports-discarded-packets=%d, " |
| 577 | "%sdiscarded-packets-have-default-cs=%d", |
| 578 | PRFIELD(stream_class->assigns_automatic_event_class_id), |
| 579 | PRFIELD(stream_class->assigns_automatic_stream_id), |
| 580 | PRFIELD(stream_class->supports_packets), |
| 581 | PRFIELD(stream_class->packets_have_beginning_default_clock_snapshot), |
| 582 | PRFIELD(stream_class->packets_have_end_default_clock_snapshot), |
| 583 | PRFIELD(stream_class->supports_discarded_events), |
| 584 | PRFIELD(stream_class->discarded_events_have_default_clock_snapshots), |
| 585 | PRFIELD(stream_class->supports_discarded_packets), |
| 586 | PRFIELD(stream_class->discarded_packets_have_default_clock_snapshots)); |
| 587 | BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace_class)); |
| 588 | SET_TMP_PREFIX("trace-class-"); |
| 589 | format_trace_class(buf_ch, false, tmp_prefix, trace_class); |
| 590 | SET_TMP_PREFIX("pcf-pool-"); |
| 591 | format_object_pool(buf_ch, extended, tmp_prefix, |
| 592 | &stream_class->packet_context_field_pool); |
| 593 | } |
| 594 | |
| 595 | static inline void format_event_class(char **buf_ch, bool extended, |
| 596 | const char *prefix, const struct bt_event_class *event_class) |
| 597 | { |
| 598 | const struct bt_stream_class *stream_class; |
| 599 | const struct bt_trace_class *trace_class; |
| 600 | char tmp_prefix[TMP_PREFIX_LEN]; |
| 601 | |
| 602 | BUF_APPEND(", %sid=%" PRIu64, PRFIELD(event_class->id)); |
| 603 | |
| 604 | if (event_class->name.value) { |
| 605 | BUF_APPEND(", %sname=\"%s\"", |
| 606 | PRFIELD(event_class->name.value)); |
| 607 | } |
| 608 | |
| 609 | if (!extended) { |
| 610 | return; |
| 611 | } |
| 612 | |
| 613 | BUF_APPEND(", %sis-frozen=%d", PRFIELD(event_class->frozen)); |
| 614 | |
| 615 | if (event_class->log_level.base.avail) { |
| 616 | BUF_APPEND(", %slog-level=%s", |
| 617 | PRFIELD(bt_common_event_class_log_level_string( |
| 618 | (int) event_class->log_level.value))); |
| 619 | } |
| 620 | |
| 621 | if (event_class->emf_uri.value) { |
| 622 | BUF_APPEND(", %semf-uri=\"%s\"", |
| 623 | PRFIELD(event_class->emf_uri.value)); |
| 624 | } |
| 625 | |
| 626 | BUF_APPEND(", %sspecific-context-fc-addr=%p, %spayload-fc-addr=%p", |
| 627 | PRFIELD(event_class->specific_context_fc), |
| 628 | PRFIELD(event_class->payload_fc)); |
| 629 | |
| 630 | stream_class = bt_event_class_borrow_stream_class_const(event_class); |
| 631 | if (!stream_class) { |
| 632 | return; |
| 633 | } |
| 634 | |
| 635 | BUF_APPEND(", %sstream-class-addr=%p", PRFIELD(stream_class)); |
| 636 | SET_TMP_PREFIX("stream-class-"); |
| 637 | format_stream_class(buf_ch, false, tmp_prefix, stream_class); |
| 638 | trace_class = bt_stream_class_borrow_trace_class_inline(stream_class); |
| 639 | if (!trace_class) { |
| 640 | return; |
| 641 | } |
| 642 | |
| 643 | BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace_class)); |
| 644 | SET_TMP_PREFIX("trace-class-"); |
| 645 | format_trace_class(buf_ch, false, tmp_prefix, trace_class); |
| 646 | SET_TMP_PREFIX("event-pool-"); |
| 647 | format_object_pool(buf_ch, extended, tmp_prefix, |
| 648 | &event_class->event_pool); |
| 649 | } |
| 650 | |
| 651 | static inline void format_stream(char **buf_ch, bool extended, |
| 652 | const char *prefix, const struct bt_stream *stream) |
| 653 | { |
| 654 | const struct bt_stream_class *stream_class; |
| 655 | const struct bt_trace_class *trace_class = NULL; |
| 656 | const struct bt_trace *trace = NULL; |
| 657 | char tmp_prefix[TMP_PREFIX_LEN]; |
| 658 | |
| 659 | BUF_APPEND(", %sid=%" PRIu64, PRFIELD(stream->id)); |
| 660 | |
| 661 | if (stream->name.value) { |
| 662 | BUF_APPEND(", %sname=\"%s\"", PRFIELD(stream->name.value)); |
| 663 | } |
| 664 | |
| 665 | if (!extended) { |
| 666 | return; |
| 667 | } |
| 668 | |
| 669 | stream_class = bt_stream_borrow_class_const(stream); |
| 670 | if (stream_class) { |
| 671 | BUF_APPEND(", %sstream-class-addr=%p", PRFIELD(stream_class)); |
| 672 | SET_TMP_PREFIX("stream-class-"); |
| 673 | format_stream_class(buf_ch, false, tmp_prefix, stream_class); |
| 674 | trace_class = bt_stream_class_borrow_trace_class_inline(stream_class); |
| 675 | } |
| 676 | |
| 677 | if (trace_class) { |
| 678 | BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace_class)); |
| 679 | SET_TMP_PREFIX("trace-class-"); |
| 680 | format_trace_class(buf_ch, false, tmp_prefix, trace_class); |
| 681 | } |
| 682 | |
| 683 | trace = bt_stream_borrow_trace_inline(stream); |
| 684 | if (trace) { |
| 685 | BUF_APPEND(", %strace-addr=%p", PRFIELD(trace)); |
| 686 | SET_TMP_PREFIX("trace-"); |
| 687 | format_trace(buf_ch, false, tmp_prefix, trace); |
| 688 | } |
| 689 | |
| 690 | SET_TMP_PREFIX("packet-pool-"); |
| 691 | format_object_pool(buf_ch, extended, tmp_prefix, &stream->packet_pool); |
| 692 | } |
| 693 | |
| 694 | static inline void format_packet(char **buf_ch, bool extended, |
| 695 | const char *prefix, const struct bt_packet *packet) |
| 696 | { |
| 697 | const struct bt_stream *stream; |
| 698 | const struct bt_trace_class *trace_class; |
| 699 | char tmp_prefix[TMP_PREFIX_LEN]; |
| 700 | |
| 701 | if (!extended) { |
| 702 | return; |
| 703 | } |
| 704 | |
| 705 | BUF_APPEND(", %sis-frozen=%d, %scontext-field-addr=%p", |
| 706 | PRFIELD(packet->frozen), |
| 707 | PRFIELD(packet->context_field ? packet->context_field->field : NULL)); |
| 708 | stream = bt_packet_borrow_stream_const(packet); |
| 709 | if (!stream) { |
| 710 | return; |
| 711 | } |
| 712 | |
| 713 | BUF_APPEND(", %sstream-addr=%p", PRFIELD(stream)); |
| 714 | SET_TMP_PREFIX("stream-"); |
| 715 | format_stream(buf_ch, false, tmp_prefix, stream); |
| 716 | trace_class = (const struct bt_trace_class *) bt_object_borrow_parent(&stream->base); |
| 717 | if (!trace_class) { |
| 718 | return; |
| 719 | } |
| 720 | |
| 721 | BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace_class)); |
| 722 | SET_TMP_PREFIX("trace-class-"); |
| 723 | format_trace_class(buf_ch, false, tmp_prefix, trace_class); |
| 724 | } |
| 725 | |
| 726 | static inline void format_event(char **buf_ch, bool extended, |
| 727 | const char *prefix, const struct bt_event *event) |
| 728 | { |
| 729 | const struct bt_trace_class *trace_class; |
| 730 | const struct bt_stream_class *stream_class; |
| 731 | char tmp_prefix[TMP_PREFIX_LEN]; |
| 732 | |
| 733 | if (!extended) { |
| 734 | return; |
| 735 | } |
| 736 | |
| 737 | BUF_APPEND(", %sis-frozen=%d, " |
| 738 | "%scommon-context-field-addr=%p, " |
| 739 | "%sspecific-context-field-addr=%p, " |
| 740 | "%spayload-field-addr=%p, ", |
| 741 | PRFIELD(event->frozen), |
| 742 | PRFIELD(event->common_context_field), |
| 743 | PRFIELD(event->specific_context_field), |
| 744 | PRFIELD(event->payload_field)); |
| 745 | BUF_APPEND(", %sevent-class-addr=%p", PRFIELD(event->class)); |
| 746 | |
| 747 | if (!event->class) { |
| 748 | return; |
| 749 | } |
| 750 | |
| 751 | SET_TMP_PREFIX("event-class-"); |
| 752 | format_event_class(buf_ch, false, tmp_prefix, event->class); |
| 753 | stream_class = bt_event_class_borrow_stream_class(event->class); |
| 754 | if (stream_class) { |
| 755 | BUF_APPEND(", %sstream-class-addr=%p", PRFIELD(stream_class)); |
| 756 | SET_TMP_PREFIX("stream-class-"); |
| 757 | format_stream_class(buf_ch, false, tmp_prefix, |
| 758 | stream_class); |
| 759 | |
| 760 | trace_class = bt_stream_class_borrow_trace_class_inline( |
| 761 | stream_class); |
| 762 | if (trace_class) { |
| 763 | BUF_APPEND(", %strace-class-addr=%p", |
| 764 | PRFIELD(trace_class)); |
| 765 | SET_TMP_PREFIX("trace-class-"); |
| 766 | format_trace_class(buf_ch, false, tmp_prefix, |
| 767 | trace_class); |
| 768 | } |
| 769 | } |
| 770 | |
| 771 | if (event->stream) { |
| 772 | BUF_APPEND(", %sstream-addr=%p", PRFIELD(event->stream)); |
| 773 | SET_TMP_PREFIX("stream-"); |
| 774 | format_stream(buf_ch, false, tmp_prefix, event->stream); |
| 775 | } |
| 776 | |
| 777 | if (event->packet) { |
| 778 | BUF_APPEND(", %spacket-addr=%p", PRFIELD(event->packet)); |
| 779 | SET_TMP_PREFIX("packet-"); |
| 780 | format_packet(buf_ch, false, tmp_prefix, event->packet); |
| 781 | } |
| 782 | } |
| 783 | |
| 784 | static inline void format_clock_class(char **buf_ch, bool extended, |
| 785 | const char *prefix, const struct bt_clock_class *clock_class) |
| 786 | { |
| 787 | char tmp_prefix[TMP_PREFIX_LEN]; |
| 788 | |
| 789 | if (clock_class->name.value) { |
| 790 | BUF_APPEND(", %sname=\"%s\"", PRFIELD(clock_class->name.value)); |
| 791 | } |
| 792 | |
| 793 | BUF_APPEND(", %sfreq=%" PRIu64, PRFIELD(clock_class->frequency)); |
| 794 | |
| 795 | if (!extended) { |
| 796 | return; |
| 797 | } |
| 798 | |
| 799 | if (clock_class->description.value) { |
| 800 | BUF_APPEND(", %spartial-descr=\"%.32s\"", |
| 801 | PRFIELD(clock_class->description.value)); |
| 802 | } |
| 803 | |
| 804 | if (clock_class->uuid.value) { |
| 805 | BUF_APPEND_UUID(clock_class->uuid.value); |
| 806 | } |
| 807 | |
| 808 | BUF_APPEND(", %sis-frozen=%d, %sprecision=%" PRIu64 ", " |
| 809 | "%soffset-s=%" PRId64 ", " |
| 810 | "%soffset-cycles=%" PRIu64 ", %sorigin-is-unix-epoch=%d, " |
| 811 | "%sbase-offset-ns=%" PRId64, |
| 812 | PRFIELD(clock_class->frozen), PRFIELD(clock_class->precision), |
| 813 | PRFIELD(clock_class->offset_seconds), |
| 814 | PRFIELD(clock_class->offset_cycles), |
| 815 | PRFIELD(clock_class->origin_is_unix_epoch), |
| 816 | PRFIELD(clock_class->base_offset.value_ns)); |
| 817 | |
| 818 | SET_TMP_PREFIX("cs-pool-"); |
| 819 | format_object_pool(buf_ch, extended, tmp_prefix, |
| 820 | &clock_class->cs_pool); |
| 821 | } |
| 822 | |
| 823 | static inline void format_clock_snapshot(char **buf_ch, bool extended, |
| 824 | const char *prefix, const struct bt_clock_snapshot *clock_snapshot) |
| 825 | { |
| 826 | char tmp_prefix[TMP_PREFIX_LEN]; |
| 827 | BUF_APPEND(", %svalue=%" PRIu64 ", %sns-from-origin=%" PRId64, |
| 828 | PRFIELD(clock_snapshot->value_cycles), |
| 829 | PRFIELD(clock_snapshot->ns_from_origin)); |
| 830 | |
| 831 | if (!extended) { |
| 832 | return; |
| 833 | } |
| 834 | |
| 835 | BUF_APPEND(", %sis-set=%d", PRFIELD(clock_snapshot->is_set)); |
| 836 | |
| 837 | if (clock_snapshot->clock_class) { |
| 838 | BUF_APPEND(", %sclock-class-addr=%p", |
| 839 | PRFIELD(clock_snapshot->clock_class)); |
| 840 | SET_TMP_PREFIX("clock-class-"); |
| 841 | format_clock_class(buf_ch, false, tmp_prefix, |
| 842 | clock_snapshot->clock_class); |
| 843 | } |
| 844 | } |
| 845 | |
| 846 | static inline void format_interrupter(char **buf_ch, bool extended, |
| 847 | const char *prefix, const struct bt_interrupter *intr) |
| 848 | { |
| 849 | BUF_APPEND(", %sis-set=%d", PRFIELD(intr->is_set)); |
| 850 | } |
| 851 | |
| 852 | static inline void format_value(char **buf_ch, bool extended, |
| 853 | const char *prefix, const struct bt_value *value) |
| 854 | { |
| 855 | BUF_APPEND(", %stype=%s", |
| 856 | PRFIELD(bt_common_value_type_string(bt_value_get_type(value)))); |
| 857 | |
| 858 | if (!extended) { |
| 859 | return; |
| 860 | } |
| 861 | |
| 862 | switch (bt_value_get_type(value)) { |
| 863 | case BT_VALUE_TYPE_BOOL: |
| 864 | { |
| 865 | bt_bool val = bt_value_bool_get(value); |
| 866 | |
| 867 | BUF_APPEND(", %svalue=%d", PRFIELD(val)); |
| 868 | break; |
| 869 | } |
| 870 | case BT_VALUE_TYPE_UNSIGNED_INTEGER: |
| 871 | { |
| 872 | BUF_APPEND(", %svalue=%" PRIu64, |
| 873 | PRFIELD(bt_value_integer_unsigned_get(value))); |
| 874 | break; |
| 875 | } |
| 876 | case BT_VALUE_TYPE_SIGNED_INTEGER: |
| 877 | { |
| 878 | BUF_APPEND(", %svalue=%" PRId64, |
| 879 | PRFIELD(bt_value_integer_signed_get(value))); |
| 880 | break; |
| 881 | } |
| 882 | case BT_VALUE_TYPE_REAL: |
| 883 | { |
| 884 | double val = bt_value_real_get(value); |
| 885 | |
| 886 | BUF_APPEND(", %svalue=%f", PRFIELD(val)); |
| 887 | break; |
| 888 | } |
| 889 | case BT_VALUE_TYPE_STRING: |
| 890 | { |
| 891 | const char *val = bt_value_string_get(value); |
| 892 | |
| 893 | BUF_APPEND(", %spartial-value=\"%.32s\"", PRFIELD(val)); |
| 894 | break; |
| 895 | } |
| 896 | case BT_VALUE_TYPE_ARRAY: |
| 897 | { |
| 898 | uint64_t count = bt_value_array_get_length(value); |
| 899 | |
| 900 | BUF_APPEND(", %selement-count=%" PRId64, PRFIELD(count)); |
| 901 | break; |
| 902 | } |
| 903 | case BT_VALUE_TYPE_MAP: |
| 904 | { |
| 905 | int64_t count = bt_value_map_get_size(value); |
| 906 | |
| 907 | BT_ASSERT(count >= 0); |
| 908 | BUF_APPEND(", %selement-count=%" PRId64, PRFIELD(count)); |
| 909 | break; |
| 910 | } |
| 911 | default: |
| 912 | break; |
| 913 | } |
| 914 | } |
| 915 | |
| 916 | static inline void format_integer_range_set(char **buf_ch, bool extended, |
| 917 | const char *prefix, |
| 918 | const struct bt_integer_range_set *range_set) |
| 919 | { |
| 920 | BUF_APPEND(", %srange-count=%u", PRFIELD(range_set->ranges->len)); |
| 921 | |
| 922 | if (!extended) { |
| 923 | return; |
| 924 | } |
| 925 | |
| 926 | BUF_APPEND(", %sis-frozen=%d", PRFIELD(range_set->frozen)); |
| 927 | } |
| 928 | |
| 929 | static inline void format_message(char **buf_ch, bool extended, |
| 930 | const char *prefix, const struct bt_message *msg) |
| 931 | { |
| 932 | char tmp_prefix[TMP_PREFIX_LEN]; |
| 933 | |
| 934 | BUF_APPEND(", %stype=%s", |
| 935 | PRFIELD(bt_common_message_type_string(msg->type))); |
| 936 | |
| 937 | if (!extended) { |
| 938 | return; |
| 939 | } |
| 940 | |
| 941 | BUF_APPEND(", %sis-frozen=%d, %sgraph-addr=%p", |
| 942 | PRFIELD(msg->frozen), PRFIELD(msg->graph)); |
| 943 | |
| 944 | switch (msg->type) { |
| 945 | case BT_MESSAGE_TYPE_EVENT: |
| 946 | { |
| 947 | const struct bt_message_event *msg_event = |
| 948 | (const void *) msg; |
| 949 | |
| 950 | if (msg_event->event) { |
| 951 | SET_TMP_PREFIX("event-"); |
| 952 | format_event(buf_ch, true, tmp_prefix, |
| 953 | msg_event->event); |
| 954 | } |
| 955 | |
| 956 | if (msg_event->default_cs) { |
| 957 | SET_TMP_PREFIX("default-cs-"); |
| 958 | format_clock_snapshot(buf_ch, true, tmp_prefix, |
| 959 | msg_event->default_cs); |
| 960 | } |
| 961 | |
| 962 | break; |
| 963 | } |
| 964 | case BT_MESSAGE_TYPE_STREAM_BEGINNING: |
| 965 | case BT_MESSAGE_TYPE_STREAM_END: |
| 966 | { |
| 967 | const struct bt_message_stream *msg_stream = (const void *) msg; |
| 968 | |
| 969 | if (msg_stream->stream) { |
| 970 | SET_TMP_PREFIX("stream-"); |
| 971 | format_stream(buf_ch, true, tmp_prefix, |
| 972 | msg_stream->stream); |
| 973 | } |
| 974 | |
| 975 | BUF_APPEND(", %sdefault-cs-state=%s", |
| 976 | PRFIELD(bt_message_stream_clock_snapshot_state_string( |
| 977 | msg_stream->default_cs_state))); |
| 978 | |
| 979 | if (msg_stream->default_cs_state == BT_MESSAGE_STREAM_CLOCK_SNAPSHOT_STATE_KNOWN) { |
| 980 | SET_TMP_PREFIX("default-cs-"); |
| 981 | format_clock_snapshot(buf_ch, true, tmp_prefix, |
| 982 | msg_stream->default_cs); |
| 983 | } |
| 984 | |
| 985 | break; |
| 986 | } |
| 987 | case BT_MESSAGE_TYPE_PACKET_BEGINNING: |
| 988 | case BT_MESSAGE_TYPE_PACKET_END: |
| 989 | { |
| 990 | const struct bt_message_packet *msg_packet = (const void *) msg; |
| 991 | |
| 992 | if (msg_packet->packet) { |
| 993 | SET_TMP_PREFIX("packet-"); |
| 994 | format_packet(buf_ch, true, tmp_prefix, |
| 995 | msg_packet->packet); |
| 996 | } |
| 997 | |
| 998 | if (msg_packet->default_cs) { |
| 999 | SET_TMP_PREFIX("default-cs-"); |
| 1000 | format_clock_snapshot(buf_ch, true, tmp_prefix, |
| 1001 | msg_packet->default_cs); |
| 1002 | } |
| 1003 | |
| 1004 | break; |
| 1005 | } |
| 1006 | case BT_MESSAGE_TYPE_DISCARDED_EVENTS: |
| 1007 | case BT_MESSAGE_TYPE_DISCARDED_PACKETS: |
| 1008 | { |
| 1009 | const struct bt_message_discarded_items *msg_disc_items = |
| 1010 | (const void *) msg; |
| 1011 | |
| 1012 | if (msg_disc_items->stream) { |
| 1013 | SET_TMP_PREFIX("stream-"); |
| 1014 | format_stream(buf_ch, true, tmp_prefix, |
| 1015 | msg_disc_items->stream); |
| 1016 | } |
| 1017 | |
| 1018 | if (msg_disc_items->default_begin_cs) { |
| 1019 | SET_TMP_PREFIX("begin-default-cs-"); |
| 1020 | format_clock_snapshot(buf_ch, true, tmp_prefix, |
| 1021 | msg_disc_items->default_begin_cs); |
| 1022 | } |
| 1023 | |
| 1024 | if (msg_disc_items->default_end_cs) { |
| 1025 | SET_TMP_PREFIX("end-default-cs-"); |
| 1026 | format_clock_snapshot(buf_ch, true, tmp_prefix, |
| 1027 | msg_disc_items->default_end_cs); |
| 1028 | } |
| 1029 | |
| 1030 | if (msg_disc_items->count.base.avail) { |
| 1031 | BUF_APPEND(", %scount=%" PRIu64, |
| 1032 | PRFIELD(msg_disc_items->count.value)); |
| 1033 | } |
| 1034 | |
| 1035 | break; |
| 1036 | } |
| 1037 | default: |
| 1038 | break; |
| 1039 | } |
| 1040 | } |
| 1041 | |
| 1042 | static inline void format_plugin_so_shared_lib_handle(char **buf_ch, |
| 1043 | const char *prefix, |
| 1044 | const struct bt_plugin_so_shared_lib_handle *handle) |
| 1045 | { |
| 1046 | BUF_APPEND(", %saddr=%p", PRFIELD(handle)); |
| 1047 | |
| 1048 | if (handle->path) { |
| 1049 | BUF_APPEND(", %spath=\"%s\"", PRFIELD_GSTRING(handle->path)); |
| 1050 | } |
| 1051 | } |
| 1052 | |
| 1053 | static inline void format_component_class(char **buf_ch, bool extended, |
| 1054 | const char *prefix, |
| 1055 | const struct bt_component_class *comp_class) |
| 1056 | { |
| 1057 | char tmp_prefix[TMP_PREFIX_LEN]; |
| 1058 | |
| 1059 | BUF_APPEND(", %stype=%s, %sname=\"%s\"", |
| 1060 | PRFIELD(bt_common_component_class_type_string(comp_class->type)), |
| 1061 | PRFIELD_GSTRING(comp_class->name)); |
| 1062 | |
| 1063 | if (comp_class->description) { |
| 1064 | BUF_APPEND(", %spartial-descr=\"%.32s\"", |
| 1065 | PRFIELD_GSTRING(comp_class->description)); |
| 1066 | } |
| 1067 | |
| 1068 | if (!extended) { |
| 1069 | return; |
| 1070 | } |
| 1071 | |
| 1072 | BUF_APPEND(", %sis-frozen=%d", PRFIELD(comp_class->frozen)); |
| 1073 | |
| 1074 | if (comp_class->so_handle) { |
| 1075 | SET_TMP_PREFIX("so-handle-"); |
| 1076 | format_plugin_so_shared_lib_handle(buf_ch, tmp_prefix, |
| 1077 | comp_class->so_handle); |
| 1078 | } |
| 1079 | } |
| 1080 | |
| 1081 | static inline void format_component(char **buf_ch, bool extended, |
| 1082 | const char *prefix, const struct bt_component *component) |
| 1083 | { |
| 1084 | char tmp_prefix[TMP_PREFIX_LEN]; |
| 1085 | |
| 1086 | BUF_APPEND(", %sname=\"%s\", %slog-level=%s", |
| 1087 | PRFIELD_GSTRING(component->name), |
| 1088 | PRFIELD(bt_common_logging_level_string(component->log_level))); |
| 1089 | |
| 1090 | if (component->class) { |
| 1091 | SET_TMP_PREFIX("class-"); |
| 1092 | format_component_class(buf_ch, extended, tmp_prefix, |
| 1093 | component->class); |
| 1094 | } |
| 1095 | |
| 1096 | if (!extended) { |
| 1097 | return; |
| 1098 | } |
| 1099 | |
| 1100 | if (component->input_ports) { |
| 1101 | BUF_APPEND(", %sinput-port-count=%u", |
| 1102 | PRFIELD(component->input_ports->len)); |
| 1103 | } |
| 1104 | |
| 1105 | if (component->output_ports) { |
| 1106 | BUF_APPEND(", %soutput-port-count=%u", |
| 1107 | PRFIELD(component->output_ports->len)); |
| 1108 | } |
| 1109 | } |
| 1110 | |
| 1111 | static inline void format_port(char **buf_ch, bool extended, |
| 1112 | const char *prefix, const struct bt_port *port) |
| 1113 | { |
| 1114 | char tmp_prefix[TMP_PREFIX_LEN]; |
| 1115 | |
| 1116 | BUF_APPEND(", %stype=%s, %sname=\"%s\"", |
| 1117 | PRFIELD(bt_port_type_string(port->type)), |
| 1118 | PRFIELD_GSTRING(port->name)); |
| 1119 | |
| 1120 | if (!extended) { |
| 1121 | return; |
| 1122 | } |
| 1123 | |
| 1124 | if (port->connection) { |
| 1125 | SET_TMP_PREFIX("conn-"); |
| 1126 | format_connection(buf_ch, false, tmp_prefix, port->connection); |
| 1127 | } |
| 1128 | } |
| 1129 | |
| 1130 | static inline void format_connection(char **buf_ch, bool extended, |
| 1131 | const char *prefix, const struct bt_connection *connection) |
| 1132 | { |
| 1133 | char tmp_prefix[TMP_PREFIX_LEN]; |
| 1134 | |
| 1135 | if (!extended) { |
| 1136 | return; |
| 1137 | } |
| 1138 | |
| 1139 | if (connection->upstream_port) { |
| 1140 | SET_TMP_PREFIX("upstream-port-"); |
| 1141 | format_port(buf_ch, false, tmp_prefix, |
| 1142 | connection->upstream_port); |
| 1143 | } |
| 1144 | |
| 1145 | if (connection->downstream_port) { |
| 1146 | SET_TMP_PREFIX("downstream-port-"); |
| 1147 | format_port(buf_ch, false, tmp_prefix, |
| 1148 | connection->downstream_port); |
| 1149 | } |
| 1150 | } |
| 1151 | |
| 1152 | static inline void format_graph(char **buf_ch, bool extended, |
| 1153 | const char *prefix, const struct bt_graph *graph) |
| 1154 | { |
| 1155 | char tmp_prefix[TMP_PREFIX_LEN]; |
| 1156 | |
| 1157 | BUF_APPEND(", %scan-consume=%d, %sconfig-state=%s", |
| 1158 | PRFIELD(graph->can_consume), |
| 1159 | PRFIELD(bt_graph_configuration_state_string(graph->config_state))); |
| 1160 | |
| 1161 | if (!extended) { |
| 1162 | return; |
| 1163 | } |
| 1164 | |
| 1165 | if (graph->components) { |
| 1166 | BUF_APPEND(", %scomp-count=%u", |
| 1167 | PRFIELD(graph->components->len)); |
| 1168 | } |
| 1169 | |
| 1170 | if (graph->connections) { |
| 1171 | BUF_APPEND(", %sconn-count=%u", |
| 1172 | PRFIELD(graph->connections->len)); |
| 1173 | } |
| 1174 | |
| 1175 | SET_TMP_PREFIX("en-pool-"); |
| 1176 | format_object_pool(buf_ch, extended, tmp_prefix, |
| 1177 | &graph->event_msg_pool); |
| 1178 | SET_TMP_PREFIX("pbn-pool-"); |
| 1179 | format_object_pool(buf_ch, extended, tmp_prefix, |
| 1180 | &graph->packet_begin_msg_pool); |
| 1181 | SET_TMP_PREFIX("pen-pool-"); |
| 1182 | format_object_pool(buf_ch, extended, tmp_prefix, |
| 1183 | &graph->packet_end_msg_pool); |
| 1184 | } |
| 1185 | |
| 1186 | static inline void format_message_iterator_class(char **buf_ch, |
| 1187 | bool extended, const char *prefix, |
| 1188 | const struct bt_message_iterator_class *iterator_class) |
| 1189 | { |
| 1190 | /* Empty, the address is automatically printed. */ |
| 1191 | } |
| 1192 | |
| 1193 | static inline void format_message_iterator(char **buf_ch, |
| 1194 | bool extended, const char *prefix, |
| 1195 | const struct bt_message_iterator *iterator) |
| 1196 | { |
| 1197 | char tmp_prefix[TMP_PREFIX_LEN]; |
| 1198 | const struct bt_message_iterator * |
| 1199 | port_in_iter = (const void *) iterator; |
| 1200 | |
| 1201 | if (port_in_iter->upstream_component) { |
| 1202 | SET_TMP_PREFIX("upstream-comp-"); |
| 1203 | format_component(buf_ch, false, tmp_prefix, |
| 1204 | port_in_iter->upstream_component); |
| 1205 | } |
| 1206 | |
| 1207 | if (!extended) { |
| 1208 | goto end; |
| 1209 | } |
| 1210 | |
| 1211 | if (port_in_iter->upstream_port) { |
| 1212 | SET_TMP_PREFIX("upstream-port-"); |
| 1213 | format_port(buf_ch, false, tmp_prefix, |
| 1214 | port_in_iter->upstream_port); |
| 1215 | } |
| 1216 | |
| 1217 | if (port_in_iter->connection) { |
| 1218 | SET_TMP_PREFIX("upstream-conn-"); |
| 1219 | format_connection(buf_ch, false, tmp_prefix, |
| 1220 | port_in_iter->connection); |
| 1221 | } |
| 1222 | |
| 1223 | end: |
| 1224 | return; |
| 1225 | } |
| 1226 | |
| 1227 | static inline void format_plugin(char **buf_ch, bool extended, |
| 1228 | const char *prefix, const struct bt_plugin *plugin) |
| 1229 | { |
| 1230 | char tmp_prefix[TMP_PREFIX_LEN]; |
| 1231 | |
| 1232 | BUF_APPEND(", %stype=%s", PRFIELD(bt_plugin_type_string(plugin->type))); |
| 1233 | |
| 1234 | if (plugin->info.path_set) { |
| 1235 | BUF_APPEND(", %spath=\"%s\"", |
| 1236 | PRFIELD_GSTRING(plugin->info.path)); |
| 1237 | } |
| 1238 | |
| 1239 | if (plugin->info.name_set) { |
| 1240 | BUF_APPEND(", %sname=\"%s\"", |
| 1241 | PRFIELD_GSTRING(plugin->info.name)); |
| 1242 | } |
| 1243 | |
| 1244 | if (!extended) { |
| 1245 | return; |
| 1246 | } |
| 1247 | |
| 1248 | if (plugin->info.author_set) { |
| 1249 | BUF_APPEND(", %sauthor=\"%s\"", |
| 1250 | PRFIELD_GSTRING(plugin->info.author)); |
| 1251 | } |
| 1252 | |
| 1253 | if (plugin->info.license_set) { |
| 1254 | BUF_APPEND(", %slicense=\"%s\"", |
| 1255 | PRFIELD_GSTRING(plugin->info.license)); |
| 1256 | } |
| 1257 | |
| 1258 | if (plugin->info.version_set) { |
| 1259 | BUF_APPEND(", %sversion=%u.%u.%u%s", |
| 1260 | PRFIELD(plugin->info.version.major), |
| 1261 | plugin->info.version.minor, |
| 1262 | plugin->info.version.patch, |
| 1263 | plugin->info.version.extra ? |
| 1264 | plugin->info.version.extra->str : ""); |
| 1265 | } |
| 1266 | |
| 1267 | BUF_APPEND(", %ssrc-comp-class-count=%u, %sflt-comp-class-count=%u, " |
| 1268 | "%ssink-comp-class-count=%u", |
| 1269 | PRFIELD(plugin->src_comp_classes->len), |
| 1270 | PRFIELD(plugin->flt_comp_classes->len), |
| 1271 | PRFIELD(plugin->sink_comp_classes->len)); |
| 1272 | |
| 1273 | if (plugin->spec_data) { |
| 1274 | const struct bt_plugin_so_spec_data *spec_data = |
| 1275 | (const void *) plugin->spec_data; |
| 1276 | |
| 1277 | if (spec_data->shared_lib_handle) { |
| 1278 | SET_TMP_PREFIX("so-handle-"); |
| 1279 | format_plugin_so_shared_lib_handle(buf_ch, tmp_prefix, |
| 1280 | spec_data->shared_lib_handle); |
| 1281 | } |
| 1282 | } |
| 1283 | } |
| 1284 | |
| 1285 | static inline void format_error_cause(char **buf_ch, bool extended, |
| 1286 | const char *prefix, const struct bt_error_cause *cause) |
| 1287 | { |
| 1288 | const struct bt_error_cause_component_class_id *comp_class_id = NULL; |
| 1289 | |
| 1290 | BUF_APPEND(", %sactor-type=%s, %smodule-name=\"%s\"", |
| 1291 | PRFIELD(bt_error_cause_actor_type_string(cause->actor_type)), |
| 1292 | PRFIELD_GSTRING(cause->module_name)); |
| 1293 | |
| 1294 | if (!extended) { |
| 1295 | return; |
| 1296 | } |
| 1297 | |
| 1298 | BUF_APPEND(", %spartial-msg=\"%.32s\"", |
| 1299 | PRFIELD_GSTRING(cause->message)); |
| 1300 | |
| 1301 | switch (cause->actor_type) { |
| 1302 | case BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT: |
| 1303 | { |
| 1304 | const struct bt_error_cause_component_actor *spec_cause = |
| 1305 | (const void *) cause; |
| 1306 | |
| 1307 | BUF_APPEND(", %scomp-name=\"%s\"", |
| 1308 | PRFIELD_GSTRING(spec_cause->comp_name)); |
| 1309 | comp_class_id = &spec_cause->comp_class_id; |
| 1310 | break; |
| 1311 | } |
| 1312 | case BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT_CLASS: |
| 1313 | { |
| 1314 | const struct bt_error_cause_component_class_actor *spec_cause = |
| 1315 | (const void *) cause; |
| 1316 | |
| 1317 | comp_class_id = &spec_cause->comp_class_id; |
| 1318 | break; |
| 1319 | } |
| 1320 | case BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR: |
| 1321 | { |
| 1322 | const struct bt_error_cause_message_iterator_actor *spec_cause = |
| 1323 | (const void *) cause; |
| 1324 | |
| 1325 | BUF_APPEND(", %scomp-name=\"%s\", %scomp-out-port-name=\"%s\"", |
| 1326 | PRFIELD_GSTRING(spec_cause->comp_name), |
| 1327 | PRFIELD_GSTRING(spec_cause->output_port_name)); |
| 1328 | comp_class_id = &spec_cause->comp_class_id; |
| 1329 | break; |
| 1330 | } |
| 1331 | default: |
| 1332 | break; |
| 1333 | } |
| 1334 | |
| 1335 | if (comp_class_id) { |
| 1336 | BUF_APPEND(", %scomp-cls-type=%s, %scomp-cls-name=\"%s\", " |
| 1337 | "%splugin-name=\"%s\"", |
| 1338 | PRFIELD(bt_common_component_class_type_string( |
| 1339 | comp_class_id->type)), |
| 1340 | PRFIELD_GSTRING(comp_class_id->name), |
| 1341 | PRFIELD_GSTRING(comp_class_id->plugin_name)); |
| 1342 | } |
| 1343 | } |
| 1344 | |
| 1345 | static inline void handle_conversion_specifier_bt(void *priv_data, |
| 1346 | char **buf_ch, size_t avail_size, |
| 1347 | const char **out_fmt_ch, va_list *args) |
| 1348 | { |
| 1349 | const char *fmt_ch = *out_fmt_ch; |
| 1350 | bool extended = false; |
| 1351 | char prefix[64]; |
| 1352 | char *prefix_ch = prefix; |
| 1353 | const void *obj; |
| 1354 | |
| 1355 | /* skip "%!" */ |
| 1356 | fmt_ch += 2; |
| 1357 | |
| 1358 | if (*fmt_ch == 'u') { |
| 1359 | /* UUID */ |
| 1360 | obj = va_arg(*args, void *); |
| 1361 | format_uuid(buf_ch, obj); |
| 1362 | goto update_fmt; |
| 1363 | } |
| 1364 | |
| 1365 | if (*fmt_ch == '[') { |
| 1366 | /* local prefix */ |
| 1367 | fmt_ch++; |
| 1368 | |
| 1369 | while (true) { |
| 1370 | if (*fmt_ch == ']') { |
| 1371 | *prefix_ch = '\0'; |
| 1372 | fmt_ch++; |
| 1373 | break; |
| 1374 | } |
| 1375 | |
| 1376 | *prefix_ch = *fmt_ch; |
| 1377 | prefix_ch++; |
| 1378 | fmt_ch++; |
| 1379 | } |
| 1380 | } |
| 1381 | |
| 1382 | *prefix_ch = '\0'; |
| 1383 | |
| 1384 | if (*fmt_ch == '+') { |
| 1385 | extended = true; |
| 1386 | fmt_ch++; |
| 1387 | } |
| 1388 | |
| 1389 | obj = va_arg(*args, void *); |
| 1390 | BUF_APPEND("%saddr=%p", prefix, obj); |
| 1391 | |
| 1392 | if (!obj) { |
| 1393 | goto update_fmt; |
| 1394 | } |
| 1395 | |
| 1396 | switch (*fmt_ch) { |
| 1397 | case 'F': |
| 1398 | format_field_class(buf_ch, extended, prefix, obj); |
| 1399 | break; |
| 1400 | case 'f': |
| 1401 | format_field(buf_ch, extended, prefix, obj); |
| 1402 | break; |
| 1403 | case 'P': |
| 1404 | format_field_path(buf_ch, extended, prefix, obj); |
| 1405 | break; |
| 1406 | case 'E': |
| 1407 | format_event_class(buf_ch, extended, prefix, obj); |
| 1408 | break; |
| 1409 | case 'e': |
| 1410 | format_event(buf_ch, extended, prefix, obj); |
| 1411 | break; |
| 1412 | case 'S': |
| 1413 | format_stream_class(buf_ch, extended, prefix, obj); |
| 1414 | break; |
| 1415 | case 's': |
| 1416 | format_stream(buf_ch, extended, prefix, obj); |
| 1417 | break; |
| 1418 | case 'a': |
| 1419 | format_packet(buf_ch, extended, prefix, obj); |
| 1420 | break; |
| 1421 | case 't': |
| 1422 | format_trace(buf_ch, extended, prefix, obj); |
| 1423 | break; |
| 1424 | case 'T': |
| 1425 | format_trace_class(buf_ch, extended, prefix, obj); |
| 1426 | break; |
| 1427 | case 'K': |
| 1428 | format_clock_class(buf_ch, extended, prefix, obj); |
| 1429 | break; |
| 1430 | case 'k': |
| 1431 | format_clock_snapshot(buf_ch, extended, prefix, obj); |
| 1432 | break; |
| 1433 | case 'v': |
| 1434 | format_value(buf_ch, extended, prefix, obj); |
| 1435 | break; |
| 1436 | case 'R': |
| 1437 | format_integer_range_set(buf_ch, extended, prefix, obj); |
| 1438 | break; |
| 1439 | case 'n': |
| 1440 | format_message(buf_ch, extended, prefix, obj); |
| 1441 | break; |
| 1442 | case 'I': |
| 1443 | format_message_iterator_class(buf_ch, extended, prefix, obj); |
| 1444 | break; |
| 1445 | case 'i': |
| 1446 | format_message_iterator(buf_ch, extended, prefix, obj); |
| 1447 | break; |
| 1448 | case 'C': |
| 1449 | format_component_class(buf_ch, extended, prefix, obj); |
| 1450 | break; |
| 1451 | case 'c': |
| 1452 | format_component(buf_ch, extended, prefix, obj); |
| 1453 | break; |
| 1454 | case 'p': |
| 1455 | format_port(buf_ch, extended, prefix, obj); |
| 1456 | break; |
| 1457 | case 'x': |
| 1458 | format_connection(buf_ch, extended, prefix, obj); |
| 1459 | break; |
| 1460 | case 'l': |
| 1461 | format_plugin(buf_ch, extended, prefix, obj); |
| 1462 | break; |
| 1463 | case 'g': |
| 1464 | format_graph(buf_ch, extended, prefix, obj); |
| 1465 | break; |
| 1466 | case 'z': |
| 1467 | format_interrupter(buf_ch, extended, prefix, obj); |
| 1468 | break; |
| 1469 | case 'o': |
| 1470 | format_object_pool(buf_ch, extended, prefix, obj); |
| 1471 | break; |
| 1472 | case 'O': |
| 1473 | format_object(buf_ch, extended, prefix, obj); |
| 1474 | break; |
| 1475 | case 'r': |
| 1476 | format_error_cause(buf_ch, extended, prefix, obj); |
| 1477 | break; |
| 1478 | default: |
| 1479 | bt_common_abort(); |
| 1480 | } |
| 1481 | |
| 1482 | update_fmt: |
| 1483 | fmt_ch++; |
| 1484 | *out_fmt_ch = fmt_ch; |
| 1485 | } |
| 1486 | |
| 1487 | /* |
| 1488 | * This function would normally not be BT_EXPORTed, but it is used by the |
| 1489 | * Python plugin provider, which is conceptually part of libbabeltrace2, but |
| 1490 | * implemented as a separate shared object, for modularity. It is therefore |
| 1491 | * exposed, but not part of the public ABI. |
| 1492 | */ |
| 1493 | BT_EXPORT |
| 1494 | void bt_lib_log_v(const char *func, const char *file, unsigned line, |
| 1495 | int lvl, const char *tag, const char *fmt, va_list *args) |
| 1496 | { |
| 1497 | BT_ASSERT(fmt); |
| 1498 | bt_common_custom_vsnprintf(lib_logging_buf, LIB_LOGGING_BUF_SIZE, '!', |
| 1499 | handle_conversion_specifier_bt, NULL, fmt, args); |
| 1500 | _bt_log_write_d(func, file, line, lvl, tag, "%s", lib_logging_buf); |
| 1501 | } |
| 1502 | |
| 1503 | /* |
| 1504 | * This function would normally not be BT_EXPORTed, but it is used by the |
| 1505 | * Python plugin provider, which is conceptually part of libbabeltrace2, but |
| 1506 | * implemented as a separate shared object, for modularity. It is therefore |
| 1507 | * exposed, but not part of the public ABI. |
| 1508 | */ |
| 1509 | BT_EXPORT |
| 1510 | void bt_lib_log(const char *func, const char *file, unsigned line, |
| 1511 | int lvl, const char *tag, const char *fmt, ...) |
| 1512 | { |
| 1513 | va_list args; |
| 1514 | |
| 1515 | BT_ASSERT(fmt); |
| 1516 | va_start(args, fmt); |
| 1517 | bt_lib_log_v(func, file, line, lvl, tag, fmt, &args); |
| 1518 | va_end(args); |
| 1519 | } |
| 1520 | |
| 1521 | /* |
| 1522 | * This function would normally not be BT_EXPORTed, but it is used by the |
| 1523 | * Python plugin provider, which is conceptually part of libbabeltrace2, but |
| 1524 | * implemented as a separate shared object, for modularity. It is therefore |
| 1525 | * exposed, but not part of the ABI. |
| 1526 | */ |
| 1527 | BT_EXPORT |
| 1528 | void bt_lib_maybe_log_and_append_cause(const char *func, const char *file, |
| 1529 | unsigned line, int lvl, const char *tag, |
| 1530 | const char *fmt, ...) |
| 1531 | { |
| 1532 | va_list args; |
| 1533 | bt_current_thread_error_append_cause_status status; |
| 1534 | |
| 1535 | BT_ASSERT(fmt); |
| 1536 | va_start(args, fmt); |
| 1537 | bt_common_custom_vsnprintf(lib_logging_buf, LIB_LOGGING_BUF_SIZE, '!', |
| 1538 | handle_conversion_specifier_bt, NULL, fmt, &args); |
| 1539 | va_end(args); |
| 1540 | |
| 1541 | /* Log conditionally, but always append the error cause */ |
| 1542 | if (BT_LOG_ON(lvl)) { |
| 1543 | _bt_log_write_d(func, file, line, lvl, tag, "%s", |
| 1544 | lib_logging_buf); |
| 1545 | } |
| 1546 | |
| 1547 | status = bt_current_thread_error_append_cause_from_unknown( |
| 1548 | BT_LIB_LOG_LIBBABELTRACE2_NAME, file, line, "%s", |
| 1549 | lib_logging_buf); |
| 1550 | if (status) { |
| 1551 | /* |
| 1552 | * Worst case: this error cause is not appended to the |
| 1553 | * current thread's error. |
| 1554 | * |
| 1555 | * We can accept this as it's an almost impossible |
| 1556 | * scenario and returning an error here would mean you |
| 1557 | * need to check the return value of each |
| 1558 | * BT_LIB_LOG*_APPEND_CAUSE() macro and that would be |
| 1559 | * cumbersome. |
| 1560 | */ |
| 1561 | BT_LOGE("Cannot append error cause to current thread's " |
| 1562 | "error object: status=%s", |
| 1563 | bt_common_func_status_string(status)); |
| 1564 | } |
| 1565 | } |