| 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 #include "base/debug/trace_event.h" | 5 #include "base/debug/trace_event.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include "base/debug/trace_event_win.h" | 10 #include "base/debug/trace_event_win.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 *out += temp_string; | 76 *out += temp_string; |
| 77 break; | 77 break; |
| 78 case TRACE_TYPE_POINTER: | 78 case TRACE_TYPE_POINTER: |
| 79 base::snprintf(temp_string, arraysize(temp_string), "%llu", | 79 base::snprintf(temp_string, arraysize(temp_string), "%llu", |
| 80 static_cast<unsigned long long>( | 80 static_cast<unsigned long long>( |
| 81 reinterpret_cast<intptr_t>( | 81 reinterpret_cast<intptr_t>( |
| 82 as_pointer()))); | 82 as_pointer()))); |
| 83 *out += temp_string; | 83 *out += temp_string; |
| 84 break; | 84 break; |
| 85 case TRACE_TYPE_STRING: | 85 case TRACE_TYPE_STRING: |
| 86 case TRACE_TYPE_STATIC_STRING: |
| 86 *out += "\""; | 87 *out += "\""; |
| 87 start_pos = out->size(); | 88 start_pos = out->size(); |
| 88 *out += as_string(); | 89 *out += as_string()? as_string() : "NULL"; |
| 89 // replace " character with ' | 90 // replace " character with ' |
| 90 while ((start_pos = out->find_first_of('\"', start_pos)) != | 91 while ((start_pos = out->find_first_of('\"', start_pos)) != |
| 91 std::string::npos) | 92 std::string::npos) |
| 92 (*out)[start_pos] = '\''; | 93 (*out)[start_pos] = '\''; |
| 93 *out += "\""; | 94 *out += "\""; |
| 94 break; | 95 break; |
| 95 default: | 96 default: |
| 96 NOTREACHED() << "Don't know how to print this value"; | 97 NOTREACHED() << "Don't know how to print this value"; |
| 97 break; | 98 break; |
| 98 } | 99 } |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 buffer_full_callback_copy = buffer_full_callback_; | 434 buffer_full_callback_copy = buffer_full_callback_; |
| 434 } | 435 } |
| 435 } // release lock | 436 } // release lock |
| 436 | 437 |
| 437 if (!buffer_full_callback_copy.is_null()) | 438 if (!buffer_full_callback_copy.is_null()) |
| 438 buffer_full_callback_copy.Run(); | 439 buffer_full_callback_copy.Run(); |
| 439 | 440 |
| 440 return ret_begin_id; | 441 return ret_begin_id; |
| 441 } | 442 } |
| 442 | 443 |
| 443 void TraceLog::AddTraceEventEtw(TraceEventPhase phase, | |
| 444 const char* name, | |
| 445 const void* id, | |
| 446 const char* extra) { | |
| 447 // Legacy trace points on windows called to ETW | |
| 448 #if defined(OS_WIN) | |
| 449 TraceEventETWProvider::Trace(name, phase, id, extra); | |
| 450 #endif | |
| 451 | |
| 452 // Also add new trace event behavior | |
| 453 static const TraceCategory* category = GetCategory("ETW Trace Event"); | |
| 454 if (category->enabled) { | |
| 455 TraceLog* tracelog = TraceLog::GetInstance(); | |
| 456 if (!tracelog) | |
| 457 return; | |
| 458 tracelog->AddTraceEvent(phase, category, name, | |
| 459 "id", id, | |
| 460 "extra", extra ? extra : "", | |
| 461 -1, 0, false); | |
| 462 } | |
| 463 } | |
| 464 | |
| 465 void TraceLog::AddCurrentMetadataEvents() { | 444 void TraceLog::AddCurrentMetadataEvents() { |
| 466 lock_.AssertAcquired(); | 445 lock_.AssertAcquired(); |
| 467 for(base::hash_map<PlatformThreadId, std::string>::iterator it = | 446 for(base::hash_map<PlatformThreadId, std::string>::iterator it = |
| 468 thread_names_.begin(); | 447 thread_names_.begin(); |
| 469 it != thread_names_.end(); | 448 it != thread_names_.end(); |
| 470 it++) { | 449 it++) { |
| 471 if (!it->second.empty()) | 450 if (!it->second.empty()) |
| 472 logged_events_.push_back( | 451 logged_events_.push_back( |
| 473 TraceEvent(static_cast<unsigned long>(base::GetCurrentProcId()), | 452 TraceEvent(static_cast<unsigned long>(base::GetCurrentProcId()), |
| 474 it->first, | 453 it->first, |
| 475 TimeTicks(), base::debug::TRACE_EVENT_PHASE_METADATA, | 454 TimeTicks(), base::debug::TRACE_EVENT_PHASE_METADATA, |
| 476 g_category_metadata, "thread_name", | 455 g_category_metadata, "thread_name", |
| 477 "name", it->second.c_str(), | 456 "name", it->second, |
| 478 NULL, 0, | 457 NULL, 0, |
| 479 false)); | 458 false)); |
| 480 } | 459 } |
| 481 } | 460 } |
| 482 | 461 |
| 483 void TraceLog::Resurrect() { | 462 void TraceLog::Resurrect() { |
| 484 StaticMemorySingletonTraits<TraceLog>::Resurrect(); | 463 StaticMemorySingletonTraits<TraceLog>::Resurrect(); |
| 485 } | 464 } |
| 486 | 465 |
| 487 namespace internal { | 466 namespace internal { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 p_data_->name, | 504 p_data_->name, |
| 526 NULL, 0, NULL, 0, | 505 NULL, 0, NULL, 0, |
| 527 p_data_->threshold_begin_id, p_data_->threshold, false); | 506 p_data_->threshold_begin_id, p_data_->threshold, false); |
| 528 } | 507 } |
| 529 } | 508 } |
| 530 | 509 |
| 531 } // namespace internal | 510 } // namespace internal |
| 532 | 511 |
| 533 } // namespace debug | 512 } // namespace debug |
| 534 } // namespace base | 513 } // namespace base |
| OLD | NEW |