| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/trace_event/trace_log.h" | 5 #include "base/trace_event/trace_log.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "base/strings/string_split.h" | 25 #include "base/strings/string_split.h" |
| 26 #include "base/strings/string_tokenizer.h" | 26 #include "base/strings/string_tokenizer.h" |
| 27 #include "base/strings/stringprintf.h" | 27 #include "base/strings/stringprintf.h" |
| 28 #include "base/sys_info.h" | 28 #include "base/sys_info.h" |
| 29 #include "base/threading/platform_thread.h" | 29 #include "base/threading/platform_thread.h" |
| 30 #include "base/threading/thread_id_name_manager.h" | 30 #include "base/threading/thread_id_name_manager.h" |
| 31 #include "base/threading/thread_task_runner_handle.h" | 31 #include "base/threading/thread_task_runner_handle.h" |
| 32 #include "base/threading/worker_pool.h" | 32 #include "base/threading/worker_pool.h" |
| 33 #include "base/time/time.h" | 33 #include "base/time/time.h" |
| 34 #include "base/trace_event/category_registry.h" | 34 #include "base/trace_event/category_registry.h" |
| 35 #include "base/trace_event/event_filter_registry.h" |
| 36 #include "base/trace_event/event_name_filter.h" |
| 35 #include "base/trace_event/heap_profiler.h" | 37 #include "base/trace_event/heap_profiler.h" |
| 36 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" | 38 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" |
| 39 #include "base/trace_event/heap_profiler_event_filter.h" |
| 37 #include "base/trace_event/memory_dump_manager.h" | 40 #include "base/trace_event/memory_dump_manager.h" |
| 38 #include "base/trace_event/memory_dump_provider.h" | 41 #include "base/trace_event/memory_dump_provider.h" |
| 39 #include "base/trace_event/process_memory_dump.h" | 42 #include "base/trace_event/process_memory_dump.h" |
| 40 #include "base/trace_event/trace_buffer.h" | 43 #include "base/trace_event/trace_buffer.h" |
| 41 #include "base/trace_event/trace_event.h" | 44 #include "base/trace_event/trace_event.h" |
| 42 #include "base/trace_event/trace_event_synthetic_delay.h" | 45 #include "base/trace_event/trace_event_synthetic_delay.h" |
| 43 #include "build/build_config.h" | 46 #include "build/build_config.h" |
| 44 | 47 |
| 45 #if defined(OS_WIN) | 48 #if defined(OS_WIN) |
| 46 #include "base/trace_event/trace_event_etw_export_win.h" | 49 #include "base/trace_event/trace_event_etw_export_win.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 77 kTraceEventVectorBufferChunks <= TraceBufferChunk::kMaxChunkIndex, | 80 kTraceEventVectorBufferChunks <= TraceBufferChunk::kMaxChunkIndex, |
| 78 "Too many vector buffer chunks"); | 81 "Too many vector buffer chunks"); |
| 79 const size_t kTraceEventRingBufferChunks = kTraceEventVectorBufferChunks / 4; | 82 const size_t kTraceEventRingBufferChunks = kTraceEventVectorBufferChunks / 4; |
| 80 | 83 |
| 81 // ECHO_TO_CONSOLE needs a small buffer to hold the unfinished COMPLETE events. | 84 // ECHO_TO_CONSOLE needs a small buffer to hold the unfinished COMPLETE events. |
| 82 const size_t kEchoToConsoleTraceEventBufferChunks = 256; | 85 const size_t kEchoToConsoleTraceEventBufferChunks = 256; |
| 83 | 86 |
| 84 const size_t kTraceEventBufferSizeInBytes = 100 * 1024; | 87 const size_t kTraceEventBufferSizeInBytes = 100 * 1024; |
| 85 const int kThreadFlushTimeoutMs = 3000; | 88 const int kThreadFlushTimeoutMs = 3000; |
| 86 | 89 |
| 87 const char kEventNameWhitelist[] = "event_name_whitelist"; | |
| 88 | |
| 89 #define MAX_TRACE_EVENT_FILTERS 32 | |
| 90 | |
| 91 // List of TraceEventFilter objects from the most recent tracing session. | |
| 92 base::LazyInstance<std::vector<std::unique_ptr<TraceLog::TraceEventFilter>>>:: | |
| 93 Leaky g_category_group_filters = LAZY_INSTANCE_INITIALIZER; | |
| 94 | |
| 95 class EventNameFilter : public TraceLog::TraceEventFilter { | |
| 96 public: | |
| 97 EventNameFilter(const base::DictionaryValue* filter_args) { | |
| 98 const base::ListValue* whitelist = nullptr; | |
| 99 if (filter_args->GetList(kEventNameWhitelist, &whitelist)) { | |
| 100 for (size_t i = 0; i < whitelist->GetSize(); ++i) { | |
| 101 std::string event_name; | |
| 102 if (!whitelist->GetString(i, &event_name)) | |
| 103 continue; | |
| 104 | |
| 105 whitelist_.insert(event_name); | |
| 106 } | |
| 107 } | |
| 108 } | |
| 109 | |
| 110 bool FilterTraceEvent(const TraceEvent& trace_event) const override { | |
| 111 return ContainsKey(whitelist_, trace_event.name()); | |
| 112 } | |
| 113 | |
| 114 private: | |
| 115 std::unordered_set<std::string> whitelist_; | |
| 116 }; | |
| 117 | |
| 118 // This filter is used to record trace events as pseudo stack for the heap | |
| 119 // profiler. It does not filter-out any events from the trace, ie. the behavior | |
| 120 // of trace events being added to TraceLog remains same: the events are added | |
| 121 // iff enabled for recording and not filtered-out by any other filter. | |
| 122 class HeapProfilerFilter : public TraceLog::TraceEventFilter { | |
| 123 public: | |
| 124 HeapProfilerFilter() {} | |
| 125 | |
| 126 bool FilterTraceEvent(const TraceEvent& trace_event) const override { | |
| 127 if (AllocationContextTracker::capture_mode() != | |
| 128 AllocationContextTracker::CaptureMode::PSEUDO_STACK) { | |
| 129 return true; | |
| 130 } | |
| 131 | |
| 132 // TODO(primiano): Add support for events with copied name crbug.com/581079. | |
| 133 if (trace_event.flags() & TRACE_EVENT_FLAG_COPY) | |
| 134 return true; | |
| 135 | |
| 136 const char* category_name = | |
| 137 TraceLog::GetCategoryGroupName(trace_event.category_group_enabled()); | |
| 138 if (trace_event.phase() == TRACE_EVENT_PHASE_BEGIN || | |
| 139 trace_event.phase() == TRACE_EVENT_PHASE_COMPLETE) { | |
| 140 AllocationContextTracker::GetInstanceForCurrentThread() | |
| 141 ->PushPseudoStackFrame({category_name, trace_event.name()}); | |
| 142 } else if (trace_event.phase() == TRACE_EVENT_PHASE_END) { | |
| 143 // The pop for |TRACE_EVENT_PHASE_COMPLETE| events is in |EndEvent|. | |
| 144 AllocationContextTracker::GetInstanceForCurrentThread() | |
| 145 ->PopPseudoStackFrame({category_name, trace_event.name()}); | |
| 146 } | |
| 147 // Do not filter-out any events and always return true. TraceLog adds the | |
| 148 // event only if it is enabled for recording. | |
| 149 return true; | |
| 150 } | |
| 151 | |
| 152 void EndEvent(const char* name, const char* category_group) override { | |
| 153 if (AllocationContextTracker::capture_mode() == | |
| 154 AllocationContextTracker::CaptureMode::PSEUDO_STACK) { | |
| 155 AllocationContextTracker::GetInstanceForCurrentThread() | |
| 156 ->PopPseudoStackFrame({category_group, name}); | |
| 157 } | |
| 158 } | |
| 159 }; | |
| 160 | |
| 161 TraceLog::TraceEventFilterConstructorForTesting | |
| 162 g_trace_event_filter_constructor_for_testing = nullptr; | |
| 163 | |
| 164 // The name of the current thread. This is used to decide if the current | 90 // The name of the current thread. This is used to decide if the current |
| 165 // thread name has changed. We combine all the seen thread names into the | 91 // thread name has changed. We combine all the seen thread names into the |
| 166 // output name for the thread. | 92 // output name for the thread. |
| 167 LazyInstance<ThreadLocalPointer<const char>>::Leaky g_current_thread_name = | 93 LazyInstance<ThreadLocalPointer<const char>>::Leaky g_current_thread_name = |
| 168 LAZY_INSTANCE_INITIALIZER; | 94 LAZY_INSTANCE_INITIALIZER; |
| 169 | 95 |
| 170 ThreadTicks ThreadNow() { | 96 ThreadTicks ThreadNow() { |
| 171 return ThreadTicks::IsSupported() ? ThreadTicks::Now() : ThreadTicks(); | 97 return ThreadTicks::IsSupported() ? ThreadTicks::Now() : ThreadTicks(); |
| 172 } | 98 } |
| 173 | 99 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 DCHECK(chunk_seq); | 151 DCHECK(chunk_seq); |
| 226 DCHECK(chunk_index <= TraceBufferChunk::kMaxChunkIndex); | 152 DCHECK(chunk_index <= TraceBufferChunk::kMaxChunkIndex); |
| 227 DCHECK(event_index < TraceBufferChunk::kTraceBufferChunkSize); | 153 DCHECK(event_index < TraceBufferChunk::kTraceBufferChunkSize); |
| 228 DCHECK(chunk_index <= std::numeric_limits<uint16_t>::max()); | 154 DCHECK(chunk_index <= std::numeric_limits<uint16_t>::max()); |
| 229 handle->chunk_seq = chunk_seq; | 155 handle->chunk_seq = chunk_seq; |
| 230 handle->chunk_index = static_cast<uint16_t>(chunk_index); | 156 handle->chunk_index = static_cast<uint16_t>(chunk_index); |
| 231 handle->event_index = static_cast<uint16_t>(event_index); | 157 handle->event_index = static_cast<uint16_t>(event_index); |
| 232 } | 158 } |
| 233 | 159 |
| 234 template <typename Function> | 160 template <typename Function> |
| 235 void ForEachCategoryGroupFilter(const unsigned char* category_group_enabled, | 161 void ForEachCategoryFilter(const unsigned char* category_group_enabled, |
| 236 Function filter_fn) { | 162 Function filter_fn) { |
| 237 const TraceCategory* category = | 163 auto* cat = CategoryRegistry::GetCategoryByStatePtr(category_group_enabled); |
| 238 CategoryRegistry::GetCategoryByStatePtr(category_group_enabled); | 164 uint32_t filter_bitmap = cat->enabled_filters(); |
| 239 uint32_t filter_bitmap = category->enabled_filters(); | 165 for (int index = 0; filter_bitmap != 0; filter_bitmap >>= 1, index++) { |
| 240 int index = 0; | 166 if (filter_bitmap & 1) |
| 241 while (filter_bitmap) { | 167 filter_fn(EventFilterRegistry::Get(index)); |
| 242 if (filter_bitmap & 1 && g_category_group_filters.Get()[index]) | |
| 243 filter_fn(g_category_group_filters.Get()[index].get()); | |
| 244 filter_bitmap = filter_bitmap >> 1; | |
| 245 index++; | |
| 246 } | 168 } |
| 247 } | 169 } |
| 248 | 170 |
| 249 } // namespace | 171 } // namespace |
| 250 | 172 |
| 251 // A helper class that allows the lock to be acquired in the middle of the scope | 173 // A helper class that allows the lock to be acquired in the middle of the scope |
| 252 // and unlocks at the end of scope if locked. | 174 // and unlocks at the end of scope if locked. |
| 253 class TraceLog::OptionalAutoLock { | 175 class TraceLog::OptionalAutoLock { |
| 254 public: | 176 public: |
| 255 explicit OptionalAutoLock(Lock* lock) : lock_(lock), locked_(false) {} | 177 explicit OptionalAutoLock(Lock* lock) : lock_(lock), locked_(false) {} |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 } | 454 } |
| 533 | 455 |
| 534 #if defined(OS_WIN) | 456 #if defined(OS_WIN) |
| 535 if (base::trace_event::TraceEventETWExport::IsCategoryGroupEnabled( | 457 if (base::trace_event::TraceEventETWExport::IsCategoryGroupEnabled( |
| 536 category->name())) { | 458 category->name())) { |
| 537 state_flags |= TraceCategory::ENABLED_FOR_ETW_EXPORT; | 459 state_flags |= TraceCategory::ENABLED_FOR_ETW_EXPORT; |
| 538 } | 460 } |
| 539 #endif | 461 #endif |
| 540 | 462 |
| 541 uint32_t enabled_filters_bitmap = 0; | 463 uint32_t enabled_filters_bitmap = 0; |
| 542 int index = 0; | 464 for (const auto& filter_config : enabled_event_filters_) { |
| 543 for (const auto& event_filter : enabled_event_filters_) { | 465 if (filter_config.IsCategoryGroupEnabled(category->name())) { |
| 544 if (event_filter.IsCategoryGroupEnabled(category->name())) { | |
| 545 state_flags |= TraceCategory::ENABLED_FOR_FILTERING; | 466 state_flags |= TraceCategory::ENABLED_FOR_FILTERING; |
| 546 DCHECK(g_category_group_filters.Get()[index]); | 467 const int filter_index = EventFilterRegistry::GetIndexByName( |
| 547 enabled_filters_bitmap |= 1 << index; | 468 filter_config.predicate_name().c_str()); |
| 548 } | 469 if (filter_index == -1) { |
| 549 if (index++ >= MAX_TRACE_EVENT_FILTERS) { | 470 NOTREACHED(); |
| 550 NOTREACHED(); | 471 continue; |
| 551 break; | 472 } |
| 473 enabled_filters_bitmap |= 1ul << filter_index; |
| 552 } | 474 } |
| 553 } | 475 } |
| 554 category->set_enabled_filters(enabled_filters_bitmap); | 476 category->set_enabled_filters(enabled_filters_bitmap); |
| 555 category->set_state(state_flags); | 477 category->set_state(state_flags); |
| 556 } | 478 } |
| 557 | 479 |
| 558 void TraceLog::UpdateCategoryRegistry() { | 480 void TraceLog::UpdateCategoryRegistry() { |
| 559 CreateFiltersForTraceConfig(); | 481 CreateFiltersForTraceConfig(); |
| 560 for (TraceCategory& category : CategoryRegistry::GetAllCategories()) { | 482 for (TraceCategory& category : CategoryRegistry::GetAllCategories()) { |
| 561 UpdateCategoryState(&category); | 483 UpdateCategoryState(&category); |
| 562 } | 484 } |
| 563 } | 485 } |
| 564 | 486 |
| 565 void TraceLog::CreateFiltersForTraceConfig() { | 487 void TraceLog::CreateFiltersForTraceConfig() { |
| 488 lock_.AssertAcquired(); |
| 489 |
| 566 if (!(enabled_modes_ & FILTERING_MODE)) | 490 if (!(enabled_modes_ & FILTERING_MODE)) |
| 567 return; | 491 return; |
| 568 | 492 |
| 569 // Filters were already added and tracing could be enabled. Filters list | 493 // |enabled_event_filters_| is the TraceConfig's filter list at the time |
| 570 // cannot be changed when trace events are using them. | 494 // tracing was started (?). |
| 571 if (g_category_group_filters.Get().size()) | |
| 572 return; | |
| 573 | |
| 574 for (auto& event_filter : enabled_event_filters_) { | 495 for (auto& event_filter : enabled_event_filters_) { |
| 575 if (g_category_group_filters.Get().size() >= MAX_TRACE_EVENT_FILTERS) { | 496 std::unique_ptr<TraceEventFilter> new_filter; |
| 576 NOTREACHED() | 497 if (event_filter.predicate_name() == EventNameFilter::kName) { |
| 577 << "Too many trace event filters installed in the current session"; | 498 auto* flt = EventFilterRegistry::RegisterFilterLocked<EventNameFilter>(); |
| 578 break; | 499 auto whitelist = MakeUnique<std::unordered_set<std::string>>(); |
| 500 const ListValue* list = nullptr; |
| 501 if (event_filter.filter_args()->GetList("event_name_whitelist", &list)) { |
| 502 for (size_t i = 0; i < list->GetSize(); ++i) { |
| 503 std::string event_name; |
| 504 if (list->GetString(i, &event_name)) |
| 505 whitelist->insert(event_name); |
| 506 } |
| 507 } |
| 508 flt->SetWhitelistedEventNames(std::move(whitelist)); |
| 509 } else if (event_filter.predicate_name() == |
| 510 HeapProfilerEventFilter::kName) { |
| 511 EventFilterRegistry::RegisterFilterLocked<HeapProfilerEventFilter>(); |
| 512 } else { |
| 513 // Check that the filter has been already registered externally. |
| 514 DCHECK(EventFilterRegistry::GetByName( |
| 515 event_filter.predicate_name().c_str())); |
| 579 } | 516 } |
| 580 | |
| 581 std::unique_ptr<TraceEventFilter> new_filter; | |
| 582 if (event_filter.predicate_name() == | |
| 583 TraceEventFilter::kEventWhitelistPredicate) { | |
| 584 new_filter = MakeUnique<EventNameFilter>(event_filter.filter_args()); | |
| 585 } else if (event_filter.predicate_name() == | |
| 586 TraceEventFilter::kHeapProfilerPredicate) { | |
| 587 new_filter = MakeUnique<HeapProfilerFilter>(); | |
| 588 } else if (event_filter.predicate_name() == "testing_predicate") { | |
| 589 CHECK(g_trace_event_filter_constructor_for_testing); | |
| 590 new_filter = g_trace_event_filter_constructor_for_testing(); | |
| 591 } else { | |
| 592 NOTREACHED(); | |
| 593 } | |
| 594 g_category_group_filters.Get().push_back(std::move(new_filter)); | |
| 595 } | 517 } |
| 596 } | 518 } |
| 597 | 519 |
| 598 void TraceLog::UpdateSyntheticDelaysFromTraceConfig() { | 520 void TraceLog::UpdateSyntheticDelaysFromTraceConfig() { |
| 599 ResetTraceEventSyntheticDelays(); | 521 ResetTraceEventSyntheticDelays(); |
| 600 const TraceConfig::StringList& delays = | 522 const TraceConfig::StringList& delays = |
| 601 trace_config_.GetSyntheticDelayValues(); | 523 trace_config_.GetSyntheticDelayValues(); |
| 602 TraceConfig::StringList::const_iterator ci; | 524 TraceConfig::StringList::const_iterator ci; |
| 603 for (ci = delays.begin(); ci != delays.end(); ++ci) { | 525 for (ci = delays.begin(); ci != delays.end(); ++ci) { |
| 604 StringTokenizer tokens(*ci, ";"); | 526 StringTokenizer tokens(*ci, ";"); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 | 569 |
| 648 InternalTraceOptions old_options = trace_options(); | 570 InternalTraceOptions old_options = trace_options(); |
| 649 | 571 |
| 650 if (dispatching_to_observer_list_) { | 572 if (dispatching_to_observer_list_) { |
| 651 // TODO(ssid): Change to NOTREACHED after fixing crbug.com/625170. | 573 // TODO(ssid): Change to NOTREACHED after fixing crbug.com/625170. |
| 652 DLOG(ERROR) | 574 DLOG(ERROR) |
| 653 << "Cannot manipulate TraceLog::Enabled state from an observer."; | 575 << "Cannot manipulate TraceLog::Enabled state from an observer."; |
| 654 return; | 576 return; |
| 655 } | 577 } |
| 656 | 578 |
| 657 // Clear all filters from previous tracing session. These filters are not | |
| 658 // cleared at the end of tracing because some threads which hit trace event | |
| 659 // when disabling, could try to use the filters. | |
| 660 if (!enabled_modes_) | |
| 661 g_category_group_filters.Get().clear(); | |
| 662 | |
| 663 // Update trace config for recording. | 579 // Update trace config for recording. |
| 664 const bool already_recording = enabled_modes_ & RECORDING_MODE; | 580 const bool already_recording = enabled_modes_ & RECORDING_MODE; |
| 665 if (modes_to_enable & RECORDING_MODE) { | 581 if (modes_to_enable & RECORDING_MODE) { |
| 666 if (already_recording) { | 582 if (already_recording) { |
| 667 // TODO(ssid): Stop suporting enabling of RECODING_MODE when already | 583 // TODO(ssid): Stop suporting enabling of RECODING_MODE when already |
| 668 // enabled crbug.com/625170. | 584 // enabled crbug.com/625170. |
| 669 DCHECK_EQ(new_options, old_options) << "Attempting to re-enable " | 585 DCHECK_EQ(new_options, old_options) << "Attempting to re-enable " |
| 670 "tracing with a different set " | 586 "tracing with a different set " |
| 671 "of options."; | 587 "of options."; |
| 672 trace_config_.Merge(trace_config); | 588 trace_config_.Merge(trace_config); |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1331 std::unique_ptr<TraceEvent> filtered_trace_event; | 1247 std::unique_ptr<TraceEvent> filtered_trace_event; |
| 1332 bool disabled_by_filters = false; | 1248 bool disabled_by_filters = false; |
| 1333 if (*category_group_enabled & TraceCategory::ENABLED_FOR_FILTERING) { | 1249 if (*category_group_enabled & TraceCategory::ENABLED_FOR_FILTERING) { |
| 1334 std::unique_ptr<TraceEvent> new_trace_event(new TraceEvent); | 1250 std::unique_ptr<TraceEvent> new_trace_event(new TraceEvent); |
| 1335 new_trace_event->Initialize(thread_id, offset_event_timestamp, thread_now, | 1251 new_trace_event->Initialize(thread_id, offset_event_timestamp, thread_now, |
| 1336 phase, category_group_enabled, name, scope, id, | 1252 phase, category_group_enabled, name, scope, id, |
| 1337 bind_id, num_args, arg_names, arg_types, | 1253 bind_id, num_args, arg_names, arg_types, |
| 1338 arg_values, convertable_values, flags); | 1254 arg_values, convertable_values, flags); |
| 1339 | 1255 |
| 1340 disabled_by_filters = true; | 1256 disabled_by_filters = true; |
| 1341 ForEachCategoryGroupFilter( | 1257 ForEachCategoryFilter( |
| 1342 category_group_enabled, [&new_trace_event, &disabled_by_filters]( | 1258 category_group_enabled, [&new_trace_event, &disabled_by_filters]( |
| 1343 TraceEventFilter* trace_event_filter) { | 1259 TraceEventFilter* trace_event_filter) { |
| 1344 if (trace_event_filter->FilterTraceEvent(*new_trace_event)) | 1260 if (trace_event_filter->FilterTraceEvent(*new_trace_event)) |
| 1345 disabled_by_filters = false; | 1261 disabled_by_filters = false; |
| 1346 }); | 1262 }); |
| 1347 if (!disabled_by_filters) | 1263 if (!disabled_by_filters) |
| 1348 filtered_trace_event = std::move(new_trace_event); | 1264 filtered_trace_event = std::move(new_trace_event); |
| 1349 } | 1265 } |
| 1350 | 1266 |
| 1351 // If enabled for recording, the event should be added only if one of the | 1267 // If enabled for recording, the event should be added only if one of the |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1461 if (phase == TRACE_EVENT_PHASE_BEGIN) | 1377 if (phase == TRACE_EVENT_PHASE_BEGIN) |
| 1462 thread_event_start_times_[thread_id].push(timestamp); | 1378 thread_event_start_times_[thread_id].push(timestamp); |
| 1463 | 1379 |
| 1464 return log.str(); | 1380 return log.str(); |
| 1465 } | 1381 } |
| 1466 | 1382 |
| 1467 void TraceLog::EndFilteredEvent(const unsigned char* category_group_enabled, | 1383 void TraceLog::EndFilteredEvent(const unsigned char* category_group_enabled, |
| 1468 const char* name, | 1384 const char* name, |
| 1469 TraceEventHandle handle) { | 1385 TraceEventHandle handle) { |
| 1470 const char* category_name = GetCategoryGroupName(category_group_enabled); | 1386 const char* category_name = GetCategoryGroupName(category_group_enabled); |
| 1471 ForEachCategoryGroupFilter( | 1387 ForEachCategoryFilter( |
| 1472 category_group_enabled, | 1388 category_group_enabled, |
| 1473 [name, category_name](TraceEventFilter* trace_event_filter) { | 1389 [name, category_name](TraceEventFilter* trace_event_filter) { |
| 1474 trace_event_filter->EndEvent(name, category_name); | 1390 trace_event_filter->EndEvent(category_name, name); |
| 1475 }); | 1391 }); |
| 1476 } | 1392 } |
| 1477 | 1393 |
| 1478 void TraceLog::UpdateTraceEventDuration( | 1394 void TraceLog::UpdateTraceEventDuration( |
| 1479 const unsigned char* category_group_enabled, | 1395 const unsigned char* category_group_enabled, |
| 1480 const char* name, | 1396 const char* name, |
| 1481 TraceEventHandle handle) { | 1397 TraceEventHandle handle) { |
| 1482 char category_group_enabled_local = *category_group_enabled; | 1398 char category_group_enabled_local = *category_group_enabled; |
| 1483 if (!category_group_enabled_local) | 1399 if (!category_group_enabled_local) |
| 1484 return; | 1400 return; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1605 "overflowed_at_ts", | 1521 "overflowed_at_ts", |
| 1606 buffer_limit_reached_timestamp_); | 1522 buffer_limit_reached_timestamp_); |
| 1607 } | 1523 } |
| 1608 } | 1524 } |
| 1609 | 1525 |
| 1610 void TraceLog::DeleteForTesting() { | 1526 void TraceLog::DeleteForTesting() { |
| 1611 internal::DeleteTraceLogForTesting::Delete(); | 1527 internal::DeleteTraceLogForTesting::Delete(); |
| 1612 CategoryRegistry::ResetForTesting(); | 1528 CategoryRegistry::ResetForTesting(); |
| 1613 } | 1529 } |
| 1614 | 1530 |
| 1615 void TraceLog::SetTraceEventFilterConstructorForTesting( | |
| 1616 TraceEventFilterConstructorForTesting predicate) { | |
| 1617 g_trace_event_filter_constructor_for_testing = predicate; | |
| 1618 } | |
| 1619 | |
| 1620 TraceEvent* TraceLog::GetEventByHandle(TraceEventHandle handle) { | 1531 TraceEvent* TraceLog::GetEventByHandle(TraceEventHandle handle) { |
| 1621 return GetEventByHandleInternal(handle, NULL); | 1532 return GetEventByHandleInternal(handle, NULL); |
| 1622 } | 1533 } |
| 1623 | 1534 |
| 1624 TraceEvent* TraceLog::GetEventByHandleInternal(TraceEventHandle handle, | 1535 TraceEvent* TraceLog::GetEventByHandleInternal(TraceEventHandle handle, |
| 1625 OptionalAutoLock* lock) { | 1536 OptionalAutoLock* lock) { |
| 1626 if (!handle.chunk_seq) | 1537 if (!handle.chunk_seq) |
| 1627 return NULL; | 1538 return NULL; |
| 1628 | 1539 |
| 1629 DCHECK(handle.chunk_seq); | 1540 DCHECK(handle.chunk_seq); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1797 } | 1708 } |
| 1798 | 1709 |
| 1799 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { | 1710 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { |
| 1800 if (*category_group_enabled_) { | 1711 if (*category_group_enabled_) { |
| 1801 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, | 1712 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, |
| 1802 event_handle_); | 1713 event_handle_); |
| 1803 } | 1714 } |
| 1804 } | 1715 } |
| 1805 | 1716 |
| 1806 } // namespace trace_event_internal | 1717 } // namespace trace_event_internal |
| OLD | NEW |