Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: base/trace_event/trace_config.cc

Issue 2323483005: [tracing] Add filtering mode in TraceLog (Closed)
Patch Set: SetEnabled takes a bitmap. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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_config.h" 5 #include "base/trace_event/trace_config.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 const MemoryDumpConfig& other) = default; 112 const MemoryDumpConfig& other) = default;
113 113
114 TraceConfig::MemoryDumpConfig::~MemoryDumpConfig() {} 114 TraceConfig::MemoryDumpConfig::~MemoryDumpConfig() {}
115 115
116 void TraceConfig::MemoryDumpConfig::Clear() { 116 void TraceConfig::MemoryDumpConfig::Clear() {
117 allowed_dump_modes.clear(); 117 allowed_dump_modes.clear();
118 triggers.clear(); 118 triggers.clear();
119 heap_profiler_options.Clear(); 119 heap_profiler_options.Clear();
120 } 120 }
121 121
122 void TraceConfig::MemoryDumpConfig::Merge(
Primiano Tucci (use gerrit) 2016/10/12 17:50:17 just to be clear, this is an indipendent fix? It w
ssid 2016/10/12 19:04:43 Yes independent since i just realized Merge is bei
123 const TraceConfig::MemoryDumpConfig& config) {
124 triggers.insert(triggers.end(), config.triggers.begin(),
125 config.triggers.end());
126 allowed_dump_modes.insert(config.allowed_dump_modes.begin(),
127 config.allowed_dump_modes.end());
128 heap_profiler_options.breakdown_threshold_bytes =
129 std::min(heap_profiler_options.breakdown_threshold_bytes,
130 config.heap_profiler_options.breakdown_threshold_bytes);
131 }
132
122 TraceConfig::EventFilterConfig::EventFilterConfig( 133 TraceConfig::EventFilterConfig::EventFilterConfig(
123 const std::string& predicate_name) 134 const std::string& predicate_name)
124 : predicate_name_(predicate_name) {} 135 : predicate_name_(predicate_name) {}
125 136
126 TraceConfig::EventFilterConfig::~EventFilterConfig() {} 137 TraceConfig::EventFilterConfig::~EventFilterConfig() {}
127 138
128 TraceConfig::EventFilterConfig::EventFilterConfig(const EventFilterConfig& tc) { 139 TraceConfig::EventFilterConfig::EventFilterConfig(const EventFilterConfig& tc) {
129 *this = tc; 140 *this = tc;
130 } 141 }
131 142
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 // Otherwise, one of the filter was specifying "*" and we want to honor the 359 // Otherwise, one of the filter was specifying "*" and we want to honor the
349 // broadest filter. 360 // broadest filter.
350 if (HasIncludedPatterns() && config.HasIncludedPatterns()) { 361 if (HasIncludedPatterns() && config.HasIncludedPatterns()) {
351 included_categories_.insert(included_categories_.end(), 362 included_categories_.insert(included_categories_.end(),
352 config.included_categories_.begin(), 363 config.included_categories_.begin(),
353 config.included_categories_.end()); 364 config.included_categories_.end());
354 } else { 365 } else {
355 included_categories_.clear(); 366 included_categories_.clear();
356 } 367 }
357 368
358 memory_dump_config_.triggers.insert(memory_dump_config_.triggers.end(), 369 memory_dump_config_.Merge(config.memory_dump_config_);
359 config.memory_dump_config_.triggers.begin(),
360 config.memory_dump_config_.triggers.end());
361 370
362 disabled_categories_.insert(disabled_categories_.end(), 371 disabled_categories_.insert(disabled_categories_.end(),
363 config.disabled_categories_.begin(), 372 config.disabled_categories_.begin(),
364 config.disabled_categories_.end()); 373 config.disabled_categories_.end());
365 excluded_categories_.insert(excluded_categories_.end(), 374 excluded_categories_.insert(excluded_categories_.end(),
366 config.excluded_categories_.begin(), 375 config.excluded_categories_.begin(),
367 config.excluded_categories_.end()); 376 config.excluded_categories_.end());
368 synthetic_delays_.insert(synthetic_delays_.end(), 377 synthetic_delays_.insert(synthetic_delays_.end(),
369 config.synthetic_delays_.begin(), 378 config.synthetic_delays_.begin(),
370 config.synthetic_delays_.end()); 379 config.synthetic_delays_.end());
380 event_filters_.insert(event_filters_.end(), config.event_filters().begin(),
381 config.event_filters().end());
371 } 382 }
372 383
373 void TraceConfig::Clear() { 384 void TraceConfig::Clear() {
374 record_mode_ = RECORD_UNTIL_FULL; 385 record_mode_ = RECORD_UNTIL_FULL;
375 enable_systrace_ = false; 386 enable_systrace_ = false;
376 enable_argument_filter_ = false; 387 enable_argument_filter_ = false;
377 included_categories_.clear(); 388 included_categories_.clear();
378 disabled_categories_.clear(); 389 disabled_categories_.clear();
379 excluded_categories_.clear(); 390 excluded_categories_.clear();
380 synthetic_delays_.clear(); 391 synthetic_delays_.clear();
(...skipping 28 matching lines...) Expand all
409 dict.GetBoolean(kEnableArgumentFilterParam, &val) ? val : false; 420 dict.GetBoolean(kEnableArgumentFilterParam, &val) ? val : false;
410 421
411 const ListValue* category_list = nullptr; 422 const ListValue* category_list = nullptr;
412 if (dict.GetList(kIncludedCategoriesParam, &category_list)) 423 if (dict.GetList(kIncludedCategoriesParam, &category_list))
413 SetCategoriesFromIncludedList(*category_list); 424 SetCategoriesFromIncludedList(*category_list);
414 if (dict.GetList(kExcludedCategoriesParam, &category_list)) 425 if (dict.GetList(kExcludedCategoriesParam, &category_list))
415 SetCategoriesFromExcludedList(*category_list); 426 SetCategoriesFromExcludedList(*category_list);
416 if (dict.GetList(kSyntheticDelaysParam, &category_list)) 427 if (dict.GetList(kSyntheticDelaysParam, &category_list))
417 SetSyntheticDelaysFromList(*category_list); 428 SetSyntheticDelaysFromList(*category_list);
418 429
430 const base::ListValue* category_event_filters = nullptr;
431 if (dict.GetList(kEventFiltersParam, &category_event_filters))
432 SetEventFilters(*category_event_filters);
433
419 if (IsCategoryEnabled(MemoryDumpManager::kTraceCategory)) { 434 if (IsCategoryEnabled(MemoryDumpManager::kTraceCategory)) {
420 // If dump triggers not set, the client is using the legacy with just 435 // If dump triggers not set, the client is using the legacy with just
421 // category enabled. So, use the default periodic dump config. 436 // category enabled. So, use the default periodic dump config.
422 const DictionaryValue* memory_dump_config = nullptr; 437 const DictionaryValue* memory_dump_config = nullptr;
423 if (dict.GetDictionary(kMemoryDumpConfigParam, &memory_dump_config)) 438 if (dict.GetDictionary(kMemoryDumpConfigParam, &memory_dump_config))
424 SetMemoryDumpConfigFromConfigDict(*memory_dump_config); 439 SetMemoryDumpConfigFromConfigDict(*memory_dump_config);
425 else 440 else
426 SetDefaultMemoryDumpConfig(); 441 SetDefaultMemoryDumpConfig();
427 } 442 }
428
429 const base::ListValue* category_event_filters = nullptr;
430 if (dict.GetList(kEventFiltersParam, &category_event_filters))
431 SetEventFilters(*category_event_filters);
432 } 443 }
433 444
434 void TraceConfig::InitializeFromConfigString(StringPiece config_string) { 445 void TraceConfig::InitializeFromConfigString(StringPiece config_string) {
435 auto dict = DictionaryValue::From(JSONReader::Read(config_string)); 446 auto dict = DictionaryValue::From(JSONReader::Read(config_string));
436 if (dict) 447 if (dict)
437 InitializeFromConfigDict(*dict); 448 InitializeFromConfigDict(*dict);
438 else 449 else
439 InitializeDefault(); 450 InitializeDefault();
440 } 451 }
441 452
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 MemoryDumpConfig::HeapProfiler::kDefaultBreakdownThresholdBytes; 622 MemoryDumpConfig::HeapProfiler::kDefaultBreakdownThresholdBytes;
612 } 623 }
613 } 624 }
614 } 625 }
615 626
616 void TraceConfig::SetDefaultMemoryDumpConfig() { 627 void TraceConfig::SetDefaultMemoryDumpConfig() {
617 memory_dump_config_.Clear(); 628 memory_dump_config_.Clear();
618 memory_dump_config_.triggers.push_back(kDefaultHeavyMemoryDumpTrigger); 629 memory_dump_config_.triggers.push_back(kDefaultHeavyMemoryDumpTrigger);
619 memory_dump_config_.triggers.push_back(kDefaultLightMemoryDumpTrigger); 630 memory_dump_config_.triggers.push_back(kDefaultLightMemoryDumpTrigger);
620 memory_dump_config_.allowed_dump_modes = GetDefaultAllowedMemoryDumpModes(); 631 memory_dump_config_.allowed_dump_modes = GetDefaultAllowedMemoryDumpModes();
621
622 if (AllocationContextTracker::capture_mode() ==
623 AllocationContextTracker::CaptureMode::PSEUDO_STACK) {
624 for (const auto& filter : event_filters_) {
625 if (filter.predicate_name() ==
626 TraceLog::TraceEventFilter::kHeapProfilerPredicate)
627 return;
628 }
629 // Adds a filter predicate to filter all categories for the heap profiler.
630 // Note that the heap profiler predicate does not filter-out any events.
631 EventFilterConfig heap_profiler_config(
632 TraceLog::TraceEventFilter::kHeapProfilerPredicate);
633 heap_profiler_config.AddIncludedCategory("*");
634 heap_profiler_config.AddIncludedCategory(MemoryDumpManager::kTraceCategory);
635 event_filters_.push_back(heap_profiler_config);
636 }
637 } 632 }
638 633
639 void TraceConfig::SetEventFilters( 634 void TraceConfig::SetEventFilters(
640 const base::ListValue& category_event_filters) { 635 const base::ListValue& category_event_filters) {
641 event_filters_.clear(); 636 event_filters_.clear();
642 637
643 for (size_t event_filter_index = 0; 638 for (size_t event_filter_index = 0;
644 event_filter_index < category_event_filters.GetSize(); 639 event_filter_index < category_event_filters.GetSize();
645 ++event_filter_index) { 640 ++event_filter_index) {
646 const base::DictionaryValue* event_filter = nullptr; 641 const base::DictionaryValue* event_filter = nullptr;
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 StringPiece str) { 849 StringPiece str) {
855 return str.empty() || str.front() == ' ' || str.back() == ' '; 850 return str.empty() || str.front() == ' ' || str.back() == ' ';
856 } 851 }
857 852
858 bool TraceConfig::HasIncludedPatterns() const { 853 bool TraceConfig::HasIncludedPatterns() const {
859 return !included_categories_.empty(); 854 return !included_categories_.empty();
860 } 855 }
861 856
862 } // namespace trace_event 857 } // namespace trace_event
863 } // namespace base 858 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698