Go to the documentation of this file. 21 #include "trace_log.h" 73 #define PHOSPHOR_INSTANCE phosphor::TraceLog::getInstance() 79 #define PHOSPHOR_PTR(arg) arg 86 #define PHOSPHOR_INLINE_STR(arg) phosphor::inline_zstring<8>(arg) 87 #define PHOSPHOR_INLINE_STR_N(arg, len) phosphor::inline_zstring<8>(arg, len) 89 #if !defined(PHOSPHOR_DISABLED) 90 #define PHOSPHOR_DISABLED 0 93 #define PHOSPHOR_ENABLED !PHOSPHOR_DISABLED 95 #if !PHOSPHOR_DISABLED 112 #define TRACE_EVENT_START(category, name, ...) \ 113 PHOSPHOR_INTERNAL_TRACE_EVENT( \ 118 phosphor::TraceEvent::Type::SyncStart, \ 121 #define TRACE_EVENT_START0(category, name) \ 122 PHOSPHOR_INTERNAL_TRACE_EVENT0( \ 123 category, name, phosphor::TraceEvent::Type::SyncStart) 125 #define TRACE_EVENT_END(category, name, ...) \ 126 PHOSPHOR_INTERNAL_TRACE_EVENT( \ 131 phosphor::TraceEvent::Type::SyncEnd, \ 134 #define TRACE_EVENT_END0(category, name) \ 135 PHOSPHOR_INTERNAL_TRACE_EVENT0( \ 136 category, name, phosphor::TraceEvent::Type::SyncEnd) 138 #define TRACE_EVENT_START1(category, name, arg1_name, arg1) \ 139 PHOSPHOR_INTERNAL_TRACE_EVENT( \ 144 phosphor::TraceEvent::Type::SyncStart, \ 147 #define TRACE_EVENT_END1(category, name, arg1_name, arg1) \ 148 PHOSPHOR_INTERNAL_TRACE_EVENT( \ 153 phosphor::TraceEvent::Type::SyncEnd, \ 156 #define TRACE_EVENT_START2(category, name, arg1_name, arg1, arg2_name, arg2) \ 157 PHOSPHOR_INTERNAL_TRACE_EVENT( \ 162 phosphor::TraceEvent::Type::SyncStart, \ 166 #define TRACE_EVENT_END2(category, name, arg1_name, arg1, arg2_name, arg2) \ 167 PHOSPHOR_INTERNAL_TRACE_EVENT( \ 172 phosphor::TraceEvent::Type::SyncEnd, \ 216 #define TRACE_EVENT(category, name, ...) \ 217 static constexpr const char* PHOSPHOR_INTERNAL_UID(nme) = name; \ 218 TRACE_EVENT_START(category, name, __VA_ARGS__); \ 219 struct PHOSPHOR_INTERNAL_UID(scoped_trace_t) { \ 220 ~PHOSPHOR_INTERNAL_UID(scoped_trace_t)() { \ 221 TRACE_EVENT_END0(category, PHOSPHOR_INTERNAL_UID(nme)); \ 223 } PHOSPHOR_INTERNAL_UID(scoped_trace_inst); 225 #define TRACE_EVENT0(category, name) \ 226 static constexpr const char* PHOSPHOR_INTERNAL_UID(nme) = name; \ 227 TRACE_EVENT_START0(category, name); \ 228 struct PHOSPHOR_INTERNAL_UID(scoped_trace_t) { \ 229 ~PHOSPHOR_INTERNAL_UID(scoped_trace_t)() { \ 230 TRACE_EVENT_END0(category, PHOSPHOR_INTERNAL_UID(nme));\ 232 } PHOSPHOR_INTERNAL_UID(scoped_trace_inst); 234 #define TRACE_EVENT1(category, name, arg1_name, arg1) \ 235 static constexpr const char* PHOSPHOR_INTERNAL_UID(nme) = name; \ 236 TRACE_EVENT_START1(category, name, arg1_name, arg1); \ 237 struct PHOSPHOR_INTERNAL_UID(scoped_trace_t) { \ 238 ~PHOSPHOR_INTERNAL_UID(scoped_trace_t)() { \ 239 TRACE_EVENT_END0(category, PHOSPHOR_INTERNAL_UID(nme)); \ 241 } PHOSPHOR_INTERNAL_UID(scoped_trace_inst); 243 #define TRACE_EVENT2(category, name, arg1_name, arg1, arg2_name, arg2) \ 244 static constexpr const char* PHOSPHOR_INTERNAL_UID(nme) = name; \ 245 TRACE_EVENT_START2(category, name, arg1_name, arg1, arg2_name, arg2); \ 246 struct PHOSPHOR_INTERNAL_UID(scoped_trace_t) { \ 247 ~PHOSPHOR_INTERNAL_UID(scoped_trace_t)() { \ 248 TRACE_EVENT_END0(category, PHOSPHOR_INTERNAL_UID(nme)); \ 250 } PHOSPHOR_INTERNAL_UID(scoped_trace_inst); 252 #define TRACE_FUNCTION(category, ...) \ 253 TRACE_EVENT(category, __func__, __VA_ARGS__) 255 #define TRACE_FUNCTION0(category) \ 256 TRACE_EVENT0(category, __func__) 258 #define TRACE_FUNCTION1(category, arg1_name, arg1) \ 259 TRACE_EVENT1(category, __func__, arg1_name, arg1) 261 #define TRACE_FUNCTION2(category, arg1_name, arg1, arg2_name, arg2) \ 262 TRACE_EVENT2(category, __func__, arg1_name, arg1, arg2_name, arg2) 264 #define TRACE_LOCKGUARD(mutex, category, name) \ 265 static constexpr const char* PHOSPHOR_INTERNAL_UID(nme) = name ".held"; \ 266 static decltype(mutex)& PHOSPHOR_INTERNAL_UID(lk)(mutex); \ 267 TRACE_EVENT_START0(category, name ".acquire"); \ 268 PHOSPHOR_INTERNAL_UID(lk).lock(); \ 269 PHOSPHOR_INTERNAL_ADDITIONAL_TRACE_EVENT0( \ 270 second_tpi, category, name ".acquire", phosphor::TraceEvent::Type::SyncEnd); \ 271 PHOSPHOR_INTERNAL_ADDITIONAL_TRACE_EVENT0( \ 272 third_tpi, category, name ".held", phosphor::TraceEvent::Type::SyncStart); \ 273 struct PHOSPHOR_INTERNAL_UID(scoped_trace_t) { \ 274 ~PHOSPHOR_INTERNAL_UID(scoped_trace_t)() { \ 275 PHOSPHOR_INTERNAL_UID(lk).unlock(); \ 276 TRACE_EVENT_END0(category, PHOSPHOR_INTERNAL_UID(nme)); \ 278 } PHOSPHOR_INTERNAL_UID(scoped_trace_inst); 298 #define TRACE_ASYNC_START(category, name, id, ...) \ 299 PHOSPHOR_INTERNAL_TRACE_EVENT( \ 304 phosphor::TraceEvent::Type::AsyncStart, \ 308 #define TRACE_ASYNC_START0(category, name, id) \ 309 PHOSPHOR_INTERNAL_TRACE_EVENT( \ 314 phosphor::TraceEvent::Type::AsyncStart, \ 317 #define TRACE_ASYNC_START1(category, name, id, arg1_name, arg1) \ 318 PHOSPHOR_INTERNAL_TRACE_EVENT( \ 323 phosphor::TraceEvent::Type::AsyncStart, \ 327 #define TRACE_ASYNC_END(category, name, id, ...) \ 328 PHOSPHOR_INTERNAL_TRACE_EVENT( \ 333 phosphor::TraceEvent::Type::AsyncEnd, \ 337 #define TRACE_ASYNC_END0(category, name, id) \ 338 PHOSPHOR_INTERNAL_TRACE_EVENT( \ 343 phosphor::TraceEvent::Type::AsyncEnd, \ 346 #define TRACE_ASYNC_END1(category, name, id, arg1_name, arg1) \ 347 PHOSPHOR_INTERNAL_TRACE_EVENT( \ 352 phosphor::TraceEvent::Type::AsyncEnd, \ 369 #define TRACE_INSTANT(category, name, ...) \ 370 PHOSPHOR_INTERNAL_TRACE_EVENT( \ 375 phosphor::TraceEvent::Type::Instant, \ 378 #define TRACE_INSTANT0(category, name) \ 379 PHOSPHOR_INTERNAL_TRACE_EVENT0( \ 380 category, name, phosphor::TraceEvent::Type::Instant) 382 #define TRACE_INSTANT1(category, name, arg1_name, arg1) \ 383 PHOSPHOR_INTERNAL_TRACE_EVENT( \ 388 phosphor::TraceEvent::Type::Instant, \ 391 #define TRACE_INSTANT2(category, name, arg1_name, arg1, arg2_name, arg2) \ 392 PHOSPHOR_INTERNAL_TRACE_EVENT( \ 397 phosphor::TraceEvent::Type::Instant, \ 415 #define TRACE_GLOBAL(category, name, ...) \ 416 PHOSPHOR_INTERNAL_TRACE_EVENT( \ 421 phosphor::TraceEvent::Type::GlobalInstant, \ 424 #define TRACE_GLOBAL0(category, name) \ 425 PHOSPHOR_INTERNAL_TRACE_EVENT0( \ 426 category, name, phosphor::TraceEvent::Type::GlobalInstant) 429 #define TRACE_GLOBAL1(category, name, arg1_name, arg1) \ 430 PHOSPHOR_INTERNAL_TRACE_EVENT( \ 435 phosphor::TraceEvent::Type::GlobalInstant, \ 438 #define TRACE_GLOBAL2(category, name, arg1_name, arg1, arg2_name, arg2) \ 439 PHOSPHOR_INTERNAL_TRACE_EVENT( \ 444 phosphor::TraceEvent::Type::GlobalInstant, \ 449 #else // if: defined(PHOSPHOR_DISABLED) && PHOSPHOR_DISABLED != 0 451 #define TRACE_EVENT_START(category, name, ...) 452 #define TRACE_EVENT_START0(category, name) 453 #define TRACE_EVENT_START1(category, name, arg1_name, arg1) 454 #define TRACE_EVENT_START2(category, name, arg1_name, arg1, arg2_name, arg2) 455 #define TRACE_EVENT_END(category, name, ...) 456 #define TRACE_EVENT_END0(category, name) 457 #define TRACE_EVENT_END1(category, name, arg1_name, arg1) 458 #define TRACE_EVENT_END2(category, name, arg1_name, arg1, arg2_name, arg2) 460 #define TRACE_EVENT(category, name, ...) 461 #define TRACE_EVENT0(category, name) 462 #define TRACE_EVENT1(category, name, arg1_name, arg1) 463 #define TRACE_EVENT2(category, name, arg1_name, arg1, arg2_name, arg2) 465 #define TRACE_FUNCTION(category, ...) 466 #define TRACE_FUNCTION0(category) 467 #define TRACE_FUNCTION1(category, name, arg1_name, arg1) 468 #define TRACE_FUNCTION2(category, name, arg1_name, arg1, arg2_name, arg2) 470 #define TRACE_LOCKGUARD(mutex, category, name) 472 #define TRACE_ASYNC_START(category, name, id, ...) 473 #define TRACE_ASYNC_START0(category, name, id) 474 #define TRACE_ASYNC_START1(category, name, id, arg1_name, arg1) 475 #define TRACE_ASYNC_END(category, name, id, ...) 476 #define TRACE_ASYNC_END0(category, name, id) 477 #define TRACE_ASYNC_END1(category, name, id, arg1_name, arg1) 479 #define TRACE_INSTANT(category, name, ...) 480 #define TRACE_INSTANT0(category, name) 481 #define TRACE_INSTANT1(category, name, arg1_name, arg1) 482 #define TRACE_INSTANT2(category, name, arg1_name, arg1, arg2_name, arg2) 484 #define TRACE_GLOBAL(category, name, ...) 485 #define TRACE_GLOBAL0(category, name) 486 #define TRACE_GLOBAL1(category, name, arg1_name, arg1) 487 #define TRACE_GLOBAL2(category, name, arg1_name, arg1, arg2_name, arg2) 489 #endif // PHOSPHOR_DISABLED