Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Trace events are for tracking application performance. | 5 // Trace events are for tracking application performance. |
| 6 // | 6 // |
| 7 // Events are issued against categories. Whereas LOG's | 7 // Events are issued against categories. Whereas LOG's |
| 8 // categories are statically defined, TRACE categories are created | 8 // categories are statically defined, TRACE categories are created |
| 9 // implicitly with a string. For example: | 9 // implicitly with a string. For example: |
| 10 // TRACE_EVENT_INSTANT0("MY_SUBSYSTEM", "SomeImportantEvent") | 10 // TRACE_EVENT_INSTANT0("MY_SUBSYSTEM", "SomeImportantEvent") |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 246 #define TRACE_EVENT_IF_LONGER_THAN0(threshold_us, category, name) \ | 246 #define TRACE_EVENT_IF_LONGER_THAN0(threshold_us, category, name) \ |
| 247 TRACE_EVENT_IF_LONGER_THAN1(threshold_us, category, name, NULL, 0) | 247 TRACE_EVENT_IF_LONGER_THAN1(threshold_us, category, name, NULL, 0) |
| 248 #define TRACE_EVENT_IF_LONGER_THAN1( \ | 248 #define TRACE_EVENT_IF_LONGER_THAN1( \ |
| 249 threshold_us, category, name, arg1_name, arg1_val) \ | 249 threshold_us, category, name, arg1_name, arg1_val) \ |
| 250 TRACE_EVENT_IF_LONGER_THAN2(threshold_us, category, name, \ | 250 TRACE_EVENT_IF_LONGER_THAN2(threshold_us, category, name, \ |
| 251 arg1_name, arg1_val, NULL, 0) | 251 arg1_name, arg1_val, NULL, 0) |
| 252 #define TRACE_EVENT_IF_LONGER_THAN2( \ | 252 #define TRACE_EVENT_IF_LONGER_THAN2( \ |
| 253 threshold_us, category, name, arg1_name, arg1_val, arg2_name, arg2_val) \ | 253 threshold_us, category, name, arg1_name, arg1_val, arg2_name, arg2_val) \ |
| 254 INTERNAL_TRACE_EVENT_ADD_SCOPED_IF_LONGER_THAN(threshold_us, \ | 254 INTERNAL_TRACE_EVENT_ADD_SCOPED_IF_LONGER_THAN(threshold_us, \ |
| 255 category, name, arg1_name, arg1_val, arg2_name, arg2_val) | 255 category, name, arg1_name, arg1_val, arg2_name, arg2_val) |
| 256 | 256 |
|
nduca
2011/11/17 19:13:06
Docs in the top of the header?
Can we remove the
jbates
2011/11/23 00:41:11
I think we should remove them, but there are a few
| |
| 257 | 257 |
| 258 // Records a single START event called "name" immediately, with 0, 1 or 2 | |
| 259 // associated arguments. If the category is not enabled, then this | |
| 260 // does nothing. | |
|
nduca
2011/11/17 19:13:06
Should explain what a start is.
jbates
2011/11/23 00:41:11
Done.
| |
| 261 // - category and name strings must have application lifetime (statics or | |
| 262 // literals). They may not include " chars. | |
| 263 // - |id| is used to match the START event with the FINISH event. It must cast | |
| 264 // properly to a uint64. | |
| 265 #define TRACE_EVENT_START0(category, name, id) \ | |
| 266 TRACE_EVENT_START1(category, name, id, NULL, 0) | |
| 267 #define TRACE_EVENT_START1(category, name, id, arg1_name, arg1_val) \ | |
| 268 TRACE_EVENT_START2(category, name, id, arg1_name, arg1_val, NULL, 0) | |
| 269 #define TRACE_EVENT_START2(category, name, id, arg1_name, arg1_val, \ | |
| 270 arg2_name, arg2_val) \ | |
| 271 INTERNAL_TRACE_EVENT_ADD_WITH_EXTRA(base::debug::TRACE_EVENT_PHASE_START, \ | |
| 272 category, name, id, arg1_name, arg1_val, arg2_name, arg2_val, \ | |
| 273 base::debug::TraceLog::EVENT_FLAG_NONE) | |
| 274 #define TRACE_EVENT_COPY_START0(category, name, id) \ | |
| 275 TRACE_EVENT_COPY_START1(category, name, id, NULL, 0) | |
| 276 #define TRACE_EVENT_COPY_START1(category, name, id, arg1_name, arg1_val) \ | |
| 277 TRACE_EVENT_COPY_START2(category, name, id, arg1_name, arg1_val, NULL, 0) | |
| 278 #define TRACE_EVENT_COPY_START2(category, name, id, arg1_name, arg1_val, \ | |
| 279 arg2_name, arg2_val) \ | |
| 280 INTERNAL_TRACE_EVENT_ADD_WITH_EXTRA(base::debug::TRACE_EVENT_PHASE_START, \ | |
| 281 category, name, id, \ | |
| 282 arg1_name, base::debug::TraceValue::ForceCopy(arg1_val), \ | |
| 283 arg2_name, base::debug::TraceValue::ForceCopy(arg2_val), \ | |
| 284 base::debug::TraceLog::EVENT_FLAG_COPY) | |
| 285 | |
| 286 // Records a single FINISH event for "name" immediately. If the category | |
| 287 // is not enabled, then this does nothing. | |
| 288 // - category and name strings must have application lifetime (statics or | |
|
nduca
2011/11/17 19:13:06
Should explai what a finish is.
jbates
2011/11/23 00:41:11
Done.
| |
| 289 // literals). They may not include " chars. | |
| 290 // - |id| is used to match the START event with the FINISH event. It must cast | |
| 291 // properly to a uint64. | |
| 292 #define TRACE_EVENT_FINISH0(category, name, id) \ | |
| 293 TRACE_EVENT_FINISH1(category, name, id, NULL, 0) | |
| 294 #define TRACE_EVENT_FINISH1(category, name, id, arg1_name, arg1_val) \ | |
| 295 TRACE_EVENT_FINISH2(category, name, id, arg1_name, arg1_val, NULL, 0) | |
| 296 #define TRACE_EVENT_FINISH2(category, name, id, arg1_name, arg1_val, \ | |
| 297 arg2_name, arg2_val) \ | |
| 298 INTERNAL_TRACE_EVENT_ADD_WITH_EXTRA(base::debug::TRACE_EVENT_PHASE_FINISH, \ | |
| 299 category, name, id, arg1_name, arg1_val, arg2_name, arg2_val, \ | |
| 300 base::debug::TraceLog::EVENT_FLAG_NONE) | |
| 301 #define TRACE_EVENT_COPY_FINISH0(category, name, id) \ | |
| 302 TRACE_EVENT_COPY_FINISH1(category, name, id, NULL, 0) | |
| 303 #define TRACE_EVENT_COPY_FINISH1(category, name, id, arg1_name, arg1_val) \ | |
| 304 TRACE_EVENT_COPY_FINISH2(category, name, id, arg1_name, arg1_val, NULL, 0) | |
| 305 #define TRACE_EVENT_COPY_FINISH2(category, name, id, arg1_name, arg1_val, \ | |
| 306 arg2_name, arg2_val) \ | |
| 307 INTERNAL_TRACE_EVENT_ADD_WITH_EXTRA(base::debug::TRACE_EVENT_PHASE_FINISH, \ | |
| 308 category, name, id, \ | |
| 309 arg1_name, base::debug::TraceValue::ForceCopy(arg1_val), \ | |
| 310 arg2_name, base::debug::TraceValue::ForceCopy(arg2_val), \ | |
| 311 base::debug::TraceLog::EVENT_FLAG_COPY) | |
| 312 | |
| 313 | |
| 258 // Implementation detail: trace event macros create temporary variables | 314 // Implementation detail: trace event macros create temporary variables |
| 259 // to keep instrumentation overhead low. These macros give each temporary | 315 // to keep instrumentation overhead low. These macros give each temporary |
| 260 // variable a unique name based on the line number to prevent name collissions. | 316 // variable a unique name based on the line number to prevent name collissions. |
| 261 #define INTERNAL_TRACE_EVENT_UID3(a,b) \ | 317 #define INTERNAL_TRACE_EVENT_UID3(a,b) \ |
| 262 trace_event_unique_##a##b | 318 trace_event_unique_##a##b |
| 263 #define INTERNAL_TRACE_EVENT_UID2(a,b) \ | 319 #define INTERNAL_TRACE_EVENT_UID2(a,b) \ |
| 264 INTERNAL_TRACE_EVENT_UID3(a,b) | 320 INTERNAL_TRACE_EVENT_UID3(a,b) |
| 265 #define INTERNAL_TRACE_EVENT_UID(name_prefix) \ | 321 #define INTERNAL_TRACE_EVENT_UID(name_prefix) \ |
| 266 INTERNAL_TRACE_EVENT_UID2(name_prefix, __LINE__) | 322 INTERNAL_TRACE_EVENT_UID2(name_prefix, __LINE__) |
| 267 | 323 |
| 268 // Implementation detail: internal macro to create static category. | 324 // Implementation detail: internal macro to create static category. |
| 269 // - ANNOTATE_BENIGN_RACE, see Thread Safety above. | 325 // - ANNOTATE_BENIGN_RACE, see Thread Safety above. |
| 270 #define INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category) \ | 326 #define INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category) \ |
| 271 static const base::debug::TraceCategory* \ | 327 static const base::debug::TraceCategory* \ |
| 272 INTERNAL_TRACE_EVENT_UID(catstatic) = NULL; \ | 328 INTERNAL_TRACE_EVENT_UID(catstatic) = NULL; \ |
| 273 ANNOTATE_BENIGN_RACE(&INTERNAL_TRACE_EVENT_UID(catstatic), \ | 329 ANNOTATE_BENIGN_RACE(&INTERNAL_TRACE_EVENT_UID(catstatic), \ |
| 274 "trace_event category"); \ | 330 "trace_event category"); \ |
| 275 if (!INTERNAL_TRACE_EVENT_UID(catstatic)) \ | 331 if (!INTERNAL_TRACE_EVENT_UID(catstatic)) \ |
| 276 INTERNAL_TRACE_EVENT_UID(catstatic) = \ | 332 INTERNAL_TRACE_EVENT_UID(catstatic) = \ |
| 277 base::debug::TraceLog::GetCategory(category); | 333 base::debug::TraceLog::GetCategory(category); |
| 278 | 334 |
| 279 // Implementation detail: internal macro to create static category and add begin | 335 // Implementation detail: internal macro to create static category and add |
| 280 // event if the category is enabled. | 336 // event if the category is enabled. |
| 281 #define INTERNAL_TRACE_EVENT_ADD( \ | 337 #define INTERNAL_TRACE_EVENT_ADD( \ |
| 282 phase, category, name, arg1_name, arg1_val, arg2_name, arg2_val, flags) \ | 338 phase, category, name, arg1_name, arg1_val, arg2_name, arg2_val, flags) \ |
| 283 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ | 339 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ |
| 284 if (INTERNAL_TRACE_EVENT_UID(catstatic)->enabled) { \ | 340 if (INTERNAL_TRACE_EVENT_UID(catstatic)->enabled) { \ |
| 285 base::debug::TraceLog::GetInstance()->AddTraceEvent( \ | 341 base::debug::TraceLog::GetInstance()->AddTraceEvent( \ |
| 286 phase, INTERNAL_TRACE_EVENT_UID(catstatic), \ | 342 phase, INTERNAL_TRACE_EVENT_UID(catstatic), \ |
| 287 name, arg1_name, arg1_val, arg2_name, arg2_val, -1, 0, flags); \ | 343 name, 0, arg1_name, arg1_val, arg2_name, arg2_val, -1, 0, flags); \ |
| 288 } | 344 } |
| 289 | 345 |
| 290 // Implementation detail: internal macro to create static category and add begin | 346 // Implementation detail: internal macro to create static category and add begin |
| 291 // event if the category is enabled. Also adds the end event when the scope | 347 // event if the category is enabled. Also adds the end event when the scope |
| 292 // ends. | 348 // ends. |
| 293 #define INTERNAL_TRACE_EVENT_ADD_SCOPED( \ | 349 #define INTERNAL_TRACE_EVENT_ADD_SCOPED( \ |
| 294 category, name, arg1_name, arg1_val, arg2_name, arg2_val) \ | 350 category, name, arg1_name, arg1_val, arg2_name, arg2_val) \ |
| 295 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ | 351 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ |
| 296 base::debug::internal::TraceEndOnScopeClose \ | 352 base::debug::internal::TraceEndOnScopeClose \ |
| 297 INTERNAL_TRACE_EVENT_UID(profileScope); \ | 353 INTERNAL_TRACE_EVENT_UID(profileScope); \ |
| 298 if (INTERNAL_TRACE_EVENT_UID(catstatic)->enabled) { \ | 354 if (INTERNAL_TRACE_EVENT_UID(catstatic)->enabled) { \ |
| 299 base::debug::TraceLog::GetInstance()->AddTraceEvent( \ | 355 base::debug::TraceLog::GetInstance()->AddTraceEvent( \ |
| 300 base::debug::TRACE_EVENT_PHASE_BEGIN, \ | 356 base::debug::TRACE_EVENT_PHASE_BEGIN, \ |
| 301 INTERNAL_TRACE_EVENT_UID(catstatic), \ | 357 INTERNAL_TRACE_EVENT_UID(catstatic), \ |
| 302 name, arg1_name, arg1_val, arg2_name, arg2_val, -1, 0, \ | 358 name, 0, arg1_name, arg1_val, arg2_name, arg2_val, -1, 0, \ |
| 303 base::debug::TraceLog::EVENT_FLAG_NONE); \ | 359 base::debug::TraceLog::EVENT_FLAG_NONE); \ |
| 304 INTERNAL_TRACE_EVENT_UID(profileScope).Initialize( \ | 360 INTERNAL_TRACE_EVENT_UID(profileScope).Initialize( \ |
| 305 INTERNAL_TRACE_EVENT_UID(catstatic), name); \ | 361 INTERNAL_TRACE_EVENT_UID(catstatic), name); \ |
| 306 } | 362 } |
| 307 | 363 |
| 308 // Implementation detail: internal macro to create static category and add begin | 364 // Implementation detail: internal macro to create static category and add begin |
| 309 // event if the category is enabled. Also adds the end event when the scope | 365 // event if the category is enabled. Also adds the end event when the scope |
| 310 // ends. If the elapsed time is < threshold time, the begin/end pair is erased. | 366 // ends. If the elapsed time is < threshold time, the begin/end pair is erased. |
| 311 #define INTERNAL_TRACE_EVENT_ADD_SCOPED_IF_LONGER_THAN(threshold, \ | 367 #define INTERNAL_TRACE_EVENT_ADD_SCOPED_IF_LONGER_THAN(threshold, \ |
| 312 category, name, arg1_name, arg1_val, arg2_name, arg2_val) \ | 368 category, name, arg1_name, arg1_val, arg2_name, arg2_val) \ |
| 313 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ | 369 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ |
| 314 base::debug::internal::TraceEndOnScopeCloseThreshold \ | 370 base::debug::internal::TraceEndOnScopeCloseThreshold \ |
| 315 INTERNAL_TRACE_EVENT_UID(profileScope); \ | 371 INTERNAL_TRACE_EVENT_UID(profileScope); \ |
| 316 if (INTERNAL_TRACE_EVENT_UID(catstatic)->enabled) { \ | 372 if (INTERNAL_TRACE_EVENT_UID(catstatic)->enabled) { \ |
| 317 int INTERNAL_TRACE_EVENT_UID(begin_event_id) = \ | 373 int INTERNAL_TRACE_EVENT_UID(begin_event_id) = \ |
| 318 base::debug::TraceLog::GetInstance()->AddTraceEvent( \ | 374 base::debug::TraceLog::GetInstance()->AddTraceEvent( \ |
| 319 base::debug::TRACE_EVENT_PHASE_BEGIN, \ | 375 base::debug::TRACE_EVENT_PHASE_BEGIN, \ |
| 320 INTERNAL_TRACE_EVENT_UID(catstatic), \ | 376 INTERNAL_TRACE_EVENT_UID(catstatic), \ |
| 321 name, arg1_name, arg1_val, arg2_name, arg2_val, -1, 0, \ | 377 name, 0, arg1_name, arg1_val, arg2_name, arg2_val, -1, 0, \ |
| 322 base::debug::TraceLog::EVENT_FLAG_NONE); \ | 378 base::debug::TraceLog::EVENT_FLAG_NONE); \ |
| 323 INTERNAL_TRACE_EVENT_UID(profileScope).Initialize( \ | 379 INTERNAL_TRACE_EVENT_UID(profileScope).Initialize( \ |
| 324 INTERNAL_TRACE_EVENT_UID(catstatic), name, \ | 380 INTERNAL_TRACE_EVENT_UID(catstatic), name, \ |
| 325 INTERNAL_TRACE_EVENT_UID(begin_event_id), threshold); \ | 381 INTERNAL_TRACE_EVENT_UID(begin_event_id), threshold); \ |
| 326 } | 382 } |
| 327 | 383 |
| 384 // Implementation detail: internal macro to create static category and add | |
| 385 // event if the category is enabled. | |
| 386 #define INTERNAL_TRACE_EVENT_ADD_WITH_EXTRA(phase, category, name, extra, \ | |
| 387 arg1_name, arg1_val, arg2_name, arg2_val, flags) \ | |
| 388 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ | |
| 389 if (INTERNAL_TRACE_EVENT_UID(catstatic)->enabled) { \ | |
| 390 base::debug::TraceLog::GetInstance()->AddTraceEvent( \ | |
| 391 phase, INTERNAL_TRACE_EVENT_UID(catstatic), \ | |
| 392 name, static_cast<uint64>(extra), \ | |
| 393 arg1_name, arg1_val, arg2_name, arg2_val, -1, 0, flags); \ | |
| 394 } | |
| 395 | |
| 328 template <typename Type> | 396 template <typename Type> |
| 329 struct StaticMemorySingletonTraits; | 397 struct StaticMemorySingletonTraits; |
| 330 | 398 |
| 331 namespace base { | 399 namespace base { |
| 332 | 400 |
| 333 class RefCountedString; | 401 class RefCountedString; |
| 334 | 402 |
| 335 namespace debug { | 403 namespace debug { |
| 336 | 404 |
| 337 // Categories allow enabling/disabling of streams of trace events | 405 // Categories allow enabling/disabling of streams of trace events |
| 338 struct TraceCategory { | 406 struct TraceCategory { |
| 339 const char* name; | 407 const char* name; |
| 340 volatile bool enabled; | 408 volatile bool enabled; |
| 341 }; | 409 }; |
| 342 | 410 |
| 343 const size_t kTraceMaxNumArgs = 2; | 411 const size_t kTraceMaxNumArgs = 2; |
| 344 | 412 |
| 345 // Phase indicates the nature of an event entry. E.g. part of a begin/end pair. | 413 // Phase indicates the nature of an event entry. E.g. part of a begin/end pair. |
| 346 enum TraceEventPhase { | 414 enum TraceEventPhase { |
| 347 TRACE_EVENT_PHASE_BEGIN, | 415 TRACE_EVENT_PHASE_BEGIN, |
| 348 TRACE_EVENT_PHASE_END, | 416 TRACE_EVENT_PHASE_END, |
| 349 TRACE_EVENT_PHASE_INSTANT, | 417 TRACE_EVENT_PHASE_INSTANT, |
| 418 TRACE_EVENT_PHASE_START, | |
| 419 TRACE_EVENT_PHASE_FINISH, | |
| 350 TRACE_EVENT_PHASE_METADATA | 420 TRACE_EVENT_PHASE_METADATA |
| 351 }; | 421 }; |
| 352 | 422 |
| 353 // Simple union of values. This is much lighter weight than base::Value, which | 423 // Simple union of values. This is much lighter weight than base::Value, which |
| 354 // requires dynamic allocation and a vtable. To keep the trace runtime overhead | 424 // requires dynamic allocation and a vtable. To keep the trace runtime overhead |
| 355 // low, we want constant size storage here. | 425 // low, we want constant size storage here. |
| 356 class BASE_EXPORT TraceValue { | 426 class BASE_EXPORT TraceValue { |
| 357 public: | 427 public: |
| 358 enum Type { | 428 enum Type { |
| 359 TRACE_TYPE_UNDEFINED, | 429 TRACE_TYPE_UNDEFINED, |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 475 Value value_; | 545 Value value_; |
| 476 }; | 546 }; |
| 477 | 547 |
| 478 // Output records are "Events" and can be obtained via the | 548 // Output records are "Events" and can be obtained via the |
| 479 // OutputCallback whenever the tracing system decides to flush. This | 549 // OutputCallback whenever the tracing system decides to flush. This |
| 480 // can happen at any time, on any thread, or you can programatically | 550 // can happen at any time, on any thread, or you can programatically |
| 481 // force it to happen. | 551 // force it to happen. |
| 482 class BASE_EXPORT TraceEvent { | 552 class BASE_EXPORT TraceEvent { |
| 483 public: | 553 public: |
| 484 TraceEvent(); | 554 TraceEvent(); |
| 485 TraceEvent(unsigned long process_id, | 555 TraceEvent(int thread_id, |
| 486 unsigned long thread_id, | |
| 487 TimeTicks timestamp, | 556 TimeTicks timestamp, |
| 488 TraceEventPhase phase, | 557 TraceEventPhase phase, |
| 489 const TraceCategory* category, | 558 const TraceCategory* category, |
| 490 const char* name, | 559 const char* name, |
| 560 uint64 extra, | |
| 491 const char* arg1_name, const TraceValue& arg1_val, | 561 const char* arg1_name, const TraceValue& arg1_val, |
| 492 const char* arg2_name, const TraceValue& arg2_val, | 562 const char* arg2_name, const TraceValue& arg2_val, |
| 493 bool copy); | 563 bool copy); |
| 494 ~TraceEvent(); | 564 ~TraceEvent(); |
| 495 | 565 |
| 496 static const char* GetPhaseString(TraceEventPhase phase); | 566 static const char* GetPhaseString(TraceEventPhase phase); |
| 497 static TraceEventPhase GetPhase(const char* phase); | 567 static TraceEventPhase GetPhase(const char* phase); |
| 498 | 568 |
| 499 // Serialize event data to JSON | 569 // Serialize event data to JSON |
| 500 static void AppendEventsAsJSON(const std::vector<TraceEvent>& events, | 570 static void AppendEventsAsJSON(const std::vector<TraceEvent>& events, |
| 501 size_t start, | 571 size_t start, |
| 502 size_t count, | 572 size_t count, |
| 503 std::string* out); | 573 std::string* out); |
| 504 void AppendAsJSON(std::string* out) const; | 574 void AppendAsJSON(std::string* out) const; |
| 505 | 575 |
| 506 TimeTicks timestamp() const { return timestamp_; } | 576 TimeTicks timestamp() const { return timestamp_; } |
| 507 | 577 |
| 508 // Exposed for unittesting: | 578 // Exposed for unittesting: |
| 509 | 579 |
| 510 const base::RefCountedString* parameter_copy_storage() const { | 580 const base::RefCountedString* parameter_copy_storage() const { |
| 511 return parameter_copy_storage_.get(); | 581 return parameter_copy_storage_.get(); |
| 512 } | 582 } |
| 513 | 583 |
| 514 const char* name() const { return name_; } | 584 const char* name() const { return name_; } |
| 515 | 585 |
| 516 private: | 586 private: |
| 517 unsigned long process_id_; | 587 // Note: these are ordered by size (largest first) for optimal packing. |
|
jbates
2011/11/17 01:15:28
Since I'm adding data to this struct, I took some
| |
| 518 unsigned long thread_id_; | |
| 519 TimeTicks timestamp_; | 588 TimeTicks timestamp_; |
| 520 TraceEventPhase phase_; | 589 // extra_ can be used to store phase-specific data. |
| 590 uint64 extra_; | |
| 591 TraceValue arg_values_[kTraceMaxNumArgs]; | |
| 592 const char* arg_names_[kTraceMaxNumArgs]; | |
| 521 const TraceCategory* category_; | 593 const TraceCategory* category_; |
| 522 const char* name_; | 594 const char* name_; |
| 523 const char* arg_names_[kTraceMaxNumArgs]; | |
| 524 TraceValue arg_values_[kTraceMaxNumArgs]; | |
| 525 scoped_refptr<base::RefCountedString> parameter_copy_storage_; | 595 scoped_refptr<base::RefCountedString> parameter_copy_storage_; |
| 596 int thread_id_; | |
|
jbates
2011/11/17 01:15:28
Changed thread_id to int to save 32-bits in the 64
| |
| 597 TraceEventPhase phase_; | |
| 526 }; | 598 }; |
| 527 | 599 |
| 528 | 600 |
| 529 // TraceResultBuffer collects and converts trace fragments returned by TraceLog | 601 // TraceResultBuffer collects and converts trace fragments returned by TraceLog |
| 530 // to JSON output. | 602 // to JSON output. |
| 531 class BASE_EXPORT TraceResultBuffer { | 603 class BASE_EXPORT TraceResultBuffer { |
| 532 public: | 604 public: |
| 533 typedef base::Callback<void(const std::string&)> OutputCallback; | 605 typedef base::Callback<void(const std::string&)> OutputCallback; |
| 534 | 606 |
| 535 // If you don't need to stream JSON chunks out efficiently, and just want to | 607 // If you don't need to stream JSON chunks out efficiently, and just want to |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 643 // Returns the index in the internal vector of the event if it was added, or | 715 // Returns the index in the internal vector of the event if it was added, or |
| 644 // -1 if the event was not added. | 716 // -1 if the event was not added. |
| 645 // On end events, the return value of the begin event can be specified along | 717 // On end events, the return value of the begin event can be specified along |
| 646 // with a threshold in microseconds. If the elapsed time between begin and end | 718 // with a threshold in microseconds. If the elapsed time between begin and end |
| 647 // is less than the threshold, the begin/end event pair is dropped. | 719 // is less than the threshold, the begin/end event pair is dropped. |
| 648 // If |copy| is set, |name|, |arg_name1| and |arg_name2| will be deep copied | 720 // If |copy| is set, |name|, |arg_name1| and |arg_name2| will be deep copied |
| 649 // into the event; see "Memory scoping note" and TRACE_EVENT_COPY_XXX above. | 721 // into the event; see "Memory scoping note" and TRACE_EVENT_COPY_XXX above. |
| 650 int AddTraceEvent(TraceEventPhase phase, | 722 int AddTraceEvent(TraceEventPhase phase, |
| 651 const TraceCategory* category, | 723 const TraceCategory* category, |
| 652 const char* name, | 724 const char* name, |
| 725 uint64 extra, | |
| 653 const char* arg1_name, TraceValue arg1_val, | 726 const char* arg1_name, TraceValue arg1_val, |
| 654 const char* arg2_name, TraceValue arg2_val, | 727 const char* arg2_name, TraceValue arg2_val, |
| 655 int threshold_begin_id, | 728 int threshold_begin_id, |
| 656 int64 threshold, | 729 int64 threshold, |
| 657 EventFlags flags); | 730 EventFlags flags); |
| 658 static void AddTraceEventEtw(TraceEventPhase phase, | 731 static void AddTraceEventEtw(TraceEventPhase phase, |
| 659 const char* name, | 732 const char* name, |
| 660 const void* id, | 733 const void* id, |
| 661 const char* extra); | 734 const char* extra); |
| 662 static void AddTraceEventEtw(TraceEventPhase phase, | 735 static void AddTraceEventEtw(TraceEventPhase phase, |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 692 // TODO(nduca): switch to per-thread trace buffers to reduce thread | 765 // TODO(nduca): switch to per-thread trace buffers to reduce thread |
| 693 // synchronization. | 766 // synchronization. |
| 694 Lock lock_; | 767 Lock lock_; |
| 695 bool enabled_; | 768 bool enabled_; |
| 696 OutputCallback output_callback_; | 769 OutputCallback output_callback_; |
| 697 BufferFullCallback buffer_full_callback_; | 770 BufferFullCallback buffer_full_callback_; |
| 698 std::vector<TraceEvent> logged_events_; | 771 std::vector<TraceEvent> logged_events_; |
| 699 std::vector<std::string> included_categories_; | 772 std::vector<std::string> included_categories_; |
| 700 std::vector<std::string> excluded_categories_; | 773 std::vector<std::string> excluded_categories_; |
| 701 | 774 |
| 702 base::hash_map<PlatformThreadId, std::string> thread_names_; | 775 base::hash_map<int, std::string> thread_names_; |
| 703 | 776 |
| 704 DISALLOW_COPY_AND_ASSIGN(TraceLog); | 777 DISALLOW_COPY_AND_ASSIGN(TraceLog); |
| 705 }; | 778 }; |
| 706 | 779 |
| 707 namespace internal { | 780 namespace internal { |
| 708 | 781 |
| 709 // Used by TRACE_EVENTx macro. Do not use directly. | 782 // Used by TRACE_EVENTx macro. Do not use directly. |
| 710 class BASE_EXPORT TraceEndOnScopeClose { | 783 class BASE_EXPORT TraceEndOnScopeClose { |
| 711 public: | 784 public: |
| 712 // Note: members of data_ intentionally left uninitialized. See Initialize. | 785 // Note: members of data_ intentionally left uninitialized. See Initialize. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 771 Data* p_data_; | 844 Data* p_data_; |
| 772 Data data_; | 845 Data data_; |
| 773 }; | 846 }; |
| 774 | 847 |
| 775 } // namespace internal | 848 } // namespace internal |
| 776 | 849 |
| 777 } // namespace debug | 850 } // namespace debug |
| 778 } // namespace base | 851 } // namespace base |
| 779 | 852 |
| 780 #endif // BASE_DEBUG_TRACE_EVENT_H_ | 853 #endif // BASE_DEBUG_TRACE_EVENT_H_ |
| OLD | NEW |