| 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_name_filter.h" |
| 35 #include "base/trace_event/heap_profiler.h" | 36 #include "base/trace_event/heap_profiler.h" |
| 36 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" | 37 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" |
| 38 #include "base/trace_event/heap_profiler_event_filter.h" |
| 37 #include "base/trace_event/memory_dump_manager.h" | 39 #include "base/trace_event/memory_dump_manager.h" |
| 38 #include "base/trace_event/memory_dump_provider.h" | 40 #include "base/trace_event/memory_dump_provider.h" |
| 39 #include "base/trace_event/process_memory_dump.h" | 41 #include "base/trace_event/process_memory_dump.h" |
| 40 #include "base/trace_event/trace_buffer.h" | 42 #include "base/trace_event/trace_buffer.h" |
| 41 #include "base/trace_event/trace_event.h" | 43 #include "base/trace_event/trace_event.h" |
| 42 #include "base/trace_event/trace_event_synthetic_delay.h" | 44 #include "base/trace_event/trace_event_synthetic_delay.h" |
| 43 #include "build/build_config.h" | 45 #include "build/build_config.h" |
| 44 | 46 |
| 45 #if defined(OS_WIN) | 47 #if defined(OS_WIN) |
| 46 #include "base/trace_event/trace_event_etw_export_win.h" | 48 #include "base/trace_event/trace_event_etw_export_win.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 77 kTraceEventVectorBufferChunks <= TraceBufferChunk::kMaxChunkIndex, | 79 kTraceEventVectorBufferChunks <= TraceBufferChunk::kMaxChunkIndex, |
| 78 "Too many vector buffer chunks"); | 80 "Too many vector buffer chunks"); |
| 79 const size_t kTraceEventRingBufferChunks = kTraceEventVectorBufferChunks / 4; | 81 const size_t kTraceEventRingBufferChunks = kTraceEventVectorBufferChunks / 4; |
| 80 | 82 |
| 81 // ECHO_TO_CONSOLE needs a small buffer to hold the unfinished COMPLETE events. | 83 // ECHO_TO_CONSOLE needs a small buffer to hold the unfinished COMPLETE events. |
| 82 const size_t kEchoToConsoleTraceEventBufferChunks = 256; | 84 const size_t kEchoToConsoleTraceEventBufferChunks = 256; |
| 83 | 85 |
| 84 const size_t kTraceEventBufferSizeInBytes = 100 * 1024; | 86 const size_t kTraceEventBufferSizeInBytes = 100 * 1024; |
| 85 const int kThreadFlushTimeoutMs = 3000; | 87 const int kThreadFlushTimeoutMs = 3000; |
| 86 | 88 |
| 87 const char kEventNameWhitelist[] = "event_name_whitelist"; | |
| 88 | |
| 89 #define MAX_TRACE_EVENT_FILTERS 32 | 89 #define MAX_TRACE_EVENT_FILTERS 32 |
| 90 | 90 |
| 91 // List of TraceEventFilter objects from the most recent tracing session. | 91 // List of TraceEventFilter objects from the most recent tracing session. |
| 92 base::LazyInstance<std::vector<std::unique_ptr<TraceLog::TraceEventFilter>>>:: | 92 base::LazyInstance<std::vector<std::unique_ptr<TraceEventFilter>>>::Leaky |
| 93 Leaky g_category_group_filters = LAZY_INSTANCE_INITIALIZER; | 93 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 | 94 |
| 164 // The name of the current thread. This is used to decide if the current | 95 // 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 | 96 // thread name has changed. We combine all the seen thread names into the |
| 166 // output name for the thread. | 97 // output name for the thread. |
| 167 LazyInstance<ThreadLocalPointer<const char>>::Leaky g_current_thread_name = | 98 LazyInstance<ThreadLocalPointer<const char>>::Leaky g_current_thread_name = |
| 168 LAZY_INSTANCE_INITIALIZER; | 99 LAZY_INSTANCE_INITIALIZER; |
| 169 | 100 |
| 170 ThreadTicks ThreadNow() { | 101 ThreadTicks ThreadNow() { |
| 171 return ThreadTicks::IsSupported() ? ThreadTicks::Now() : ThreadTicks(); | 102 return ThreadTicks::IsSupported() ? ThreadTicks::Now() : ThreadTicks(); |
| 172 } | 103 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 DCHECK(chunk_seq); | 156 DCHECK(chunk_seq); |
| 226 DCHECK(chunk_index <= TraceBufferChunk::kMaxChunkIndex); | 157 DCHECK(chunk_index <= TraceBufferChunk::kMaxChunkIndex); |
| 227 DCHECK(event_index < TraceBufferChunk::kTraceBufferChunkSize); | 158 DCHECK(event_index < TraceBufferChunk::kTraceBufferChunkSize); |
| 228 DCHECK(chunk_index <= std::numeric_limits<uint16_t>::max()); | 159 DCHECK(chunk_index <= std::numeric_limits<uint16_t>::max()); |
| 229 handle->chunk_seq = chunk_seq; | 160 handle->chunk_seq = chunk_seq; |
| 230 handle->chunk_index = static_cast<uint16_t>(chunk_index); | 161 handle->chunk_index = static_cast<uint16_t>(chunk_index); |
| 231 handle->event_index = static_cast<uint16_t>(event_index); | 162 handle->event_index = static_cast<uint16_t>(event_index); |
| 232 } | 163 } |
| 233 | 164 |
| 234 template <typename Function> | 165 template <typename Function> |
| 235 void ForEachCategoryGroupFilter(const unsigned char* category_group_enabled, | 166 void ForEachCategoryFilter(const unsigned char* category_group_enabled, |
| 236 Function filter_fn) { | 167 Function filter_fn) { |
| 237 const TraceCategory* category = | 168 const TraceCategory* category = |
| 238 CategoryRegistry::GetCategoryByStatePtr(category_group_enabled); | 169 CategoryRegistry::GetCategoryByStatePtr(category_group_enabled); |
| 239 uint32_t filter_bitmap = category->enabled_filters(); | 170 uint32_t filter_bitmap = category->enabled_filters(); |
| 240 int index = 0; | 171 for (int index = 0; filter_bitmap != 0; filter_bitmap >>= 1, index++) { |
| 241 while (filter_bitmap) { | |
| 242 if (filter_bitmap & 1 && g_category_group_filters.Get()[index]) | 172 if (filter_bitmap & 1 && g_category_group_filters.Get()[index]) |
| 243 filter_fn(g_category_group_filters.Get()[index].get()); | 173 filter_fn(g_category_group_filters.Get()[index].get()); |
| 244 filter_bitmap = filter_bitmap >> 1; | |
| 245 index++; | |
| 246 } | 174 } |
| 247 } | 175 } |
| 248 | 176 |
| 249 } // namespace | 177 } // namespace |
| 250 | 178 |
| 251 // A helper class that allows the lock to be acquired in the middle of the scope | 179 // 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. | 180 // and unlocks at the end of scope if locked. |
| 253 class TraceLog::OptionalAutoLock { | 181 class TraceLog::OptionalAutoLock { |
| 254 public: | 182 public: |
| 255 explicit OptionalAutoLock(Lock* lock) : lock_(lock), locked_(false) {} | 183 explicit OptionalAutoLock(Lock* lock) : lock_(lock), locked_(false) {} |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 : enabled_modes_(0), | 350 : enabled_modes_(0), |
| 423 num_traces_recorded_(0), | 351 num_traces_recorded_(0), |
| 424 dispatching_to_observer_list_(false), | 352 dispatching_to_observer_list_(false), |
| 425 process_sort_index_(0), | 353 process_sort_index_(0), |
| 426 process_id_hash_(0), | 354 process_id_hash_(0), |
| 427 process_id_(0), | 355 process_id_(0), |
| 428 trace_options_(kInternalRecordUntilFull), | 356 trace_options_(kInternalRecordUntilFull), |
| 429 trace_config_(TraceConfig()), | 357 trace_config_(TraceConfig()), |
| 430 thread_shared_chunk_index_(0), | 358 thread_shared_chunk_index_(0), |
| 431 generation_(0), | 359 generation_(0), |
| 432 use_worker_thread_(false) { | 360 use_worker_thread_(false), |
| 361 filter_factory_for_testing_(nullptr) { |
| 433 CategoryRegistry::Initialize(); | 362 CategoryRegistry::Initialize(); |
| 434 | 363 |
| 435 #if defined(OS_NACL) // NaCl shouldn't expose the process id. | 364 #if defined(OS_NACL) // NaCl shouldn't expose the process id. |
| 436 SetProcessID(0); | 365 SetProcessID(0); |
| 437 #else | 366 #else |
| 438 SetProcessID(static_cast<int>(GetCurrentProcId())); | 367 SetProcessID(static_cast<int>(GetCurrentProcId())); |
| 439 #endif | 368 #endif |
| 440 | 369 |
| 441 logged_events_.reset(CreateTraceBuffer()); | 370 logged_events_.reset(CreateTraceBuffer()); |
| 442 | 371 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 return category->state_ptr(); | 438 return category->state_ptr(); |
| 510 } | 439 } |
| 511 | 440 |
| 512 const char* TraceLog::GetCategoryGroupName( | 441 const char* TraceLog::GetCategoryGroupName( |
| 513 const unsigned char* category_group_enabled) { | 442 const unsigned char* category_group_enabled) { |
| 514 return CategoryRegistry::GetCategoryByStatePtr(category_group_enabled) | 443 return CategoryRegistry::GetCategoryByStatePtr(category_group_enabled) |
| 515 ->name(); | 444 ->name(); |
| 516 } | 445 } |
| 517 | 446 |
| 518 void TraceLog::UpdateCategoryState(TraceCategory* category) { | 447 void TraceLog::UpdateCategoryState(TraceCategory* category) { |
| 448 lock_.AssertAcquired(); |
| 519 DCHECK(category->is_valid()); | 449 DCHECK(category->is_valid()); |
| 520 unsigned char state_flags = 0; | 450 unsigned char state_flags = 0; |
| 521 if (enabled_modes_ & RECORDING_MODE && | 451 if (enabled_modes_ & RECORDING_MODE && |
| 522 trace_config_.IsCategoryGroupEnabled(category->name())) { | 452 trace_config_.IsCategoryGroupEnabled(category->name())) { |
| 523 state_flags |= TraceCategory::ENABLED_FOR_RECORDING; | 453 state_flags |= TraceCategory::ENABLED_FOR_RECORDING; |
| 524 } | 454 } |
| 525 | 455 |
| 526 // TODO(primiano): this is a temporary workaround for catapult:#2341, | 456 // TODO(primiano): this is a temporary workaround for catapult:#2341, |
| 527 // to guarantee that metadata events are always added even if the category | 457 // to guarantee that metadata events are always added even if the category |
| 528 // filter is "-*". See crbug.com/618054 for more details and long-term fix. | 458 // filter is "-*". See crbug.com/618054 for more details and long-term fix. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 549 if (index++ >= MAX_TRACE_EVENT_FILTERS) { | 479 if (index++ >= MAX_TRACE_EVENT_FILTERS) { |
| 550 NOTREACHED(); | 480 NOTREACHED(); |
| 551 break; | 481 break; |
| 552 } | 482 } |
| 553 } | 483 } |
| 554 category->set_enabled_filters(enabled_filters_bitmap); | 484 category->set_enabled_filters(enabled_filters_bitmap); |
| 555 category->set_state(state_flags); | 485 category->set_state(state_flags); |
| 556 } | 486 } |
| 557 | 487 |
| 558 void TraceLog::UpdateCategoryRegistry() { | 488 void TraceLog::UpdateCategoryRegistry() { |
| 489 lock_.AssertAcquired(); |
| 559 CreateFiltersForTraceConfig(); | 490 CreateFiltersForTraceConfig(); |
| 560 for (TraceCategory& category : CategoryRegistry::GetAllCategories()) { | 491 for (TraceCategory& category : CategoryRegistry::GetAllCategories()) { |
| 561 UpdateCategoryState(&category); | 492 UpdateCategoryState(&category); |
| 562 } | 493 } |
| 563 } | 494 } |
| 564 | 495 |
| 565 void TraceLog::CreateFiltersForTraceConfig() { | 496 void TraceLog::CreateFiltersForTraceConfig() { |
| 566 if (!(enabled_modes_ & FILTERING_MODE)) | 497 if (!(enabled_modes_ & FILTERING_MODE)) |
| 567 return; | 498 return; |
| 568 | 499 |
| 569 // Filters were already added and tracing could be enabled. Filters list | 500 // Filters were already added and tracing could be enabled. Filters list |
| 570 // cannot be changed when trace events are using them. | 501 // cannot be changed when trace events are using them. |
| 571 if (g_category_group_filters.Get().size()) | 502 if (g_category_group_filters.Get().size()) |
| 572 return; | 503 return; |
| 573 | 504 |
| 574 for (auto& event_filter : enabled_event_filters_) { | 505 for (auto& filter_config : enabled_event_filters_) { |
| 575 if (g_category_group_filters.Get().size() >= MAX_TRACE_EVENT_FILTERS) { | 506 if (g_category_group_filters.Get().size() >= MAX_TRACE_EVENT_FILTERS) { |
| 576 NOTREACHED() | 507 NOTREACHED() |
| 577 << "Too many trace event filters installed in the current session"; | 508 << "Too many trace event filters installed in the current session"; |
| 578 break; | 509 break; |
| 579 } | 510 } |
| 580 | 511 |
| 581 std::unique_ptr<TraceEventFilter> new_filter; | 512 std::unique_ptr<TraceEventFilter> new_filter; |
| 582 if (event_filter.predicate_name() == | 513 const std::string& predicate_name = filter_config.predicate_name(); |
| 583 TraceEventFilter::kEventWhitelistPredicate) { | 514 if (predicate_name == EventNameFilter::kName) { |
| 584 new_filter = MakeUnique<EventNameFilter>(event_filter.filter_args()); | 515 auto whitelist = MakeUnique<std::unordered_set<std::string>>(); |
| 585 } else if (event_filter.predicate_name() == | 516 CHECK(filter_config.GetArgAsSet("event_name_whitelist", &*whitelist)); |
| 586 TraceEventFilter::kHeapProfilerPredicate) { | 517 new_filter = MakeUnique<EventNameFilter>(std::move(whitelist)); |
| 587 new_filter = MakeUnique<HeapProfilerFilter>(); | 518 } else if (predicate_name == HeapProfilerEventFilter::kName) { |
| 588 } else if (event_filter.predicate_name() == "testing_predicate") { | 519 new_filter = MakeUnique<HeapProfilerEventFilter>(); |
| 589 CHECK(g_trace_event_filter_constructor_for_testing); | |
| 590 new_filter = g_trace_event_filter_constructor_for_testing(); | |
| 591 } else { | 520 } else { |
| 592 NOTREACHED(); | 521 if (filter_factory_for_testing_) |
| 522 new_filter = filter_factory_for_testing_(predicate_name); |
| 523 CHECK(new_filter) << "Unknown trace filter " << predicate_name; |
| 593 } | 524 } |
| 594 g_category_group_filters.Get().push_back(std::move(new_filter)); | 525 g_category_group_filters.Get().push_back(std::move(new_filter)); |
| 595 } | 526 } |
| 596 } | 527 } |
| 597 | 528 |
| 598 void TraceLog::UpdateSyntheticDelaysFromTraceConfig() { | 529 void TraceLog::UpdateSyntheticDelaysFromTraceConfig() { |
| 599 ResetTraceEventSyntheticDelays(); | 530 ResetTraceEventSyntheticDelays(); |
| 600 const TraceConfig::StringList& delays = | 531 const TraceConfig::StringList& delays = |
| 601 trace_config_.GetSyntheticDelayValues(); | 532 trace_config_.GetSyntheticDelayValues(); |
| 602 TraceConfig::StringList::const_iterator ci; | 533 TraceConfig::StringList::const_iterator ci; |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 return; | 715 return; |
| 785 } | 716 } |
| 786 | 717 |
| 787 bool is_recording_mode_disabled = | 718 bool is_recording_mode_disabled = |
| 788 (enabled_modes_ & RECORDING_MODE) && (modes_to_disable & RECORDING_MODE); | 719 (enabled_modes_ & RECORDING_MODE) && (modes_to_disable & RECORDING_MODE); |
| 789 enabled_modes_ &= ~modes_to_disable; | 720 enabled_modes_ &= ~modes_to_disable; |
| 790 | 721 |
| 791 if (modes_to_disable & FILTERING_MODE) | 722 if (modes_to_disable & FILTERING_MODE) |
| 792 enabled_event_filters_.clear(); | 723 enabled_event_filters_.clear(); |
| 793 | 724 |
| 794 if (modes_to_disable & RECORDING_MODE) { | 725 if (modes_to_disable & RECORDING_MODE) |
| 795 trace_config_.Clear(); | 726 trace_config_.Clear(); |
| 796 } | |
| 797 | 727 |
| 798 UpdateCategoryRegistry(); | 728 UpdateCategoryRegistry(); |
| 799 | 729 |
| 800 // Add metadata events and notify observers only if recording mode was | 730 // Add metadata events and notify observers only if recording mode was |
| 801 // disabled now. | 731 // disabled now. |
| 802 if (!is_recording_mode_disabled) | 732 if (!is_recording_mode_disabled) |
| 803 return; | 733 return; |
| 804 | 734 |
| 805 AddMetadataEventsWhileLocked(); | 735 AddMetadataEventsWhileLocked(); |
| 806 | 736 |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1331 std::unique_ptr<TraceEvent> filtered_trace_event; | 1261 std::unique_ptr<TraceEvent> filtered_trace_event; |
| 1332 bool disabled_by_filters = false; | 1262 bool disabled_by_filters = false; |
| 1333 if (*category_group_enabled & TraceCategory::ENABLED_FOR_FILTERING) { | 1263 if (*category_group_enabled & TraceCategory::ENABLED_FOR_FILTERING) { |
| 1334 std::unique_ptr<TraceEvent> new_trace_event(new TraceEvent); | 1264 std::unique_ptr<TraceEvent> new_trace_event(new TraceEvent); |
| 1335 new_trace_event->Initialize(thread_id, offset_event_timestamp, thread_now, | 1265 new_trace_event->Initialize(thread_id, offset_event_timestamp, thread_now, |
| 1336 phase, category_group_enabled, name, scope, id, | 1266 phase, category_group_enabled, name, scope, id, |
| 1337 bind_id, num_args, arg_names, arg_types, | 1267 bind_id, num_args, arg_names, arg_types, |
| 1338 arg_values, convertable_values, flags); | 1268 arg_values, convertable_values, flags); |
| 1339 | 1269 |
| 1340 disabled_by_filters = true; | 1270 disabled_by_filters = true; |
| 1341 ForEachCategoryGroupFilter( | 1271 ForEachCategoryFilter( |
| 1342 category_group_enabled, [&new_trace_event, &disabled_by_filters]( | 1272 category_group_enabled, [&new_trace_event, &disabled_by_filters]( |
| 1343 TraceEventFilter* trace_event_filter) { | 1273 TraceEventFilter* trace_event_filter) { |
| 1344 if (trace_event_filter->FilterTraceEvent(*new_trace_event)) | 1274 if (trace_event_filter->FilterTraceEvent(*new_trace_event)) |
| 1345 disabled_by_filters = false; | 1275 disabled_by_filters = false; |
| 1346 }); | 1276 }); |
| 1347 if (!disabled_by_filters) | 1277 if (!disabled_by_filters) |
| 1348 filtered_trace_event = std::move(new_trace_event); | 1278 filtered_trace_event = std::move(new_trace_event); |
| 1349 } | 1279 } |
| 1350 | 1280 |
| 1351 // If enabled for recording, the event should be added only if one of the | 1281 // 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) | 1391 if (phase == TRACE_EVENT_PHASE_BEGIN) |
| 1462 thread_event_start_times_[thread_id].push(timestamp); | 1392 thread_event_start_times_[thread_id].push(timestamp); |
| 1463 | 1393 |
| 1464 return log.str(); | 1394 return log.str(); |
| 1465 } | 1395 } |
| 1466 | 1396 |
| 1467 void TraceLog::EndFilteredEvent(const unsigned char* category_group_enabled, | 1397 void TraceLog::EndFilteredEvent(const unsigned char* category_group_enabled, |
| 1468 const char* name, | 1398 const char* name, |
| 1469 TraceEventHandle handle) { | 1399 TraceEventHandle handle) { |
| 1470 const char* category_name = GetCategoryGroupName(category_group_enabled); | 1400 const char* category_name = GetCategoryGroupName(category_group_enabled); |
| 1471 ForEachCategoryGroupFilter( | 1401 ForEachCategoryFilter( |
| 1472 category_group_enabled, | 1402 category_group_enabled, |
| 1473 [name, category_name](TraceEventFilter* trace_event_filter) { | 1403 [name, category_name](TraceEventFilter* trace_event_filter) { |
| 1474 trace_event_filter->EndEvent(name, category_name); | 1404 trace_event_filter->EndEvent(category_name, name); |
| 1475 }); | 1405 }); |
| 1476 } | 1406 } |
| 1477 | 1407 |
| 1478 void TraceLog::UpdateTraceEventDuration( | 1408 void TraceLog::UpdateTraceEventDuration( |
| 1479 const unsigned char* category_group_enabled, | 1409 const unsigned char* category_group_enabled, |
| 1480 const char* name, | 1410 const char* name, |
| 1481 TraceEventHandle handle) { | 1411 TraceEventHandle handle) { |
| 1482 char category_group_enabled_local = *category_group_enabled; | 1412 char category_group_enabled_local = *category_group_enabled; |
| 1483 if (!category_group_enabled_local) | 1413 if (!category_group_enabled_local) |
| 1484 return; | 1414 return; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1605 "overflowed_at_ts", | 1535 "overflowed_at_ts", |
| 1606 buffer_limit_reached_timestamp_); | 1536 buffer_limit_reached_timestamp_); |
| 1607 } | 1537 } |
| 1608 } | 1538 } |
| 1609 | 1539 |
| 1610 void TraceLog::DeleteForTesting() { | 1540 void TraceLog::DeleteForTesting() { |
| 1611 internal::DeleteTraceLogForTesting::Delete(); | 1541 internal::DeleteTraceLogForTesting::Delete(); |
| 1612 CategoryRegistry::ResetForTesting(); | 1542 CategoryRegistry::ResetForTesting(); |
| 1613 } | 1543 } |
| 1614 | 1544 |
| 1615 void TraceLog::SetTraceEventFilterConstructorForTesting( | |
| 1616 TraceEventFilterConstructorForTesting predicate) { | |
| 1617 g_trace_event_filter_constructor_for_testing = predicate; | |
| 1618 } | |
| 1619 | |
| 1620 TraceEvent* TraceLog::GetEventByHandle(TraceEventHandle handle) { | 1545 TraceEvent* TraceLog::GetEventByHandle(TraceEventHandle handle) { |
| 1621 return GetEventByHandleInternal(handle, NULL); | 1546 return GetEventByHandleInternal(handle, NULL); |
| 1622 } | 1547 } |
| 1623 | 1548 |
| 1624 TraceEvent* TraceLog::GetEventByHandleInternal(TraceEventHandle handle, | 1549 TraceEvent* TraceLog::GetEventByHandleInternal(TraceEventHandle handle, |
| 1625 OptionalAutoLock* lock) { | 1550 OptionalAutoLock* lock) { |
| 1626 if (!handle.chunk_seq) | 1551 if (!handle.chunk_seq) |
| 1627 return NULL; | 1552 return NULL; |
| 1628 | 1553 |
| 1629 DCHECK(handle.chunk_seq); | 1554 DCHECK(handle.chunk_seq); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1797 } | 1722 } |
| 1798 | 1723 |
| 1799 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { | 1724 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { |
| 1800 if (*category_group_enabled_) { | 1725 if (*category_group_enabled_) { |
| 1801 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, | 1726 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, |
| 1802 event_handle_); | 1727 event_handle_); |
| 1803 } | 1728 } |
| 1804 } | 1729 } |
| 1805 | 1730 |
| 1806 } // namespace trace_event_internal | 1731 } // namespace trace_event_internal |
| OLD | NEW |