| 1 | /* |
| 2 | * Copyright 2018 Philippe Proulx <pproulx@efficios.com> |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 5 | * of this software and associated documentation files (the "Software"), to deal |
| 6 | * in the Software without restriction, including without limitation the rights |
| 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 8 | * copies of the Software, and to permit persons to whom the Software is |
| 9 | * furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice shall be included in |
| 12 | * all copies or substantial portions of the Software. |
| 13 | * |
| 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 20 | * SOFTWARE. |
| 21 | */ |
| 22 | |
| 23 | #define BT_LOG_TAG "LIB-LOGGING" |
| 24 | |
| 25 | #include <stdarg.h> |
| 26 | #include <stdio.h> |
| 27 | #include <stdlib.h> |
| 28 | #include <string.h> |
| 29 | #include <inttypes.h> |
| 30 | #include <stdint.h> |
| 31 | #include <wchar.h> |
| 32 | #include <glib.h> |
| 33 | #include <babeltrace/common-internal.h> |
| 34 | #include <babeltrace/lib-logging-internal.h> |
| 35 | #include <babeltrace/values-internal.h> |
| 36 | #include <babeltrace/object-pool-internal.h> |
| 37 | #include <babeltrace/ctf-ir/field-types-internal.h> |
| 38 | #include <babeltrace/ctf-ir/fields-internal.h> |
| 39 | #include <babeltrace/ctf-ir/event-class-internal.h> |
| 40 | #include <babeltrace/ctf-ir/event-internal.h> |
| 41 | #include <babeltrace/ctf-ir/packet-internal.h> |
| 42 | #include <babeltrace/ctf-ir/stream-class-internal.h> |
| 43 | #include <babeltrace/ctf-ir/stream-internal.h> |
| 44 | #include <babeltrace/ctf-ir/trace-internal.h> |
| 45 | #include <babeltrace/ctf-ir/clock-class-internal.h> |
| 46 | #include <babeltrace/ctf-ir/clock-value-internal.h> |
| 47 | #include <babeltrace/ctf-ir/field-path-internal.h> |
| 48 | #include <babeltrace/ctf-ir/utils-internal.h> |
| 49 | #include <babeltrace/ctf-writer/field-types-internal.h> |
| 50 | #include <babeltrace/ctf-writer/fields-internal.h> |
| 51 | #include <babeltrace/ctf-writer/event-internal.h> |
| 52 | #include <babeltrace/ctf-writer/stream-class-internal.h> |
| 53 | #include <babeltrace/ctf-writer/stream-internal.h> |
| 54 | #include <babeltrace/ctf-writer/trace-internal.h> |
| 55 | #include <babeltrace/ctf-writer/clock-internal.h> |
| 56 | #include <babeltrace/ctf-writer/writer-internal.h> |
| 57 | #include <babeltrace/graph/component-class-internal.h> |
| 58 | #include <babeltrace/graph/component-class-sink-colander-internal.h> |
| 59 | #include <babeltrace/graph/component-filter-internal.h> |
| 60 | #include <babeltrace/graph/component-internal.h> |
| 61 | #include <babeltrace/graph/component-sink-internal.h> |
| 62 | #include <babeltrace/graph/component-source-internal.h> |
| 63 | #include <babeltrace/graph/connection-internal.h> |
| 64 | #include <babeltrace/graph/graph-internal.h> |
| 65 | #include <babeltrace/graph/notification-event-internal.h> |
| 66 | #include <babeltrace/graph/notification-inactivity-internal.h> |
| 67 | #include <babeltrace/graph/notification-internal.h> |
| 68 | #include <babeltrace/graph/notification-iterator-internal.h> |
| 69 | #include <babeltrace/graph/notification-packet-internal.h> |
| 70 | #include <babeltrace/graph/notification-stream-internal.h> |
| 71 | #include <babeltrace/graph/port-internal.h> |
| 72 | #include <babeltrace/plugin/plugin-internal.h> |
| 73 | #include <babeltrace/plugin/plugin-so-internal.h> |
| 74 | |
| 75 | #define LIB_LOGGING_BUF_SIZE (4096 * 4) |
| 76 | |
| 77 | static char __thread lib_logging_buf[LIB_LOGGING_BUF_SIZE]; |
| 78 | |
| 79 | #define BUF_APPEND(_fmt, ...) \ |
| 80 | do { \ |
| 81 | int _count; \ |
| 82 | size_t _size = LIB_LOGGING_BUF_SIZE - \ |
| 83 | (size_t) (*buf_ch - lib_logging_buf); \ |
| 84 | _count = snprintf(*buf_ch, _size, (_fmt), __VA_ARGS__); \ |
| 85 | BT_ASSERT(_count >= 0); \ |
| 86 | *buf_ch += MIN(_count, _size); \ |
| 87 | if (*buf_ch >= lib_logging_buf + LIB_LOGGING_BUF_SIZE - 1) { \ |
| 88 | return; \ |
| 89 | } \ |
| 90 | } while (0) |
| 91 | |
| 92 | #define BUF_APPEND_UUID(_uuid) \ |
| 93 | BUF_APPEND(", %suuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\"", \ |
| 94 | prefix, \ |
| 95 | (unsigned int) (_uuid)[0], \ |
| 96 | (unsigned int) (_uuid)[1], \ |
| 97 | (unsigned int) (_uuid)[2], \ |
| 98 | (unsigned int) (_uuid)[3], \ |
| 99 | (unsigned int) (_uuid)[4], \ |
| 100 | (unsigned int) (_uuid)[5], \ |
| 101 | (unsigned int) (_uuid)[6], \ |
| 102 | (unsigned int) (_uuid)[7], \ |
| 103 | (unsigned int) (_uuid)[8], \ |
| 104 | (unsigned int) (_uuid)[9], \ |
| 105 | (unsigned int) (_uuid)[10], \ |
| 106 | (unsigned int) (_uuid)[11], \ |
| 107 | (unsigned int) (_uuid)[12], \ |
| 108 | (unsigned int) (_uuid)[13], \ |
| 109 | (unsigned int) (_uuid)[14], \ |
| 110 | (unsigned int) (_uuid)[15]) |
| 111 | |
| 112 | #define PRFIELD(_expr) prefix, (_expr) |
| 113 | |
| 114 | #define SET_TMP_PREFIX(_prefix2) \ |
| 115 | do { \ |
| 116 | strcpy(tmp_prefix, prefix); \ |
| 117 | strcat(tmp_prefix, (_prefix2)); \ |
| 118 | } while (0) |
| 119 | |
| 120 | typedef void (*format_func)(char **, bool, const char *, void *); |
| 121 | |
| 122 | static inline void format_component(char **buf_ch, bool extended, |
| 123 | const char *prefix, struct bt_component *component); |
| 124 | |
| 125 | static inline void format_port(char **buf_ch, bool extended, |
| 126 | const char *prefix, struct bt_port *port); |
| 127 | |
| 128 | static inline void format_connection(char **buf_ch, bool extended, |
| 129 | const char *prefix, struct bt_connection *connection); |
| 130 | |
| 131 | static inline void format_clock_value(char **buf_ch, bool extended, |
| 132 | const char *prefix, struct bt_clock_value *clock_value); |
| 133 | |
| 134 | static inline void format_object(char **buf_ch, bool extended, |
| 135 | const char *prefix, struct bt_object *obj) |
| 136 | { |
| 137 | BUF_APPEND(", %sref-count=%llu", prefix, obj->ref_count); |
| 138 | } |
| 139 | |
| 140 | static inline void format_clock_value_set(char **buf_ch, bool extended, |
| 141 | const char *prefix, struct bt_clock_value_set *cv_set) |
| 142 | { |
| 143 | char tmp_prefix[64]; |
| 144 | |
| 145 | if (!cv_set->clock_values) { |
| 146 | return; |
| 147 | } |
| 148 | |
| 149 | BUF_APPEND(", %ssize=%u", PRFIELD(cv_set->clock_values->len)); |
| 150 | |
| 151 | if (cv_set->default_cv) { |
| 152 | SET_TMP_PREFIX("default-cv-"); |
| 153 | format_clock_value(buf_ch, extended, tmp_prefix, |
| 154 | cv_set->default_cv); |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | static inline void format_object_pool(char **buf_ch, bool extended, |
| 159 | const char *prefix, struct bt_object_pool *pool) |
| 160 | { |
| 161 | BUF_APPEND(", %ssize=%zu", PRFIELD(pool->size)); |
| 162 | |
| 163 | if (pool->objects) { |
| 164 | BUF_APPEND(", %scap=%u", PRFIELD(pool->objects->len)); |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | static inline void format_field_type_common(char **buf_ch, bool extended, |
| 169 | const char *prefix, struct bt_field_type_common *field_type) |
| 170 | { |
| 171 | BUF_APPEND(", %stype-id=%s, %salignment=%u", |
| 172 | PRFIELD(bt_common_field_type_id_string(field_type->id)), |
| 173 | PRFIELD(field_type->alignment)); |
| 174 | |
| 175 | if (extended) { |
| 176 | BUF_APPEND(", %sis-frozen=%d", PRFIELD(field_type->frozen)); |
| 177 | } else { |
| 178 | return; |
| 179 | } |
| 180 | |
| 181 | if (field_type->id == BT_FIELD_TYPE_ID_UNKNOWN) { |
| 182 | return; |
| 183 | } |
| 184 | |
| 185 | switch (field_type->id) { |
| 186 | case BT_FIELD_TYPE_ID_INTEGER: |
| 187 | { |
| 188 | struct bt_field_type_common_integer *integer = |
| 189 | BT_FROM_COMMON(field_type); |
| 190 | |
| 191 | BUF_APPEND(", %ssize=%u, %sis-signed=%d, %sbyte-order=%s, " |
| 192 | "%sbase=%d, %sencoding=%s, " |
| 193 | "%smapped-clock-class-addr=%p", |
| 194 | PRFIELD(integer->size), PRFIELD(integer->is_signed), |
| 195 | PRFIELD(bt_common_byte_order_string(integer->user_byte_order)), |
| 196 | PRFIELD(integer->base), |
| 197 | PRFIELD(bt_common_string_encoding_string(integer->encoding)), |
| 198 | PRFIELD(integer->mapped_clock_class)); |
| 199 | |
| 200 | if (integer->mapped_clock_class) { |
| 201 | BUF_APPEND(", %smapped-clock-class-name=\"%s\"", |
| 202 | PRFIELD(bt_clock_class_get_name(integer->mapped_clock_class))); |
| 203 | } |
| 204 | break; |
| 205 | } |
| 206 | case BT_FIELD_TYPE_ID_FLOAT: |
| 207 | { |
| 208 | struct bt_field_type_common_floating_point *flt = |
| 209 | BT_FROM_COMMON(field_type); |
| 210 | |
| 211 | BUF_APPEND(", %sexp-dig=%u, %smant-dig=%u, %sbyte-order=%s", |
| 212 | PRFIELD(flt->exp_dig), PRFIELD(flt->mant_dig), |
| 213 | PRFIELD(bt_common_byte_order_string(flt->user_byte_order))); |
| 214 | break; |
| 215 | } |
| 216 | case BT_FIELD_TYPE_ID_ENUM: |
| 217 | { |
| 218 | struct bt_field_type_common_enumeration *enm = |
| 219 | BT_FROM_COMMON(field_type); |
| 220 | |
| 221 | BUF_APPEND(", %smapping-count=%u", |
| 222 | PRFIELD(enm->entries->len)); |
| 223 | break; |
| 224 | } |
| 225 | case BT_FIELD_TYPE_ID_STRING: |
| 226 | { |
| 227 | struct bt_field_type_common_string *str = |
| 228 | BT_FROM_COMMON(field_type); |
| 229 | |
| 230 | BUF_APPEND(", %sencoding=%s", |
| 231 | PRFIELD(bt_common_string_encoding_string(str->encoding))); |
| 232 | break; |
| 233 | } |
| 234 | case BT_FIELD_TYPE_ID_STRUCT: |
| 235 | { |
| 236 | struct bt_field_type_common_structure *structure = |
| 237 | BT_FROM_COMMON(field_type); |
| 238 | |
| 239 | BUF_APPEND(", %sfield-count=%u", |
| 240 | PRFIELD(structure->fields->len)); |
| 241 | break; |
| 242 | } |
| 243 | case BT_FIELD_TYPE_ID_SEQUENCE: |
| 244 | { |
| 245 | struct bt_field_type_common_sequence *seq = |
| 246 | BT_FROM_COMMON(field_type); |
| 247 | |
| 248 | BUF_APPEND(", %slength-ft-addr=\"%s\", %selem-ft-addr=%p", |
| 249 | PRFIELD(seq->length_field_name->str), |
| 250 | PRFIELD(seq->element_ft)); |
| 251 | break; |
| 252 | } |
| 253 | case BT_FIELD_TYPE_ID_VARIANT: |
| 254 | { |
| 255 | struct bt_field_type_common_variant *variant = |
| 256 | BT_FROM_COMMON(field_type); |
| 257 | |
| 258 | BUF_APPEND(", %stag-name=\"%s\", %sfield-count=%u", |
| 259 | PRFIELD(variant->tag_name->str), |
| 260 | PRFIELD(variant->choices->len)); |
| 261 | break; |
| 262 | } |
| 263 | default: |
| 264 | break; |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | static inline void format_field_type(char **buf_ch, bool extended, |
| 269 | const char *prefix, struct bt_field_type *field_type) |
| 270 | { |
| 271 | format_field_type_common(buf_ch, extended, prefix, |
| 272 | (void *) field_type); |
| 273 | } |
| 274 | |
| 275 | static inline void format_writer_field_type(char **buf_ch, bool extended, |
| 276 | const char *prefix, struct bt_ctf_field_type *field_type) |
| 277 | { |
| 278 | format_field_type_common(buf_ch, extended, prefix, |
| 279 | (void *) field_type); |
| 280 | } |
| 281 | |
| 282 | static inline void format_field_common_integer_extended(char **buf_ch, |
| 283 | const char *prefix, struct bt_field_common *field) |
| 284 | { |
| 285 | struct bt_field_common_integer *integer = BT_FROM_COMMON(field); |
| 286 | struct bt_field_type_common_integer *field_type = |
| 287 | BT_FROM_COMMON(field->type); |
| 288 | const char *fmt = NULL; |
| 289 | |
| 290 | BT_ASSERT(field_type); |
| 291 | |
| 292 | if (field_type->base == 8) { |
| 293 | fmt = ", %svalue=%" PRIo64; |
| 294 | } else if (field_type->base == 16) { |
| 295 | fmt = ", %svalue=%" PRIx64; |
| 296 | } |
| 297 | |
| 298 | if (field_type->is_signed) { |
| 299 | if (!fmt) { |
| 300 | fmt = ", %svalue=%" PRId64; |
| 301 | } |
| 302 | |
| 303 | BUF_APPEND(fmt, PRFIELD(integer->payload.signd)); |
| 304 | } else { |
| 305 | if (!fmt) { |
| 306 | fmt = ", %svalue=%" PRIu64; |
| 307 | } |
| 308 | |
| 309 | BUF_APPEND(fmt, PRFIELD(integer->payload.unsignd)); |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | static inline void format_field_common(char **buf_ch, bool extended, |
| 314 | const char *prefix, struct bt_field_common *field) |
| 315 | { |
| 316 | BUF_APPEND(", %sis-set=%d", PRFIELD(field->payload_set)); |
| 317 | |
| 318 | if (extended) { |
| 319 | BUF_APPEND(", %sis-frozen=%d", PRFIELD(field->frozen)); |
| 320 | } |
| 321 | |
| 322 | BUF_APPEND(", %stype-addr=%p", PRFIELD(field->type)); |
| 323 | |
| 324 | if (!field->type) { |
| 325 | return; |
| 326 | } |
| 327 | |
| 328 | BUF_APPEND(", %stype-id=%s", |
| 329 | PRFIELD(bt_common_field_type_id_string(field->type->id))); |
| 330 | |
| 331 | if (!extended || field->type->id == BT_FIELD_TYPE_ID_UNKNOWN || |
| 332 | !field->payload_set) { |
| 333 | return; |
| 334 | } |
| 335 | |
| 336 | switch (field->type->id) { |
| 337 | case BT_FIELD_TYPE_ID_INTEGER: |
| 338 | { |
| 339 | format_field_common_integer_extended(buf_ch, prefix, field); |
| 340 | break; |
| 341 | } |
| 342 | case BT_FIELD_TYPE_ID_FLOAT: |
| 343 | { |
| 344 | struct bt_field_common_floating_point *flt = |
| 345 | BT_FROM_COMMON(field); |
| 346 | |
| 347 | BUF_APPEND(", %svalue=%f", PRFIELD(flt->payload)); |
| 348 | break; |
| 349 | } |
| 350 | case BT_FIELD_TYPE_ID_STRING: |
| 351 | { |
| 352 | struct bt_field_common_string *str = |
| 353 | BT_FROM_COMMON(field); |
| 354 | |
| 355 | if (str->buf) { |
| 356 | BT_ASSERT(str->buf->data); |
| 357 | BUF_APPEND(", %spartial-value=\"%.32s\"", |
| 358 | PRFIELD(str->buf->data)); |
| 359 | |
| 360 | } |
| 361 | break; |
| 362 | } |
| 363 | case BT_FIELD_TYPE_ID_SEQUENCE: |
| 364 | { |
| 365 | struct bt_field_common_sequence *seq = |
| 366 | BT_FROM_COMMON(field); |
| 367 | |
| 368 | BUF_APPEND(", %slength=%" PRIu64, PRFIELD(seq->length)); |
| 369 | |
| 370 | if (seq->elements) { |
| 371 | BUF_APPEND(", %sallocated-length=%u", |
| 372 | PRFIELD(seq->elements->len)); |
| 373 | } |
| 374 | break; |
| 375 | } |
| 376 | case BT_FIELD_TYPE_ID_VARIANT: |
| 377 | { |
| 378 | struct bt_field_common_variant *variant = |
| 379 | BT_FROM_COMMON(field); |
| 380 | |
| 381 | BUF_APPEND(", %scur-field-addr=%p", |
| 382 | PRFIELD(variant->current_field)); |
| 383 | break; |
| 384 | } |
| 385 | default: |
| 386 | break; |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | static inline void format_field(char **buf_ch, bool extended, |
| 391 | const char *prefix, struct bt_field *field) |
| 392 | { |
| 393 | struct bt_field_common *common_field = (void *) field; |
| 394 | |
| 395 | format_field_common(buf_ch, extended, prefix, (void *) field); |
| 396 | |
| 397 | if (!extended) { |
| 398 | return; |
| 399 | } |
| 400 | |
| 401 | if (!common_field->type) { |
| 402 | return; |
| 403 | } |
| 404 | |
| 405 | switch (common_field->type->id) { |
| 406 | case BT_FIELD_TYPE_ID_ENUM: |
| 407 | { |
| 408 | struct bt_field_common_integer *integer = (void *) field; |
| 409 | struct bt_field_type_common_enumeration *enum_ft = |
| 410 | BT_FROM_COMMON(common_field->type); |
| 411 | |
| 412 | if (enum_ft->container_ft) { |
| 413 | if (enum_ft->container_ft->is_signed) { |
| 414 | BUF_APPEND(", %svalue=%" PRId64, |
| 415 | PRFIELD(integer->payload.signd)); |
| 416 | } else { |
| 417 | BUF_APPEND(", %svalue=%" PRIu64, |
| 418 | PRFIELD(integer->payload.unsignd)); |
| 419 | } |
| 420 | } |
| 421 | break; |
| 422 | } |
| 423 | default: |
| 424 | break; |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | static inline void format_writer_field(char **buf_ch, bool extended, |
| 429 | const char *prefix, struct bt_ctf_field *field) |
| 430 | { |
| 431 | struct bt_field_common *common_field = (void *) field; |
| 432 | |
| 433 | format_field_common(buf_ch, extended, prefix, (void *) field); |
| 434 | |
| 435 | if (!extended) { |
| 436 | return; |
| 437 | } |
| 438 | |
| 439 | if (!common_field->type) { |
| 440 | return; |
| 441 | } |
| 442 | |
| 443 | switch (common_field->type->id) { |
| 444 | case BT_FIELD_TYPE_ID_ENUM: |
| 445 | { |
| 446 | struct bt_ctf_field_enumeration *enumeration = (void *) field; |
| 447 | |
| 448 | if (enumeration->container) { |
| 449 | format_writer_field(buf_ch, extended, prefix, |
| 450 | (void *) enumeration->container); |
| 451 | } |
| 452 | break; |
| 453 | } |
| 454 | case BT_FIELD_TYPE_ID_VARIANT: |
| 455 | { |
| 456 | struct bt_ctf_field_variant *variant = (void *) field; |
| 457 | |
| 458 | BUF_APPEND(", %stag-field-addr=%p", PRFIELD(variant->tag)); |
| 459 | break; |
| 460 | } |
| 461 | default: |
| 462 | break; |
| 463 | } |
| 464 | } |
| 465 | |
| 466 | static inline void format_field_path(char **buf_ch, bool extended, |
| 467 | const char *prefix, struct bt_field_path *field_path) |
| 468 | { |
| 469 | uint64_t i; |
| 470 | |
| 471 | if (field_path->indexes) { |
| 472 | BT_ASSERT(field_path->indexes); |
| 473 | BUF_APPEND(", %sindex-count=%u", PRFIELD(field_path->indexes->len)); |
| 474 | } |
| 475 | |
| 476 | if (!extended || !field_path->indexes) { |
| 477 | return; |
| 478 | } |
| 479 | |
| 480 | BUF_APPEND(", %spath=[%s", PRFIELD(bt_common_scope_string(field_path->root))); |
| 481 | |
| 482 | for (i = 0; i < field_path->indexes->len; i++) { |
| 483 | int index = g_array_index(field_path->indexes, int, i); |
| 484 | |
| 485 | BUF_APPEND(", %d", index); |
| 486 | } |
| 487 | |
| 488 | BUF_APPEND("%s", "]"); |
| 489 | } |
| 490 | |
| 491 | static inline void format_trace_common(char **buf_ch, bool extended, |
| 492 | const char *prefix, struct bt_trace_common *trace) |
| 493 | { |
| 494 | if (trace->name) { |
| 495 | BUF_APPEND(", %sname=\"%s\"", PRFIELD(trace->name->str)); |
| 496 | } |
| 497 | |
| 498 | if (!extended) { |
| 499 | return; |
| 500 | } |
| 501 | |
| 502 | BUF_APPEND(", %sis-frozen=%d", PRFIELD(trace->frozen)); |
| 503 | |
| 504 | if (trace->uuid_set) { |
| 505 | BUF_APPEND_UUID(trace->uuid); |
| 506 | } |
| 507 | |
| 508 | if (trace->clock_classes) { |
| 509 | BUF_APPEND(", %sclock-class-count=%u", |
| 510 | PRFIELD(trace->clock_classes->len)); |
| 511 | } |
| 512 | |
| 513 | if (trace->stream_classes) { |
| 514 | BUF_APPEND(", %sstream-class-count=%u", |
| 515 | PRFIELD(trace->stream_classes->len)); |
| 516 | } |
| 517 | |
| 518 | if (trace->streams) { |
| 519 | BUF_APPEND(", %sstream-count=%u", |
| 520 | PRFIELD(trace->streams->len)); |
| 521 | } |
| 522 | |
| 523 | BUF_APPEND(", %spacket-header-ft-addr=%p", |
| 524 | PRFIELD(trace->packet_header_field_type)); |
| 525 | } |
| 526 | |
| 527 | static inline void format_trace(char **buf_ch, bool extended, |
| 528 | const char *prefix, struct bt_trace *trace) |
| 529 | { |
| 530 | char tmp_prefix[64]; |
| 531 | |
| 532 | format_trace_common(buf_ch, extended, prefix, BT_TO_COMMON(trace)); |
| 533 | |
| 534 | if (!extended) { |
| 535 | return; |
| 536 | } |
| 537 | |
| 538 | BUF_APPEND(", %sis-static=%d", PRFIELD(trace->is_static)); |
| 539 | SET_TMP_PREFIX("phf-pool-"); |
| 540 | format_object_pool(buf_ch, extended, prefix, |
| 541 | &trace->packet_header_field_pool); |
| 542 | } |
| 543 | |
| 544 | static inline void format_writer_trace(char **buf_ch, bool extended, |
| 545 | const char *prefix, struct bt_ctf_trace *trace) |
| 546 | { |
| 547 | format_trace_common(buf_ch, extended, prefix, BT_TO_COMMON(trace)); |
| 548 | } |
| 549 | |
| 550 | static inline void format_stream_class_common(char **buf_ch, bool extended, |
| 551 | const char *prefix, struct bt_stream_class_common *stream_class, |
| 552 | format_func trace_format_func) |
| 553 | { |
| 554 | struct bt_trace_common *trace; |
| 555 | char tmp_prefix[64]; |
| 556 | |
| 557 | if (stream_class->id_set) { |
| 558 | BUF_APPEND(", %sid=%" PRId64, PRFIELD(stream_class->id)); |
| 559 | } |
| 560 | |
| 561 | if (stream_class->name) { |
| 562 | BUF_APPEND(", %sname=\"%s\"", PRFIELD(stream_class->name->str)); |
| 563 | } |
| 564 | |
| 565 | if (!extended) { |
| 566 | return; |
| 567 | } |
| 568 | |
| 569 | BUF_APPEND(", %sis-frozen=%d", PRFIELD(stream_class->frozen)); |
| 570 | |
| 571 | if (stream_class->event_classes) { |
| 572 | BUF_APPEND(", %sevent-class-count=%u", |
| 573 | PRFIELD(stream_class->event_classes->len)); |
| 574 | } |
| 575 | |
| 576 | BUF_APPEND(", %spacket-context-ft-addr=%p, " |
| 577 | "%sevent-header-ft-addr=%p, %sevent-context-ft-addr=%p", |
| 578 | PRFIELD(stream_class->packet_context_field_type), |
| 579 | PRFIELD(stream_class->event_header_field_type), |
| 580 | PRFIELD(stream_class->event_context_field_type)); |
| 581 | trace = bt_stream_class_common_borrow_trace(stream_class); |
| 582 | if (!trace) { |
| 583 | return; |
| 584 | } |
| 585 | |
| 586 | BUF_APPEND(", %strace-addr=%p", PRFIELD(trace)); |
| 587 | SET_TMP_PREFIX("trace-"); |
| 588 | trace_format_func(buf_ch, false, tmp_prefix, trace); |
| 589 | } |
| 590 | |
| 591 | static inline void format_stream_class(char **buf_ch, bool extended, |
| 592 | const char *prefix, struct bt_stream_class *stream_class) |
| 593 | { |
| 594 | char tmp_prefix[64]; |
| 595 | |
| 596 | format_stream_class_common(buf_ch, extended, prefix, |
| 597 | BT_TO_COMMON(stream_class), (format_func) format_trace); |
| 598 | |
| 599 | if (!extended) { |
| 600 | return; |
| 601 | } |
| 602 | |
| 603 | SET_TMP_PREFIX("ehf-pool-"); |
| 604 | format_object_pool(buf_ch, extended, prefix, |
| 605 | &stream_class->event_header_field_pool); |
| 606 | SET_TMP_PREFIX("pcf-pool-"); |
| 607 | format_object_pool(buf_ch, extended, prefix, |
| 608 | &stream_class->packet_context_field_pool); |
| 609 | } |
| 610 | |
| 611 | static inline void format_writer_stream_class(char **buf_ch, bool extended, |
| 612 | const char *prefix, struct bt_ctf_stream_class *stream_class) |
| 613 | { |
| 614 | format_stream_class_common(buf_ch, extended, prefix, |
| 615 | BT_TO_COMMON(stream_class), (format_func) format_writer_trace); |
| 616 | |
| 617 | if (extended && stream_class->clock) { |
| 618 | BUF_APPEND(", %sctf-writer-clock-addr=%p, " |
| 619 | "%sctf-writer-clock-name=\"%s\"", |
| 620 | PRFIELD(stream_class->clock), |
| 621 | PRFIELD(bt_clock_class_get_name( |
| 622 | BT_TO_COMMON(stream_class->clock->clock_class)))); |
| 623 | } |
| 624 | } |
| 625 | |
| 626 | static inline void format_event_class_common(char **buf_ch, bool extended, |
| 627 | const char *prefix, struct bt_event_class_common *event_class, |
| 628 | format_func format_stream_class_func, |
| 629 | format_func format_trace_func) |
| 630 | { |
| 631 | struct bt_stream_class_common *stream_class; |
| 632 | struct bt_trace_common *trace; |
| 633 | char tmp_prefix[64]; |
| 634 | |
| 635 | BUF_APPEND(", %sid=%" PRId64, PRFIELD(event_class->id)); |
| 636 | |
| 637 | if (event_class->name) { |
| 638 | BUF_APPEND(", %sname=\"%s\"", PRFIELD(event_class->name->str)); |
| 639 | } |
| 640 | |
| 641 | if (!extended) { |
| 642 | return; |
| 643 | } |
| 644 | |
| 645 | BUF_APPEND(", %sis-frozen=%d, %slog-level=%s", |
| 646 | PRFIELD(event_class->frozen), |
| 647 | PRFIELD(bt_common_event_class_log_level_string(event_class->log_level))); |
| 648 | |
| 649 | if (event_class->emf_uri) { |
| 650 | BUF_APPEND(", %semf-uri=\"%s\"", |
| 651 | PRFIELD(event_class->emf_uri->str)); |
| 652 | } |
| 653 | |
| 654 | BUF_APPEND(", %scontext-ft-addr=%p, %spayload-ft-addr=%p", |
| 655 | PRFIELD(event_class->context_field_type), |
| 656 | PRFIELD(event_class->payload_field_type)); |
| 657 | |
| 658 | stream_class = bt_event_class_common_borrow_stream_class(event_class); |
| 659 | if (!stream_class) { |
| 660 | return; |
| 661 | } |
| 662 | |
| 663 | BUF_APPEND(", %sstream-class-addr=%p", PRFIELD(stream_class)); |
| 664 | SET_TMP_PREFIX("stream-class-"); |
| 665 | format_stream_class_func(buf_ch, false, tmp_prefix, stream_class); |
| 666 | trace = bt_stream_class_common_borrow_trace(stream_class); |
| 667 | if (!trace) { |
| 668 | return; |
| 669 | } |
| 670 | |
| 671 | BUF_APPEND(", %strace-addr=%p", PRFIELD(trace)); |
| 672 | SET_TMP_PREFIX("trace-"); |
| 673 | format_trace_func(buf_ch, false, tmp_prefix, trace); |
| 674 | } |
| 675 | |
| 676 | static inline void format_event_class(char **buf_ch, bool extended, |
| 677 | const char *prefix, struct bt_event_class *event_class) |
| 678 | { |
| 679 | char tmp_prefix[64]; |
| 680 | |
| 681 | format_event_class_common(buf_ch, extended, prefix, |
| 682 | BT_TO_COMMON(event_class), (format_func) format_stream_class, |
| 683 | (format_func) format_trace); |
| 684 | |
| 685 | if (!extended) { |
| 686 | return; |
| 687 | } |
| 688 | |
| 689 | SET_TMP_PREFIX("event-pool-"); |
| 690 | format_object_pool(buf_ch, extended, prefix, &event_class->event_pool); |
| 691 | } |
| 692 | |
| 693 | static inline void format_writer_event_class(char **buf_ch, bool extended, |
| 694 | const char *prefix, struct bt_ctf_event_class *event_class) |
| 695 | { |
| 696 | format_event_class_common(buf_ch, extended, prefix, |
| 697 | BT_TO_COMMON(event_class), |
| 698 | (format_func) format_writer_stream_class, |
| 699 | (format_func) format_writer_trace); |
| 700 | } |
| 701 | |
| 702 | static inline void format_stream_common(char **buf_ch, bool extended, |
| 703 | const char *prefix, struct bt_stream_common *stream, |
| 704 | format_func format_stream_class_func, |
| 705 | format_func format_trace_func) |
| 706 | { |
| 707 | struct bt_stream_class_common *stream_class; |
| 708 | struct bt_trace_common *trace; |
| 709 | char tmp_prefix[64]; |
| 710 | |
| 711 | BUF_APPEND(", %sid=%" PRId64, PRFIELD(stream->id)); |
| 712 | |
| 713 | if (stream->name) { |
| 714 | BUF_APPEND(", %sname=\"%s\"", PRFIELD(stream->name->str)); |
| 715 | } |
| 716 | |
| 717 | if (!extended) { |
| 718 | return; |
| 719 | } |
| 720 | |
| 721 | stream_class = bt_stream_common_borrow_class(stream); |
| 722 | if (!stream_class) { |
| 723 | return; |
| 724 | } |
| 725 | |
| 726 | BUF_APPEND(", %sstream-class-addr=%p", PRFIELD(stream_class)); |
| 727 | SET_TMP_PREFIX("stream-class-"); |
| 728 | format_stream_class_func(buf_ch, false, tmp_prefix, stream_class); |
| 729 | trace = bt_stream_class_common_borrow_trace(stream_class); |
| 730 | if (!trace) { |
| 731 | return; |
| 732 | } |
| 733 | |
| 734 | trace = (void *) bt_object_borrow_parent(&stream->base); |
| 735 | if (!trace) { |
| 736 | return; |
| 737 | } |
| 738 | |
| 739 | BUF_APPEND(", %strace-addr=%p", PRFIELD(trace)); |
| 740 | SET_TMP_PREFIX("trace-"); |
| 741 | format_trace_common(buf_ch, false, tmp_prefix, trace); |
| 742 | } |
| 743 | |
| 744 | static inline void format_stream(char **buf_ch, bool extended, |
| 745 | const char *prefix, struct bt_stream *stream) |
| 746 | { |
| 747 | char tmp_prefix[64]; |
| 748 | |
| 749 | format_stream_common(buf_ch, extended, prefix, BT_TO_COMMON(stream), |
| 750 | (format_func) format_stream_class, |
| 751 | (format_func) format_trace); |
| 752 | SET_TMP_PREFIX("packet-pool-"); |
| 753 | format_object_pool(buf_ch, extended, prefix, &stream->packet_pool); |
| 754 | } |
| 755 | |
| 756 | static inline void format_writer_stream(char **buf_ch, bool extended, |
| 757 | const char *prefix, struct bt_ctf_stream *stream) |
| 758 | { |
| 759 | format_stream_common(buf_ch, extended, prefix, BT_TO_COMMON(stream), |
| 760 | (format_func) format_writer_stream_class, |
| 761 | (format_func) format_writer_trace); |
| 762 | |
| 763 | BUF_APPEND(", %sheader-field-addr=%p, %scontext-field-addr=%p" |
| 764 | ", %sfd=%d, %smmap-offset=%zu, " |
| 765 | "%smmap-base-offset=%zu, %spacket-size=%" PRIu64 ", " |
| 766 | "%soffset=%" PRId64 ", %sevent-count=%u, " |
| 767 | "%sflushed-packet-count=%u, " |
| 768 | "%sdiscarded-event-count=%" PRIu64 ", " |
| 769 | "%ssize=%" PRIu64 ", %slast-ts-end=%" PRIu64, |
| 770 | PRFIELD(stream->packet_header), |
| 771 | PRFIELD(stream->packet_context), |
| 772 | PRFIELD(stream->pos.fd), |
| 773 | PRFIELD((size_t) stream->pos.mmap_offset), |
| 774 | PRFIELD((size_t) stream->pos.mmap_base_offset), |
| 775 | PRFIELD(stream->pos.packet_size), |
| 776 | PRFIELD(stream->pos.offset), |
| 777 | PRFIELD(stream->events->len), |
| 778 | PRFIELD(stream->flushed_packet_count), |
| 779 | PRFIELD(stream->discarded_events), |
| 780 | PRFIELD(stream->size), PRFIELD(stream->last_ts_end)); |
| 781 | |
| 782 | if (stream->events) { |
| 783 | BUF_APPEND(", %sevent-count=%u", PRFIELD(stream->events->len)); |
| 784 | } |
| 785 | |
| 786 | BUF_APPEND(", %sheader-field-addr=%p, %scontext-field-addr=%p" |
| 787 | ", %sfd=%d, %smmap-offset=%zu, " |
| 788 | "%smmap-base-offset=%zu, %spacket-size=%" PRIu64 ", " |
| 789 | "%soffset=%" PRId64 ", " |
| 790 | "%sflushed-packet-count=%u, " |
| 791 | "%sdiscarded-event-count=%" PRIu64 ", " |
| 792 | "%ssize=%" PRIu64 ", %slast-ts-end=%" PRIu64, |
| 793 | PRFIELD(stream->packet_header), |
| 794 | PRFIELD(stream->packet_context), |
| 795 | PRFIELD(stream->pos.fd), |
| 796 | PRFIELD((size_t) stream->pos.mmap_offset), |
| 797 | PRFIELD((size_t) stream->pos.mmap_base_offset), |
| 798 | PRFIELD(stream->pos.packet_size), |
| 799 | PRFIELD(stream->pos.offset), |
| 800 | PRFIELD(stream->flushed_packet_count), |
| 801 | PRFIELD(stream->discarded_events), |
| 802 | PRFIELD(stream->size), PRFIELD(stream->last_ts_end)); |
| 803 | } |
| 804 | |
| 805 | static inline void format_packet(char **buf_ch, bool extended, |
| 806 | const char *prefix, struct bt_packet *packet) |
| 807 | { |
| 808 | struct bt_stream *stream; |
| 809 | struct bt_trace *trace; |
| 810 | char tmp_prefix[64]; |
| 811 | |
| 812 | if (!extended) { |
| 813 | return; |
| 814 | } |
| 815 | |
| 816 | BUF_APPEND(", %sis-frozen=%d, %sheader-field-addr=%p, " |
| 817 | "%scontext-field-addr=%p", |
| 818 | PRFIELD(packet->frozen), |
| 819 | PRFIELD(packet->header ? packet->header->field : NULL), |
| 820 | PRFIELD(packet->context)); |
| 821 | stream = bt_packet_borrow_stream(packet); |
| 822 | if (!stream) { |
| 823 | return; |
| 824 | } |
| 825 | |
| 826 | BUF_APPEND(", %sstream-addr=%p", PRFIELD(stream)); |
| 827 | SET_TMP_PREFIX("stream-"); |
| 828 | format_stream(buf_ch, false, tmp_prefix, stream); |
| 829 | trace = (struct bt_trace *) bt_object_borrow_parent(&stream->common.base); |
| 830 | if (!trace) { |
| 831 | return; |
| 832 | } |
| 833 | |
| 834 | BUF_APPEND(", %strace-addr=%p", PRFIELD(trace)); |
| 835 | SET_TMP_PREFIX("trace-"); |
| 836 | format_trace(buf_ch, false, tmp_prefix, trace); |
| 837 | } |
| 838 | |
| 839 | static inline void format_event_common(char **buf_ch, bool extended, |
| 840 | const char *prefix, struct bt_event_common *event, |
| 841 | format_func format_event_class_func, |
| 842 | format_func format_stream_class_func, |
| 843 | format_func format_trace_func) |
| 844 | { |
| 845 | struct bt_trace_common *trace; |
| 846 | struct bt_stream_class_common *stream_class; |
| 847 | char tmp_prefix[64]; |
| 848 | |
| 849 | if (!extended) { |
| 850 | return; |
| 851 | } |
| 852 | |
| 853 | BUF_APPEND(", %sis-frozen=%d, %sheader-field-addr=%p, " |
| 854 | "%sstream-context-field-addr=%p, " |
| 855 | "%scontext-field-addr=%p, %spayload-field-addr=%p, ", |
| 856 | PRFIELD(event->frozen), |
| 857 | PRFIELD(event->header_field ? event->header_field->field : NULL), |
| 858 | PRFIELD(event->stream_event_context_field), |
| 859 | PRFIELD(event->context_field), |
| 860 | PRFIELD(event->payload_field)); |
| 861 | BUF_APPEND(", %sevent-class-addr=%p", PRFIELD(event->class)); |
| 862 | |
| 863 | if (!event->class) { |
| 864 | return; |
| 865 | } |
| 866 | |
| 867 | SET_TMP_PREFIX("event-class-"); |
| 868 | format_event_class_func(buf_ch, false, tmp_prefix, event->class); |
| 869 | stream_class = bt_event_class_common_borrow_stream_class(event->class); |
| 870 | if (stream_class) { |
| 871 | BUF_APPEND(", %sstream-class-addr=%p", PRFIELD(stream_class)); |
| 872 | SET_TMP_PREFIX("stream-class-"); |
| 873 | format_stream_class_func(buf_ch, false, tmp_prefix, |
| 874 | stream_class); |
| 875 | |
| 876 | trace = bt_stream_class_common_borrow_trace(stream_class); |
| 877 | if (trace) { |
| 878 | BUF_APPEND(", %strace-addr=%p", PRFIELD(trace)); |
| 879 | SET_TMP_PREFIX("trace-"); |
| 880 | format_trace_func(buf_ch, false, tmp_prefix, trace); |
| 881 | } |
| 882 | } |
| 883 | } |
| 884 | |
| 885 | static inline void format_event(char **buf_ch, bool extended, |
| 886 | const char *prefix, struct bt_event *event) |
| 887 | { |
| 888 | struct bt_packet *packet; |
| 889 | struct bt_stream *stream; |
| 890 | char tmp_prefix[64]; |
| 891 | |
| 892 | format_event_common(buf_ch, extended, prefix, BT_TO_COMMON(event), |
| 893 | (format_func) format_event_class, |
| 894 | (format_func) format_stream_class, (format_func) format_trace); |
| 895 | |
| 896 | if (!extended) { |
| 897 | return; |
| 898 | } |
| 899 | |
| 900 | SET_TMP_PREFIX("cvs-"); |
| 901 | format_clock_value_set(buf_ch, extended, tmp_prefix, &event->cv_set); |
| 902 | packet = bt_event_borrow_packet(event); |
| 903 | if (!packet) { |
| 904 | return; |
| 905 | } |
| 906 | |
| 907 | BUF_APPEND(", %spacket-addr=%p", PRFIELD(packet)); |
| 908 | SET_TMP_PREFIX("packet-"); |
| 909 | format_packet(buf_ch, false, tmp_prefix, packet); |
| 910 | stream = bt_packet_borrow_stream(packet); |
| 911 | if (!stream) { |
| 912 | return; |
| 913 | } |
| 914 | |
| 915 | BUF_APPEND(", %sstream-addr=%p", PRFIELD(stream)); |
| 916 | SET_TMP_PREFIX("stream-"); |
| 917 | format_stream(buf_ch, false, tmp_prefix, stream); |
| 918 | } |
| 919 | |
| 920 | static inline void format_writer_event(char **buf_ch, bool extended, |
| 921 | const char *prefix, struct bt_event *event) |
| 922 | { |
| 923 | format_event_common(buf_ch, extended, prefix, BT_TO_COMMON(event), |
| 924 | (format_func) format_writer_event_class, |
| 925 | (format_func) format_writer_stream_class, |
| 926 | (format_func) format_writer_trace); |
| 927 | } |
| 928 | |
| 929 | static inline void format_clock_class(char **buf_ch, bool extended, |
| 930 | const char *prefix, struct bt_clock_class *clock_class) |
| 931 | { |
| 932 | char tmp_prefix[64]; |
| 933 | |
| 934 | BUF_APPEND(", %sname=\"%s\", %sfreq=%" PRIu64, |
| 935 | PRFIELD(clock_class->name->str), |
| 936 | PRFIELD(clock_class->frequency)); |
| 937 | |
| 938 | if (!extended) { |
| 939 | return; |
| 940 | } |
| 941 | |
| 942 | if (clock_class->description) { |
| 943 | BUF_APPEND(", %spartial-description=\"%.32s\"", |
| 944 | PRFIELD(clock_class->description->str)); |
| 945 | } |
| 946 | |
| 947 | BUF_APPEND(", %sis-frozen=%d, %sprecision=%" PRIu64 ", " |
| 948 | "%soffset-s=%" PRId64 ", " |
| 949 | "%soffset-cycles=%" PRId64 ", %sis-absolute=%d", |
| 950 | PRFIELD(clock_class->frozen), PRFIELD(clock_class->precision), |
| 951 | PRFIELD(clock_class->offset_s), PRFIELD(clock_class->offset), |
| 952 | PRFIELD(clock_class->absolute)); |
| 953 | |
| 954 | if (clock_class->uuid_set) { |
| 955 | BUF_APPEND_UUID(clock_class->uuid); |
| 956 | } |
| 957 | |
| 958 | SET_TMP_PREFIX("cv-pool-"); |
| 959 | format_object_pool(buf_ch, extended, prefix, &clock_class->cv_pool); |
| 960 | } |
| 961 | |
| 962 | static inline void format_clock_value(char **buf_ch, bool extended, |
| 963 | const char *prefix, struct bt_clock_value *clock_value) |
| 964 | { |
| 965 | char tmp_prefix[64]; |
| 966 | BUF_APPEND(", %sraw-value=%" PRIu64 ", %sns-from-epoch=%" PRId64, |
| 967 | PRFIELD(clock_value->value), |
| 968 | PRFIELD(clock_value->ns_from_epoch)); |
| 969 | |
| 970 | if (!extended) { |
| 971 | return; |
| 972 | } |
| 973 | |
| 974 | BUF_APPEND(", %sis-frozen=%d, %sis-set=%d", |
| 975 | PRFIELD(clock_value->frozen), PRFIELD(clock_value->is_set)); |
| 976 | BUF_APPEND(", %sclock-class-addr=%p", |
| 977 | PRFIELD(clock_value->clock_class)); |
| 978 | SET_TMP_PREFIX("clock-class-"); |
| 979 | format_clock_class(buf_ch, false, tmp_prefix, clock_value->clock_class); |
| 980 | } |
| 981 | |
| 982 | static inline void format_value(char **buf_ch, bool extended, |
| 983 | const char *prefix, struct bt_value *value) |
| 984 | { |
| 985 | BUF_APPEND(", %stype=%s", |
| 986 | PRFIELD(bt_value_type_string(bt_value_get_type(value)))); |
| 987 | |
| 988 | if (!extended) { |
| 989 | return; |
| 990 | } |
| 991 | |
| 992 | switch (bt_value_get_type(value)) { |
| 993 | case BT_VALUE_TYPE_BOOL: |
| 994 | { |
| 995 | bt_bool val; |
| 996 | |
| 997 | (void) bt_value_bool_get(value, &val); |
| 998 | BUF_APPEND(", %svalue=%d", PRFIELD(val)); |
| 999 | break; |
| 1000 | } |
| 1001 | case BT_VALUE_TYPE_INTEGER: |
| 1002 | { |
| 1003 | int64_t val; |
| 1004 | |
| 1005 | (void) bt_value_integer_get(value, &val); |
| 1006 | BUF_APPEND(", %svalue=%" PRId64, PRFIELD(val)); |
| 1007 | break; |
| 1008 | } |
| 1009 | case BT_VALUE_TYPE_FLOAT: |
| 1010 | { |
| 1011 | double val; |
| 1012 | |
| 1013 | (void) bt_value_float_get(value, &val); |
| 1014 | BUF_APPEND(", %svalue=%f", PRFIELD(val)); |
| 1015 | break; |
| 1016 | } |
| 1017 | case BT_VALUE_TYPE_STRING: |
| 1018 | { |
| 1019 | const char *val; |
| 1020 | |
| 1021 | (void) bt_value_string_get(value, &val); |
| 1022 | BUF_APPEND(", %spartial-value=\"%.32s\"", PRFIELD(val)); |
| 1023 | break; |
| 1024 | } |
| 1025 | case BT_VALUE_TYPE_ARRAY: |
| 1026 | { |
| 1027 | int64_t count = bt_value_array_size(value); |
| 1028 | |
| 1029 | BT_ASSERT(count >= 0); |
| 1030 | BUF_APPEND(", %selement-count=%" PRId64, PRFIELD(count)); |
| 1031 | break; |
| 1032 | } |
| 1033 | case BT_VALUE_TYPE_MAP: |
| 1034 | { |
| 1035 | int64_t count = bt_value_map_size(value); |
| 1036 | |
| 1037 | BT_ASSERT(count >= 0); |
| 1038 | BUF_APPEND(", %selement-count=%" PRId64, PRFIELD(count)); |
| 1039 | break; |
| 1040 | } |
| 1041 | default: |
| 1042 | break; |
| 1043 | } |
| 1044 | } |
| 1045 | |
| 1046 | static inline void format_notification(char **buf_ch, bool extended, |
| 1047 | const char *prefix, struct bt_notification *notif) |
| 1048 | { |
| 1049 | char tmp_prefix[64]; |
| 1050 | |
| 1051 | BUF_APPEND(", %stype=%s", |
| 1052 | PRFIELD(bt_notification_type_string(notif->type))); |
| 1053 | |
| 1054 | if (!extended) { |
| 1055 | return; |
| 1056 | } |
| 1057 | |
| 1058 | BUF_APPEND(", %sis-frozen=%d, %sgraph-addr=%p", |
| 1059 | PRFIELD(notif->frozen), PRFIELD(notif->graph)); |
| 1060 | |
| 1061 | switch (notif->type) { |
| 1062 | case BT_NOTIFICATION_TYPE_EVENT: |
| 1063 | { |
| 1064 | struct bt_notification_event *notif_event = (void *) notif; |
| 1065 | |
| 1066 | SET_TMP_PREFIX("event-"); |
| 1067 | format_event(buf_ch, true, tmp_prefix, notif_event->event); |
| 1068 | break; |
| 1069 | } |
| 1070 | case BT_NOTIFICATION_TYPE_STREAM_BEGIN: |
| 1071 | { |
| 1072 | struct bt_notification_stream_begin *notif_stream = |
| 1073 | (void *) notif; |
| 1074 | |
| 1075 | SET_TMP_PREFIX("stream-"); |
| 1076 | format_stream(buf_ch, true, tmp_prefix, notif_stream->stream); |
| 1077 | break; |
| 1078 | } |
| 1079 | case BT_NOTIFICATION_TYPE_STREAM_END: |
| 1080 | { |
| 1081 | struct bt_notification_stream_end *notif_stream = |
| 1082 | (void *) notif; |
| 1083 | |
| 1084 | SET_TMP_PREFIX("stream-"); |
| 1085 | format_stream(buf_ch, true, tmp_prefix, notif_stream->stream); |
| 1086 | break; |
| 1087 | } |
| 1088 | case BT_NOTIFICATION_TYPE_PACKET_BEGIN: |
| 1089 | { |
| 1090 | struct bt_notification_packet_begin *notif_packet = |
| 1091 | (void *) notif; |
| 1092 | |
| 1093 | SET_TMP_PREFIX("packet-"); |
| 1094 | format_packet(buf_ch, true, tmp_prefix, notif_packet->packet); |
| 1095 | break; |
| 1096 | } |
| 1097 | case BT_NOTIFICATION_TYPE_PACKET_END: |
| 1098 | { |
| 1099 | struct bt_notification_packet_end *notif_packet = |
| 1100 | (void *) notif; |
| 1101 | |
| 1102 | SET_TMP_PREFIX("packet-"); |
| 1103 | format_packet(buf_ch, true, tmp_prefix, notif_packet->packet); |
| 1104 | break; |
| 1105 | } |
| 1106 | default: |
| 1107 | break; |
| 1108 | } |
| 1109 | } |
| 1110 | |
| 1111 | static inline void format_plugin_so_shared_lib_handle(char **buf_ch, |
| 1112 | const char *prefix, |
| 1113 | struct bt_plugin_so_shared_lib_handle *handle) |
| 1114 | { |
| 1115 | BUF_APPEND(", %saddr=%p", PRFIELD(handle)); |
| 1116 | |
| 1117 | if (handle->path) { |
| 1118 | BUF_APPEND(", %spath=\"%s\"", PRFIELD(handle->path->str)); |
| 1119 | } |
| 1120 | } |
| 1121 | |
| 1122 | static inline void format_component_class(char **buf_ch, bool extended, |
| 1123 | const char *prefix, struct bt_component_class *comp_class) |
| 1124 | { |
| 1125 | char tmp_prefix[64]; |
| 1126 | |
| 1127 | BUF_APPEND(", %stype=%s, %sname=\"%s\"", |
| 1128 | PRFIELD(bt_component_class_type_string(comp_class->type)), |
| 1129 | PRFIELD(comp_class->name ? comp_class->name->str : NULL)); |
| 1130 | |
| 1131 | if (comp_class->description) { |
| 1132 | BUF_APPEND(", %spartial-descr=\"%.32s\"", |
| 1133 | PRFIELD(comp_class->description->str)); |
| 1134 | } |
| 1135 | |
| 1136 | if (!extended) { |
| 1137 | return; |
| 1138 | } |
| 1139 | |
| 1140 | BUF_APPEND(", %sis-frozen=%d", PRFIELD(comp_class->frozen)); |
| 1141 | |
| 1142 | if (comp_class->so_handle) { |
| 1143 | SET_TMP_PREFIX("so-handle-"); |
| 1144 | format_plugin_so_shared_lib_handle(buf_ch, tmp_prefix, |
| 1145 | comp_class->so_handle); |
| 1146 | } |
| 1147 | } |
| 1148 | |
| 1149 | static inline void format_component(char **buf_ch, bool extended, |
| 1150 | const char *prefix, struct bt_component *component) |
| 1151 | { |
| 1152 | char tmp_prefix[64]; |
| 1153 | |
| 1154 | BUF_APPEND(", %sname=\"%s\"", PRFIELD(component->name->str)); |
| 1155 | SET_TMP_PREFIX("class-"); |
| 1156 | format_component_class(buf_ch, extended, tmp_prefix, component->class); |
| 1157 | |
| 1158 | if (!extended) { |
| 1159 | return; |
| 1160 | } |
| 1161 | |
| 1162 | if (component->input_ports) { |
| 1163 | BUF_APPEND(", %sinput-port-count=%u", |
| 1164 | PRFIELD(component->input_ports->len)); |
| 1165 | } |
| 1166 | |
| 1167 | if (component->output_ports) { |
| 1168 | BUF_APPEND(", %soutput-port-count=%u", |
| 1169 | PRFIELD(component->output_ports->len)); |
| 1170 | } |
| 1171 | } |
| 1172 | |
| 1173 | static inline void format_port(char **buf_ch, bool extended, |
| 1174 | const char *prefix, struct bt_port *port) |
| 1175 | { |
| 1176 | char tmp_prefix[64]; |
| 1177 | |
| 1178 | BUF_APPEND(", %stype=%s, %sname=\"%s\"", |
| 1179 | PRFIELD(bt_port_type_string(port->type)), |
| 1180 | PRFIELD(port->name->str)); |
| 1181 | |
| 1182 | if (!extended) { |
| 1183 | return; |
| 1184 | } |
| 1185 | |
| 1186 | if (port->connection) { |
| 1187 | SET_TMP_PREFIX("conn-"); |
| 1188 | format_connection(buf_ch, false, tmp_prefix, port->connection); |
| 1189 | } |
| 1190 | } |
| 1191 | |
| 1192 | static inline void format_connection(char **buf_ch, bool extended, |
| 1193 | const char *prefix, struct bt_connection *connection) |
| 1194 | { |
| 1195 | char tmp_prefix[64]; |
| 1196 | |
| 1197 | if (!extended) { |
| 1198 | return; |
| 1199 | } |
| 1200 | |
| 1201 | if (connection->upstream_port) { |
| 1202 | SET_TMP_PREFIX("upstream-port-"); |
| 1203 | format_port(buf_ch, false, tmp_prefix, |
| 1204 | connection->upstream_port); |
| 1205 | } |
| 1206 | |
| 1207 | if (connection->downstream_port) { |
| 1208 | SET_TMP_PREFIX("downstream-port-"); |
| 1209 | format_port(buf_ch, false, tmp_prefix, |
| 1210 | connection->downstream_port); |
| 1211 | } |
| 1212 | } |
| 1213 | |
| 1214 | static inline void format_graph(char **buf_ch, bool extended, |
| 1215 | const char *prefix, struct bt_graph *graph) |
| 1216 | { |
| 1217 | char tmp_prefix[64]; |
| 1218 | |
| 1219 | BUF_APPEND(", %sis-canceled=%d", PRFIELD(graph->canceled)); |
| 1220 | |
| 1221 | if (!extended) { |
| 1222 | return; |
| 1223 | } |
| 1224 | |
| 1225 | if (graph->components) { |
| 1226 | BUF_APPEND(", %scomp-count=%u", |
| 1227 | PRFIELD(graph->components->len)); |
| 1228 | } |
| 1229 | |
| 1230 | if (graph->connections) { |
| 1231 | BUF_APPEND(", %sconn-count=%u", |
| 1232 | PRFIELD(graph->connections->len)); |
| 1233 | } |
| 1234 | |
| 1235 | SET_TMP_PREFIX("en-pool-"); |
| 1236 | format_object_pool(buf_ch, extended, prefix, |
| 1237 | &graph->event_notif_pool); |
| 1238 | SET_TMP_PREFIX("pbn-pool-"); |
| 1239 | format_object_pool(buf_ch, extended, prefix, |
| 1240 | &graph->packet_begin_notif_pool); |
| 1241 | SET_TMP_PREFIX("pen-pool-"); |
| 1242 | format_object_pool(buf_ch, extended, prefix, |
| 1243 | &graph->packet_end_notif_pool); |
| 1244 | } |
| 1245 | |
| 1246 | static inline void format_notification_iterator(char **buf_ch, |
| 1247 | bool extended, const char *prefix, |
| 1248 | struct bt_notification_iterator *iterator) |
| 1249 | { |
| 1250 | const char *type; |
| 1251 | char tmp_prefix[64]; |
| 1252 | |
| 1253 | if (iterator->type == BT_NOTIFICATION_ITERATOR_TYPE_PRIVATE_CONNECTION) { |
| 1254 | type = "BT_NOTIFICATION_ITERATOR_TYPE_PRIVATE_CONNECTION"; |
| 1255 | } else if (iterator->type == BT_NOTIFICATION_ITERATOR_TYPE_OUTPUT_PORT) { |
| 1256 | type = "BT_NOTIFICATION_ITERATOR_TYPE_OUTPUT_PORT"; |
| 1257 | } else { |
| 1258 | type = "(unknown)"; |
| 1259 | } |
| 1260 | |
| 1261 | BUF_APPEND(", %stype=%s", PRFIELD(type)); |
| 1262 | |
| 1263 | switch (iterator->type) { |
| 1264 | case BT_NOTIFICATION_ITERATOR_TYPE_PRIVATE_CONNECTION: |
| 1265 | { |
| 1266 | struct bt_notification_iterator_private_connection * |
| 1267 | iter_priv_conn = (void *) iterator; |
| 1268 | |
| 1269 | if (iter_priv_conn->upstream_component) { |
| 1270 | SET_TMP_PREFIX("upstream-comp-"); |
| 1271 | format_component(buf_ch, false, tmp_prefix, |
| 1272 | iter_priv_conn->upstream_component); |
| 1273 | } |
| 1274 | |
| 1275 | if (iter_priv_conn->upstream_port) { |
| 1276 | SET_TMP_PREFIX("upstream-port-"); |
| 1277 | format_port(buf_ch, false, tmp_prefix, |
| 1278 | iter_priv_conn->upstream_port); |
| 1279 | } |
| 1280 | |
| 1281 | if (iter_priv_conn->connection) { |
| 1282 | SET_TMP_PREFIX("upstream-conn-"); |
| 1283 | format_connection(buf_ch, false, tmp_prefix, |
| 1284 | iter_priv_conn->connection); |
| 1285 | } |
| 1286 | break; |
| 1287 | } |
| 1288 | case BT_NOTIFICATION_ITERATOR_TYPE_OUTPUT_PORT: |
| 1289 | { |
| 1290 | struct bt_notification_iterator_output_port *iter_output_port = |
| 1291 | (void *) iterator; |
| 1292 | |
| 1293 | SET_TMP_PREFIX("graph-"); |
| 1294 | format_graph(buf_ch, false, tmp_prefix, |
| 1295 | iter_output_port->graph); |
| 1296 | SET_TMP_PREFIX("colander-comp-"); |
| 1297 | format_component(buf_ch, false, tmp_prefix, |
| 1298 | iter_output_port->colander); |
| 1299 | break; |
| 1300 | } |
| 1301 | default: |
| 1302 | break; |
| 1303 | } |
| 1304 | } |
| 1305 | |
| 1306 | static inline void format_plugin(char **buf_ch, bool extended, |
| 1307 | const char *prefix, struct bt_plugin *plugin) |
| 1308 | { |
| 1309 | char tmp_prefix[64]; |
| 1310 | |
| 1311 | BUF_APPEND(", %stype=%s", PRFIELD(bt_plugin_type_string(plugin->type))); |
| 1312 | |
| 1313 | if (plugin->info.path_set) { |
| 1314 | BUF_APPEND(", %spath=\"%s\"", |
| 1315 | PRFIELD(plugin->info.path->str)); |
| 1316 | } |
| 1317 | |
| 1318 | if (plugin->info.name_set) { |
| 1319 | BUF_APPEND(", %sname=\"%s\"", |
| 1320 | PRFIELD(plugin->info.name->str)); |
| 1321 | } |
| 1322 | |
| 1323 | if (!extended) { |
| 1324 | return; |
| 1325 | } |
| 1326 | |
| 1327 | if (plugin->info.author_set) { |
| 1328 | BUF_APPEND(", %sauthor=\"%s\"", |
| 1329 | PRFIELD(plugin->info.author->str)); |
| 1330 | } |
| 1331 | |
| 1332 | if (plugin->info.license_set) { |
| 1333 | BUF_APPEND(", %slicense=\"%s\"", |
| 1334 | PRFIELD(plugin->info.license->str)); |
| 1335 | } |
| 1336 | |
| 1337 | if (plugin->info.version_set) { |
| 1338 | BUF_APPEND(", %sversion=%u.%u.%u%s", |
| 1339 | PRFIELD(plugin->info.version.major), |
| 1340 | plugin->info.version.minor, |
| 1341 | plugin->info.version.patch, |
| 1342 | plugin->info.version.extra ? |
| 1343 | plugin->info.version.extra->str : ""); |
| 1344 | } |
| 1345 | |
| 1346 | BUF_APPEND(", %sis-frozen=%d, %scomp-class-count=%u", |
| 1347 | PRFIELD(plugin->frozen), |
| 1348 | PRFIELD(plugin->comp_classes->len)); |
| 1349 | |
| 1350 | if (plugin->spec_data) { |
| 1351 | struct bt_plugin_so_spec_data *spec_data = |
| 1352 | (void *) plugin->spec_data; |
| 1353 | |
| 1354 | if (spec_data->shared_lib_handle) { |
| 1355 | SET_TMP_PREFIX("so-handle-"); |
| 1356 | format_plugin_so_shared_lib_handle(buf_ch, tmp_prefix, |
| 1357 | spec_data->shared_lib_handle); |
| 1358 | } |
| 1359 | } |
| 1360 | } |
| 1361 | |
| 1362 | static inline void format_ctf_writer(char **buf_ch, bool extended, |
| 1363 | const char *prefix, struct bt_ctf_writer *writer) |
| 1364 | { |
| 1365 | /* TODO */ |
| 1366 | } |
| 1367 | |
| 1368 | static inline void format_stream_class_common_common(char **buf_ch, |
| 1369 | bool extended, const char *prefix, |
| 1370 | struct bt_stream_class_common *stream_class) |
| 1371 | { |
| 1372 | format_stream_class_common(buf_ch, extended, prefix, stream_class, |
| 1373 | (format_func) format_trace_common); |
| 1374 | } |
| 1375 | |
| 1376 | static inline void format_event_class_common_common(char **buf_ch, |
| 1377 | bool extended, const char *prefix, |
| 1378 | struct bt_event_class_common *event_class) |
| 1379 | { |
| 1380 | format_event_class_common(buf_ch, extended, prefix, event_class, |
| 1381 | (format_func) format_stream_class_common, |
| 1382 | (format_func) format_trace_common); |
| 1383 | } |
| 1384 | |
| 1385 | static inline void format_event_common_common(char **buf_ch, |
| 1386 | bool extended, const char *prefix, |
| 1387 | struct bt_event_common *event) |
| 1388 | { |
| 1389 | format_event_common(buf_ch, extended, prefix, event, |
| 1390 | (format_func) format_event_class_common, |
| 1391 | (format_func) format_stream_class_common, |
| 1392 | (format_func) format_trace_common); |
| 1393 | } |
| 1394 | |
| 1395 | static inline void format_stream_common_common(char **buf_ch, bool extended, |
| 1396 | const char *prefix, struct bt_stream_common *stream) |
| 1397 | { |
| 1398 | format_stream_common(buf_ch, extended, prefix, stream, |
| 1399 | (format_func) format_stream_class_common, |
| 1400 | (format_func) format_trace_common); |
| 1401 | } |
| 1402 | |
| 1403 | static inline void handle_conversion_specifier_bt(void *priv_data, |
| 1404 | char **buf_ch, size_t avail_size, |
| 1405 | const char **out_fmt_ch, va_list *args) |
| 1406 | { |
| 1407 | const char *fmt_ch = *out_fmt_ch; |
| 1408 | bool extended = false; |
| 1409 | char prefix[64]; |
| 1410 | char *prefix_ch = prefix; |
| 1411 | void *obj; |
| 1412 | enum { |
| 1413 | CAT_DEFAULT, |
| 1414 | CAT_WRITER, |
| 1415 | CAT_COMMON, |
| 1416 | } cat = CAT_DEFAULT; |
| 1417 | |
| 1418 | /* skip "%!" */ |
| 1419 | fmt_ch += 2; |
| 1420 | |
| 1421 | if (*fmt_ch == '[') { |
| 1422 | /* local prefix */ |
| 1423 | fmt_ch++; |
| 1424 | |
| 1425 | while (true) { |
| 1426 | if (*fmt_ch == ']') { |
| 1427 | *prefix_ch = '\0'; |
| 1428 | fmt_ch++; |
| 1429 | break; |
| 1430 | } |
| 1431 | |
| 1432 | *prefix_ch = *fmt_ch; |
| 1433 | prefix_ch++; |
| 1434 | fmt_ch++; |
| 1435 | } |
| 1436 | } |
| 1437 | |
| 1438 | *prefix_ch = '\0'; |
| 1439 | |
| 1440 | if (*fmt_ch == '+') { |
| 1441 | extended = true; |
| 1442 | fmt_ch++; |
| 1443 | } |
| 1444 | |
| 1445 | if (*fmt_ch == 'w') { |
| 1446 | cat = CAT_WRITER; |
| 1447 | fmt_ch++; |
| 1448 | } else if (*fmt_ch == '_') { |
| 1449 | cat = CAT_COMMON; |
| 1450 | fmt_ch++; |
| 1451 | } |
| 1452 | |
| 1453 | obj = va_arg(*args, void *); |
| 1454 | BUF_APPEND("%saddr=%p", prefix, obj); |
| 1455 | |
| 1456 | if (!obj) { |
| 1457 | goto update_fmt; |
| 1458 | } |
| 1459 | |
| 1460 | switch (cat) { |
| 1461 | case CAT_DEFAULT: |
| 1462 | switch (*fmt_ch) { |
| 1463 | case 'F': |
| 1464 | format_field_type(buf_ch, extended, prefix, obj); |
| 1465 | break; |
| 1466 | case 'f': |
| 1467 | format_field(buf_ch, extended, prefix, obj); |
| 1468 | break; |
| 1469 | case 'P': |
| 1470 | format_field_path(buf_ch, extended, prefix, obj); |
| 1471 | break; |
| 1472 | case 'E': |
| 1473 | format_event_class(buf_ch, extended, prefix, obj); |
| 1474 | break; |
| 1475 | case 'e': |
| 1476 | format_event(buf_ch, extended, prefix, obj); |
| 1477 | break; |
| 1478 | case 'S': |
| 1479 | format_stream_class(buf_ch, extended, prefix, obj); |
| 1480 | break; |
| 1481 | case 's': |
| 1482 | format_stream(buf_ch, extended, prefix, obj); |
| 1483 | break; |
| 1484 | case 'a': |
| 1485 | format_packet(buf_ch, extended, prefix, obj); |
| 1486 | break; |
| 1487 | case 't': |
| 1488 | format_trace(buf_ch, extended, prefix, obj); |
| 1489 | break; |
| 1490 | case 'K': |
| 1491 | format_clock_class(buf_ch, extended, prefix, obj); |
| 1492 | break; |
| 1493 | case 'k': |
| 1494 | format_clock_value(buf_ch, extended, prefix, obj); |
| 1495 | break; |
| 1496 | case 'v': |
| 1497 | format_value(buf_ch, extended, prefix, obj); |
| 1498 | break; |
| 1499 | case 'n': |
| 1500 | format_notification(buf_ch, extended, prefix, obj); |
| 1501 | break; |
| 1502 | case 'i': |
| 1503 | format_notification_iterator(buf_ch, extended, prefix, obj); |
| 1504 | break; |
| 1505 | case 'C': |
| 1506 | format_component_class(buf_ch, extended, prefix, obj); |
| 1507 | break; |
| 1508 | case 'c': |
| 1509 | format_component(buf_ch, extended, prefix, obj); |
| 1510 | break; |
| 1511 | case 'p': |
| 1512 | format_port(buf_ch, extended, prefix, obj); |
| 1513 | break; |
| 1514 | case 'x': |
| 1515 | format_connection(buf_ch, extended, prefix, obj); |
| 1516 | break; |
| 1517 | case 'u': |
| 1518 | format_plugin(buf_ch, extended, prefix, obj); |
| 1519 | break; |
| 1520 | case 'g': |
| 1521 | format_graph(buf_ch, extended, prefix, obj); |
| 1522 | break; |
| 1523 | case 'o': |
| 1524 | format_object_pool(buf_ch, extended, prefix, obj); |
| 1525 | break; |
| 1526 | case 'O': |
| 1527 | format_object(buf_ch, extended, prefix, obj); |
| 1528 | break; |
| 1529 | default: |
| 1530 | abort(); |
| 1531 | } |
| 1532 | break; |
| 1533 | case CAT_WRITER: |
| 1534 | switch (*fmt_ch) { |
| 1535 | case 'F': |
| 1536 | format_writer_field_type(buf_ch, extended, prefix, obj); |
| 1537 | break; |
| 1538 | case 'f': |
| 1539 | format_writer_field(buf_ch, extended, prefix, obj); |
| 1540 | break; |
| 1541 | case 'E': |
| 1542 | format_writer_event_class(buf_ch, extended, prefix, obj); |
| 1543 | break; |
| 1544 | case 'e': |
| 1545 | format_writer_event(buf_ch, extended, prefix, obj); |
| 1546 | break; |
| 1547 | case 'S': |
| 1548 | format_writer_stream_class(buf_ch, extended, prefix, obj); |
| 1549 | break; |
| 1550 | case 's': |
| 1551 | format_writer_stream(buf_ch, extended, prefix, obj); |
| 1552 | break; |
| 1553 | case 't': |
| 1554 | format_writer_trace(buf_ch, extended, prefix, obj); |
| 1555 | break; |
| 1556 | case 'w': |
| 1557 | format_ctf_writer(buf_ch, extended, prefix, obj); |
| 1558 | break; |
| 1559 | default: |
| 1560 | abort(); |
| 1561 | } |
| 1562 | break; |
| 1563 | case CAT_COMMON: |
| 1564 | switch (*fmt_ch) { |
| 1565 | case 'F': |
| 1566 | format_field_type_common(buf_ch, extended, prefix, obj); |
| 1567 | break; |
| 1568 | case 'f': |
| 1569 | format_field_common(buf_ch, extended, prefix, obj); |
| 1570 | break; |
| 1571 | case 'E': |
| 1572 | format_event_class_common_common(buf_ch, extended, prefix, obj); |
| 1573 | break; |
| 1574 | case 'e': |
| 1575 | format_event_common_common(buf_ch, extended, prefix, obj); |
| 1576 | break; |
| 1577 | case 'S': |
| 1578 | format_stream_class_common_common(buf_ch, extended, prefix, obj); |
| 1579 | break; |
| 1580 | case 's': |
| 1581 | format_stream_common_common(buf_ch, extended, prefix, obj); |
| 1582 | break; |
| 1583 | case 't': |
| 1584 | format_trace_common(buf_ch, extended, prefix, obj); |
| 1585 | break; |
| 1586 | default: |
| 1587 | abort(); |
| 1588 | } |
| 1589 | break; |
| 1590 | } |
| 1591 | |
| 1592 | update_fmt: |
| 1593 | fmt_ch++; |
| 1594 | *out_fmt_ch = fmt_ch; |
| 1595 | } |
| 1596 | |
| 1597 | BT_HIDDEN |
| 1598 | void bt_lib_log(const char *func, const char *file, unsigned line, |
| 1599 | int lvl, const char *tag, const char *fmt, ...) |
| 1600 | { |
| 1601 | va_list args; |
| 1602 | |
| 1603 | BT_ASSERT(fmt); |
| 1604 | va_start(args, fmt); |
| 1605 | bt_common_custom_vsnprintf(lib_logging_buf, LIB_LOGGING_BUF_SIZE, '!', |
| 1606 | handle_conversion_specifier_bt, NULL, fmt, &args); |
| 1607 | va_end(args); |
| 1608 | _bt_log_write_d(func, file, line, lvl, tag, "%s", lib_logging_buf); |
| 1609 | } |