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