1 // Copyright 2020 The Pigweed Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 // use this file except in compliance with the License. You may obtain a copy of 5 // the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 // License for the specific language governing permissions and limitations under 13 // the License. 14 //============================================================================== 15 // This file contains the backend hooks and implementation details for trace. 16 17 #pragma once 18 19 #include "pw_preprocessor/arguments.h" 20 #include "pw_trace_backend/trace_backend.h" 21 22 // Default: Flag value if none set 23 #ifndef PW_TRACE_FLAGS_DEFAULT 24 #define PW_TRACE_FLAGS_DEFAULT 0 25 #endif // PW_TRACE_FLAGS_DEFAULT 26 27 // Default: PW_TRACE_TRACE_ID_DEFAULT 28 #ifndef PW_TRACE_TRACE_ID_DEFAULT 29 #define PW_TRACE_TRACE_ID_DEFAULT 0 30 #endif // PW_TRACE_TRACE_ID_DEFAULT 31 32 // Default: PW_TRACE_GROUP_LABEL_DEFAULT 33 #ifndef PW_TRACE_GROUP_LABEL_DEFAULT 34 #define PW_TRACE_GROUP_LABEL_DEFAULT "" 35 #endif // PW_TRACE_GROUP_LABEL_DEFAULT 36 37 // These macros can be used to determine if a trace type contrains span or group 38 // label 39 #ifndef PW_TRACE_HAS_TRACE_ID 40 #define PW_TRACE_HAS_TRACE_ID(TRACE_TYPE) \ 41 ((TRACE_TYPE) == PW_TRACE_TYPE_ASYNC_START || \ 42 (TRACE_TYPE) == PW_TRACE_TYPE_ASYNC_INSTANT || \ 43 (TRACE_TYPE) == PW_TRACE_TYPE_ASYNC_END) 44 #endif // PW_TRACE_HAS_TRACE_ID 45 #ifndef PW_TRACE_HAS_GROUP_LABEL 46 #define PW_TRACE_HAS_GROUP_LABEL(TRACE_TYPE) (false) 47 #endif // PW_TRACE_HAS_GROUP_LABEL 48 49 // Default: behaviour for unimplemented trace event types 50 #ifndef _PW_TRACE_DISABLED 51 #define _PW_TRACE_DISABLED(...) \ 52 do { \ 53 } while (0) 54 #endif // _PW_TRACE_DISABLED 55 56 // Default: label used for PW_TRACE_FUNCTION trace events 57 #ifndef PW_TRACE_FUNCTION_LABEL 58 #define PW_TRACE_FUNCTION_LABEL __PRETTY_FUNCTION__ 59 #endif 60 61 // This block handles: 62 // - PW_TRACE_INSTANT(label) 63 // - PW_TRACE_INSTANT_FLAG(flag, label) 64 // Which creates a trace event with the type: PW_TRACE_TYPE_INSTANT 65 // NOTE: If this type is not defined by the backend this trace is removed. 66 #ifdef PW_TRACE_TYPE_INSTANT 67 #define _PW_TRACE_INSTANT_ARGS2(flag, label) \ 68 PW_TRACE(PW_TRACE_TYPE_INSTANT, \ 69 flag, \ 70 label, \ 71 PW_TRACE_GROUP_LABEL_DEFAULT, \ 72 PW_TRACE_TRACE_ID_DEFAULT) 73 #else // PW_TRACE_TYPE_INSTANT 74 #define _PW_TRACE_INSTANT_ARGS2(...) _PW_TRACE_DISABLED(__VA_ARGS__) 75 #endif // PW_TRACE_TYPE_INSTANT 76 77 // This block handles: 78 // - PW_TRACE_INSTANT(label, group) 79 // - PW_TRACE_INSTANT_FLAG(flag, label, group) 80 // Which creates a trace event with the type: PW_TRACE_TYPE_INSTANT_GROUP 81 // NOTE: If this type is not defined by the backend this trace is removed. 82 #ifdef PW_TRACE_TYPE_INSTANT_GROUP 83 #define _PW_TRACE_INSTANT_ARGS3(flag, label, group) \ 84 PW_TRACE(PW_TRACE_TYPE_INSTANT_GROUP, \ 85 flag, \ 86 label, \ 87 group, \ 88 PW_TRACE_TRACE_ID_DEFAULT) 89 #else // PW_TRACE_TYPE_INSTANT_GROUP 90 #define _PW_TRACE_INSTANT_ARGS3(...) _PW_TRACE_DISABLED(__VA_ARGS__) 91 #endif // PW_TRACE_TYPE_INSTANT_GROUP 92 93 // This block handles: 94 // - PW_TRACE_INSTANT(label, group, trace_id) 95 // - PW_TRACE_INSTANT_FLAG(flag, label, group, trace_id) 96 // Which creates a trace event with the type: PW_TRACE_TYPE_ASYNC_INSTANT 97 // NOTE: If this type is not defined by the backend this trace is removed. 98 #ifdef PW_TRACE_TYPE_ASYNC_INSTANT 99 #define _PW_TRACE_INSTANT_ARGS4(flag, label, group, trace_id) \ 100 PW_TRACE(PW_TRACE_TYPE_ASYNC_INSTANT, flag, label, group, trace_id) 101 #else // PW_TRACE_TYPE_ASYNC_INSTANT 102 #define _PW_TRACE_INSTANT_ARGS4(...) _PW_TRACE_DISABLED(__VA_ARGS__) 103 #endif // PW_TRACE_TYPE_ASYNC_INSTANT 104 105 // This block handles: 106 // - PW_TRACE_START(label) 107 // - PW_TRACE_START_FLAG(flag, label) 108 // Which creates a trace event with the type: PW_TRACE_TYPE_DURATION_START 109 // NOTE: If this type is not defined by the backend this trace is removed. 110 #ifdef PW_TRACE_TYPE_DURATION_START 111 #define _PW_TRACE_START_ARGS2(flag, label) \ 112 PW_TRACE(PW_TRACE_TYPE_DURATION_START, \ 113 flag, \ 114 label, \ 115 PW_TRACE_GROUP_LABEL_DEFAULT, \ 116 PW_TRACE_TRACE_ID_DEFAULT) 117 #else // PW_TRACE_TYPE_DURATION_START 118 #define _PW_TRACE_START_ARGS2(...) _PW_TRACE_DISABLED(__VA_ARGS__) 119 #endif // PW_TRACE_TYPE_DURATION_START 120 121 // This block handles: 122 // - PW_TRACE_START(label, group) 123 // - PW_TRACE_START_FLAG(flag, label, group) 124 // Which creates a trace event with the type: PW_TRACE_TYPE_DURATION_GROUP_START 125 // NOTE: If this type is not defined by the backend this trace is removed. 126 #ifdef PW_TRACE_TYPE_DURATION_GROUP_START // Disabled if backend doesn't define 127 // this 128 #define _PW_TRACE_START_ARGS3(flag, label, group) \ 129 PW_TRACE(PW_TRACE_TYPE_DURATION_GROUP_START, \ 130 flag, \ 131 label, \ 132 group, \ 133 PW_TRACE_TRACE_ID_DEFAULT) 134 #else // PW_TRACE_TYPE_DURATION_GROUP_START 135 #define _PW_TRACE_START_ARGS3(...) _PW_TRACE_DISABLED(__VA_ARGS__) 136 #endif // PW_TRACE_TYPE_DURATION_GROUP_START 137 138 // This block handles: 139 // - PW_TRACE_START(label, group, trace_id) 140 // - PW_TRACE_START_FLAG(flag, label, group, trace_id) 141 // Which creates a trace event with the type: PW_TRACE_TYPE_ASYNC_START 142 // NOTE: If this type is not defined by the backend this trace is removed. 143 #ifdef PW_TRACE_TYPE_ASYNC_START 144 #define _PW_TRACE_START_ARGS4(flag, label, group, trace_id) \ 145 PW_TRACE(PW_TRACE_TYPE_ASYNC_START, flag, label, group, trace_id) 146 #else // PW_TRACE_TYPE_ASYNC_START 147 #define _PW_TRACE_START_ARGS4(...) _PW_TRACE_DISABLED(__VA_ARGS__) 148 #endif // PW_TRACE_TYPE_ASYNC_START 149 150 // This block handles: 151 // - PW_TRACE_END(labe) 152 // - PW_TRACE_END_FLAG(flag, label) 153 // Which creates a trace event with the type: PW_TRACE_TYPE_DURATION_END 154 // NOTE: If this type is not defined by the backend this trace is removed. 155 #ifdef PW_TRACE_TYPE_DURATION_END 156 #define _PW_TRACE_END_ARGS2(flag, label) \ 157 PW_TRACE(PW_TRACE_TYPE_DURATION_END, \ 158 flag, \ 159 label, \ 160 PW_TRACE_GROUP_LABEL_DEFAULT, \ 161 PW_TRACE_TRACE_ID_DEFAULT) 162 #else // PW_TRACE_TYPE_DURATION_END 163 #define _PW_TRACE_END_ARGS2(...) _PW_TRACE_DISABLED(__VA_ARGS__) 164 #endif // PW_TRACE_TYPE_DURATION_END 165 166 // This block handles: 167 // - PW_TRACE_END(label, group) 168 // - PW_TRACE_END_FLAG(flag, label, group) 169 // Which creates a trace event with the type: PW_TRACE_TYPE_DURATION_GROUP_END 170 // NOTE: If this type is not defined by the backend this trace is removed. 171 #ifdef PW_TRACE_TYPE_DURATION_GROUP_END 172 #define _PW_TRACE_END_ARGS3(flag, label, group) \ 173 PW_TRACE(PW_TRACE_TYPE_DURATION_GROUP_END, \ 174 flag, \ 175 label, \ 176 group, \ 177 PW_TRACE_TRACE_ID_DEFAULT) 178 #else // PW_TRACE_TYPE_DURATION_GROUP_END 179 #define _PW_TRACE_END_ARGS3(...) _PW_TRACE_DISABLED(__VA_ARGS__) 180 #endif // PW_TRACE_TYPE_DURATION_GROUP_END 181 182 // This block handles: 183 // - PW_TRACE_END(label, group, trace_id) 184 // - PW_TRACE_END_FLAG(flag, label, group, trace_id) 185 // Which creates a trace event with the type: PW_TRACE_TYPE_ASYNC_END 186 // NOTE: If this type is not defined by the backend this trace is removed. 187 #ifdef PW_TRACE_TYPE_ASYNC_END 188 #define _PW_TRACE_END_ARGS4(flag, label, group, trace_id) \ 189 PW_TRACE(PW_TRACE_TYPE_ASYNC_END, flag, label, group, trace_id) 190 #else // PW_TRACE_TYPE_ASYNC_END 191 #define _PW_TRACE_END_ARGS4(...) _PW_TRACE_DISABLED(__VA_ARGS__) 192 #endif // PW_TRACE_TYPE_ASYNC_END 193 194 // The pigweed scope objects gets defined inline with the trace event. The 195 // constructor handles the start trace event, and the destructor does the end. 196 #ifndef _PW_TRACE_SCOPE_OBJECT 197 #define _PW_TRACE_SCOPE_OBJECT( \ 198 object_name, flag, event_type_start, event_type_end, label, group) \ 199 class object_name { \ 200 public: \ 201 object_name(uint32_t trace_id = PW_TRACE_TRACE_ID_DEFAULT) \ 202 : trace_id_(trace_id) { \ 203 PW_TRACE(event_type_start, flag, label, group, trace_id_); \ 204 } \ 205 ~object_name() { \ 206 PW_TRACE(event_type_end, flag, label, group, trace_id_); \ 207 } \ 208 \ 209 private: \ 210 const uint32_t trace_id_; \ 211 } 212 #endif // _PW_TRACE_SCOPE_OBJECT 213 214 // This block handles: 215 // - PW_TRACE_SCOPE(label) 216 // - PW_TRACE_SCOPE_FLAG(flag, label) 217 // - PW_TRACE_FUNCTION() 218 // - PW_TRACE_FUNCTION_FLAG(flag) 219 // These each generate two trace events: 220 // - PW_TRACE_TYPE_DURATION_START: Where trace event appears in code. 221 // - PW_TRACE_TYPE_DURATION_END: When current scope is lost. 222 // NOTE; If these types are not defined by the backend these traces are removed. 223 #if defined(PW_TRACE_TYPE_DURATION_START) && defined(PW_TRACE_TYPE_DURATION_END) 224 #define _PW_TRACE_SCOPE_ARGS2(flag, label) \ 225 _PW_TRACE_SCOPE_OBJECT(PW_CONCAT(_PwTraceScopeObject, __COUNTER__), \ 226 flag, \ 227 PW_TRACE_TYPE_DURATION_START, \ 228 PW_TRACE_TYPE_DURATION_END, \ 229 label, \ 230 PW_TRACE_GROUP_LABEL_DEFAULT) \ 231 PW_CONCAT(_pw_trace_scope_object, __COUNTER__); 232 #define _PW_TRACE_FUNCTION_ARGS0() \ 233 _PW_TRACE_SCOPE_ARGS2(PW_TRACE_FLAGS, PW_TRACE_FUNCTION_LABEL) 234 #define _PW_TRACE_FUNCTION_FLAGS_ARGS1(flag) \ 235 _PW_TRACE_SCOPE_ARGS2(flag, PW_TRACE_FUNCTION_LABEL) 236 #endif // defined(PW_TRACE_TYPE_DURATION_START) && 237 // defined(PW_TRACE_TYPE_DURATION_END) 238 239 // This block handles: 240 // - PW_TRACE_SCOPE(label, group) 241 // - PW_TRACE_SCOPE_FLAG(flag, label, group) 242 // - PW_TRACE_FUNCTION(group) 243 // - PW_TRACE_FUNCTION_FLAG(flag, group) 244 // These each generate two trace events: 245 // - PW_TRACE_TYPE_DURATION_GROUP_START: Where trace event appears in code. 246 // - PW_TRACE_TYPE_DURATION_GROUP_END: When current scope is lost. 247 // NOTE; If these types are not defined by the backend these traces are removed. 248 #if defined(PW_TRACE_TYPE_DURATION_GROUP_START) && \ 249 defined(PW_TRACE_TYPE_DURATION_GROUP_END) 250 #define _PW_TRACE_SCOPE_ARGS3(flag, label, group) \ 251 _PW_TRACE_SCOPE_OBJECT(PW_CONCAT(_PwTraceScopeObject, __COUNTER__), \ 252 flag, \ 253 PW_TRACE_TYPE_DURATION_GROUP_START, \ 254 PW_TRACE_TYPE_DURATION_GROUP_END, \ 255 label, \ 256 group) \ 257 PW_CONCAT(_pw_trace_scope_object, __COUNTER__); 258 #define _PW_TRACE_FUNCTION_ARGS1(group) \ 259 _PW_TRACE_SCOPE_ARGS3(PW_TRACE_FLAGS, PW_TRACE_FUNCTION_LABEL, group) 260 #define _PW_TRACE_FUNCTION_FLAGS_ARGS2(flag, group) \ 261 _PW_TRACE_SCOPE_ARGS3(flag, PW_TRACE_FUNCTION_LABEL, group) 262 #endif // defined(PW_TRACE_TYPE_DURATION_GROUP_START) && 263 // defined(PW_TRACE_TYPE_DURATION_GROUP_END) 264 265 // This block handles: 266 // - PW_TRACE_SCOPE(label, group, trace_id) 267 // - PW_TRACE_SCOPE_FLAG(flag, label, group, trace_id) 268 // - PW_TRACE_FUNCTION(group, trace_id) 269 // - PW_TRACE_FUNCTION_FLAG(flag, group, trace_id) 270 // These each generate two trace events: 271 // - PW_TRACE_TYPE_ASYNC_START: Where trace event appears in code. 272 // - PW_TRACE_TYPE_ASYNC_END: When current scope is lost. 273 // NOTE: If these types are not defined by the backend these traces are removed. 274 #if defined(PW_TRACE_TYPE_ASYNC_START) && defined(PW_TRACE_TYPE_ASYNC_END) 275 #define _PW_TRACE_SCOPE_ARGS4(flag, label, group, trace_id) \ 276 _PW_TRACE_SCOPE_OBJECT(PW_CONCAT(_PwTraceScopeObject, __COUNTER__), \ 277 flag, \ 278 PW_TRACE_TYPE_ASYNC_START, \ 279 PW_TRACE_TYPE_ASYNC_END, \ 280 label, \ 281 group) \ 282 PW_CONCAT(_pw_trace_scope_object, __COUNTER__)(trace_id); 283 #define _PW_TRACE_FUNCTION_ARGS2(group, trace_id) \ 284 _PW_TRACE_SCOPE_ARGS4( \ 285 PW_TRACE_FLAGS, PW_TRACE_FUNCTION_LABEL, group, trace_id) 286 #define _PW_TRACE_FUNCTION_FLAGS_ARGS3(flag, group, trace_id) \ 287 _PW_TRACE_SCOPE_ARGS4(flag, PW_TRACE_FUNCTION_LABEL, group, trace_id) 288 #endif // defined(PW_TRACE_TYPE_ASYNC_START) && 289 // defined(PW_TRACE_TYPE_ASYNC_END) 290 291 // This block handles: 292 // - PW_TRACE_INSTANT_DATA(label, 293 // data_format_string, 294 // data, 295 // size) 296 // - PW_TRACE_INSTANT_DATA_FLAG(flag, 297 // label, 298 // data_format_string, 299 // data, 300 // size) 301 // Which creates a trace event with the type: PW_TRACE_TYPE_INSTANT 302 // NOTE: If this type or PW_TRACE_DATA is not defined by the backend this trace 303 // is removed. 304 #if defined(PW_TRACE_DATA) && defined(PW_TRACE_TYPE_INSTANT) 305 #define _PW_TRACE_INSTANT_DATA_ARGS5( \ 306 flag, label, data_format_string, data, size) \ 307 PW_TRACE_DATA(PW_TRACE_TYPE_INSTANT, \ 308 flag, \ 309 label, \ 310 PW_TRACE_GROUP_LABEL_DEFAULT, \ 311 PW_TRACE_TRACE_ID_DEFAULT, \ 312 data_format_string, \ 313 data, \ 314 size) 315 #else // defined(PW_TRACE_DATA) && defined(PW_TRACE_TYPE_INSTANT) 316 #define _PW_TRACE_INSTANT_DATA_ARGS5(...) _PW_TRACE_DISABLED(__VA_ARGS__) 317 #endif // defined(PW_TRACE_DATA) && defined(PW_TRACE_TYPE_INSTANT) 318 319 // This block handles: 320 // - PW_TRACE_INSTANT_DATA(label, 321 // group, 322 // data_format_string, 323 // data, 324 // size) 325 // - PW_TRACE_INSTANT_DATA_FLAG(flag, 326 // label, 327 // group, 328 // data_format_string, 329 // data, 330 // size) 331 // Which creates a trace event with the type: PW_TRACE_TYPE_INSTANT_GROUP 332 // NOTE: If this type or PW_TRACE_DATA is not defined by the backend this trace 333 // is removed. 334 #if defined(PW_TRACE_DATA) && defined(PW_TRACE_TYPE_INSTANT_GROUP) 335 #define _PW_TRACE_INSTANT_DATA_ARGS6( \ 336 flag, label, group, data_format_string, data, size) \ 337 PW_TRACE_DATA(PW_TRACE_TYPE_INSTANT_GROUP, \ 338 flag, \ 339 label, \ 340 group, \ 341 PW_TRACE_TRACE_ID_DEFAULT, \ 342 data_format_string, \ 343 data, \ 344 size) 345 #else // defined(PW_TRACE_DATA) && defined(PW_TRACE_TYPE_INSTANT_GROUP) 346 #define _PW_TRACE_INSTANT_DATA_ARGS6(...) _PW_TRACE_DISABLED(__VA_ARGS__) 347 #endif // defined(PW_TRACE_DATA) && defined(PW_TRACE_TYPE_INSTANT_GROUP) 348 349 // This block handles: 350 // - PW_TRACE_INSTANT_DATA(label, 351 // group, 352 // trace_id 353 // data_format_string, 354 // data, 355 // size) 356 // - PW_TRACE_INSTANT_DATA_FLAG(flag, 357 // label, 358 // group, 359 // trace_id 360 // data_format_string, 361 // data, 362 // size) 363 // Which creates a trace event with the type: PW_TRACE_TYPE_ASYNC_INSTANT 364 // NOTE: If this type or PW_TRACE_DATA is not defined by the backend this trace 365 // is removed. 366 #if defined(PW_TRACE_DATA) && defined(PW_TRACE_TYPE_ASYNC_INSTANT) 367 #define _PW_TRACE_INSTANT_DATA_ARGS7( \ 368 flag, label, group, trace_id, data_format_string, data, size) \ 369 PW_TRACE_DATA(PW_TRACE_TYPE_ASYNC_INSTANT, \ 370 flag, \ 371 label, \ 372 group, \ 373 trace_id, \ 374 data_format_string, \ 375 data, \ 376 size) 377 #else // defined(PW_TRACE_DATA) && defined(PW_TRACE_TYPE_ASYNC_INSTANT) 378 #define _PW_TRACE_INSTANT_DATA_ARGS7(...) _PW_TRACE_DISABLED(__VA_ARGS__) 379 #endif // defined(PW_TRACE_DATA) && defined(PW_TRACE_TYPE_ASYNC_INSTANT) 380 381 // This block handles: 382 // - PW_TRACE_START_DATA(label, 383 // data_format_string, 384 // data, 385 // size) 386 // - PW_TRACE_START_DATA_FLAG(flag, 387 // label, 388 // data_format_string, 389 // data, 390 // size) 391 // Which creates a trace event with the type: PW_TRACE_TYPE_DURATION_START 392 // NOTE: If this type or PW_TRACE_DATA is not defined by the backend this trace 393 // is removed. 394 #if defined(PW_TRACE_DATA) && defined(PW_TRACE_TYPE_DURATION_START) 395 #define _PW_TRACE_START_DATA_ARGS5( \ 396 flag, label, data_format_string, data, size) \ 397 PW_TRACE_DATA(PW_TRACE_TYPE_DURATION_START, \ 398 flag, \ 399 label, \ 400 PW_TRACE_GROUP_LABEL_DEFAULT, \ 401 PW_TRACE_TRACE_ID_DEFAULT, \ 402 data_format_string, \ 403 data, \ 404 size) 405 #else // defined(PW_TRACE_DATA) && defined(PW_TRACE_TYPE_DURATION_START) 406 #define _PW_TRACE_START_DATA_ARGS5(...) _PW_TRACE_DISABLED(__VA_ARGS__) 407 #endif // defined(PW_TRACE_DATA) && defined(PW_TRACE_TYPE_DURATION_START) 408 409 // This block handles: 410 // - PW_TRACE_START_DATA(label, 411 // group, 412 // data_format_string, 413 // data, 414 // size) 415 // - PW_TRACE_START_DATA_FLAG(flag, 416 // label, 417 // group, 418 // data_format_string, 419 // data, 420 // size) 421 // Which creates a trace event with the type: PW_TRACE_TYPE_DURATION_GROUP_START 422 // NOTE: If this type or PW_TRACE_DATA is not defined by the backend this trace 423 // is removed. 424 #if defined(PW_TRACE_DATA) && defined(PW_TRACE_TYPE_DURATION_GROUP_START) 425 #define _PW_TRACE_START_DATA_ARGS6( \ 426 flag, label, group, data_format_string, data, size) \ 427 PW_TRACE_DATA(PW_TRACE_TYPE_DURATION_GROUP_START, \ 428 flag, \ 429 label, \ 430 group, \ 431 PW_TRACE_TRACE_ID_DEFAULT, \ 432 data_format_string, \ 433 data, \ 434 size) 435 #else // defined(PW_TRACE_DATA) && defined(PW_TRACE_TYPE_DURATION_START) 436 #define _PW_TRACE_START_DATA_ARGS6(...) _PW_TRACE_DISABLED(__VA_ARGS__) 437 #endif // defined(PW_TRACE_DATA) && defined(PW_TRACE_TYPE_DURATION_START) 438 439 // This block handles: 440 // - PW_TRACE_START_DATA(label, 441 // group, 442 // trace_id 443 // data_format_string, 444 // data, 445 // size) 446 // - PW_TRACE_START_DATA_FLAG(flag, 447 // label, 448 // group, 449 // trace_id 450 // data_format_string, 451 // data, 452 // size) 453 // Which creates a trace event with the type: PW_TRACE_TYPE_ASYNC_START 454 // NOTE: If this type or PW_TRACE_DATA is not defined by the backend this trace 455 // is removed. 456 #if defined(PW_TRACE_DATA) && defined(PW_TRACE_TYPE_ASYNC_START) 457 #define _PW_TRACE_START_DATA_ARGS7( \ 458 flag, label, group, trace_id, data_format_string, data, size) \ 459 PW_TRACE_DATA(PW_TRACE_TYPE_ASYNC_START, \ 460 flag, \ 461 label, \ 462 group, \ 463 trace_id, \ 464 data_format_string, \ 465 data, \ 466 size) 467 #else // defined(PW_TRACE_DATA) && defined(PW_TRACE_TYPE_ASYNC_START) 468 #define _PW_TRACE_START_DATA_ARGS7(...) _PW_TRACE_DISABLED(__VA_ARGS__) 469 #endif // defined(PW_TRACE_DATA) && defined(PW_TRACE_TYPE_ASYNC_START) 470 471 // This block handles: 472 // - PW_TRACE_END_DATA(label, 473 // data_format_string, 474 // data, 475 // size) 476 // - PW_TRACE_END_DATA_FLAG(flag, 477 // label, 478 // data_format_string, 479 // data, 480 // size) 481 // Which creates a trace event with the type: PW_TRACE_TYPE_DURATION_END 482 // NOTE: If this type or PW_TRACE_DATA is not defined by the backend this trace 483 // is removed. 484 #if defined(PW_TRACE_DATA) && defined(PW_TRACE_TYPE_DURATION_END) 485 #define _PW_TRACE_END_DATA_ARGS5(flag, label, data_format_string, data, size) \ 486 PW_TRACE_DATA(PW_TRACE_TYPE_DURATION_END, \ 487 flag, \ 488 label, \ 489 PW_TRACE_GROUP_LABEL_DEFAULT, \ 490 PW_TRACE_TRACE_ID_DEFAULT, \ 491 data_format_string, \ 492 data, \ 493 size) 494 #else // defined(PW_TRACE_DATA) && defined(PW_TRACE_TYPE_DURATION_START) 495 #define _PW_TRACE_END_DATA_ARGS5(...) _PW_TRACE_DISABLED(__VA_ARGS__) 496 #endif // defined(PW_TRACE_DATA) && defined(PW_TRACE_TYPE_DURATION_START) 497 498 // This block handles: 499 // - PW_TRACE_END_DATA(label, 500 // group, 501 // data_format_string, 502 // data, 503 // size) 504 // - PW_TRACE_END_DATA_FLAG(flag, 505 // label, 506 // group, 507 // data_format_string, 508 // data, 509 // size) 510 // Which creates a trace event with the type: PW_TRACE_TYPE_DURATION_GROUP_END 511 // NOTE: If this type or PW_TRACE_DATA is not defined by the backend this trace 512 // is removed. 513 #if defined(PW_TRACE_DATA) && defined(PW_TRACE_TYPE_DURATION_GROUP_END) 514 #define _PW_TRACE_END_DATA_ARGS6( \ 515 flag, label, group, data_format_string, data, size) \ 516 PW_TRACE_DATA(PW_TRACE_TYPE_DURATION_GROUP_END, \ 517 flag, \ 518 label, \ 519 group, \ 520 PW_TRACE_TRACE_ID_DEFAULT, \ 521 data_format_string, \ 522 data, \ 523 size) 524 #else // defined(PW_TRACE_DATA) && defined(PW_TRACE_TYPE_DURATION_GROUP_END) 525 #define _PW_TRACE_END_DATA_ARGS6(...) _PW_TRACE_DISABLED(__VA_ARGS__) 526 #endif // defined(PW_TRACE_DATA) && defined(PW_TRACE_TYPE_DURATION_GROUP_END) 527 528 // This block handles: 529 // - PW_TRACE_END_DATA(label, 530 // group, 531 // trace_id 532 // data_format_string, 533 // data, 534 // size) 535 // - PW_TRACE_END_DATA_FLAG(flag, 536 // label, 537 // group, 538 // trace_id 539 // data_format_string, 540 // data, 541 // size) 542 // Which creates a trace event with the type: PW_TRACE_TYPE_ASYNC_END 543 // NOTE: If this type or PW_TRACE_DATA is not defined by the backend this trace 544 // is removed. 545 #if defined(PW_TRACE_DATA) && defined(PW_TRACE_TYPE_ASYNC_END) 546 #define _PW_TRACE_END_DATA_ARGS7( \ 547 flag, label, group, trace_id, data_format_string, data, size) \ 548 PW_TRACE_DATA(PW_TRACE_TYPE_ASYNC_END, \ 549 flag, \ 550 label, \ 551 group, \ 552 trace_id, \ 553 data_format_string, \ 554 data, \ 555 size) 556 #else // defined(PW_TRACE_DATA) && defined(PW_TRACE_TYPE_ASYNC_END) 557 #define _PW_TRACE_END_DATA_ARGS7(...) _PW_TRACE_DISABLED(__VA_ARGS__) 558 #endif // defined(PW_TRACE_DATA) && defined(PW_TRACE_TYPE_ASYNC_END) 559