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

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

Issue 1306753005: [tracing] Add memory dump config to TraceConfig (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding note about category. Created 5 years, 3 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 #ifndef BASE_TRACE_EVENT_TRACE_CONFIG_H_ 5 #ifndef BASE_TRACE_EVENT_TRACE_CONFIG_H_
6 #define BASE_TRACE_EVENT_TRACE_CONFIG_H_ 6 #define BASE_TRACE_EVENT_TRACE_CONFIG_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/base_export.h" 11 #include "base/base_export.h"
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "base/trace_event/memory_dump_provider.h"
13 #include "base/values.h" 14 #include "base/values.h"
14 15
15 namespace base { 16 namespace base {
16 namespace trace_event { 17 namespace trace_event {
17 18
18 // Options determines how the trace buffer stores data. 19 // Options determines how the trace buffer stores data.
19 enum TraceRecordMode { 20 enum TraceRecordMode {
20 // Record until the trace buffer is full. 21 // Record until the trace buffer is full.
21 RECORD_UNTIL_FULL, 22 RECORD_UNTIL_FULL,
22 23
23 // Record until the user ends the trace. The trace buffer is a fixed size 24 // Record until the user ends the trace. The trace buffer is a fixed size
24 // and we use it as a ring buffer during recording. 25 // and we use it as a ring buffer during recording.
25 RECORD_CONTINUOUSLY, 26 RECORD_CONTINUOUSLY,
26 27
27 // Record until the trace buffer is full, but with a huge buffer size. 28 // Record until the trace buffer is full, but with a huge buffer size.
28 RECORD_AS_MUCH_AS_POSSIBLE, 29 RECORD_AS_MUCH_AS_POSSIBLE,
29 30
30 // Echo to console. Events are discarded. 31 // Echo to console. Events are discarded.
31 ECHO_TO_CONSOLE, 32 ECHO_TO_CONSOLE,
32 }; 33 };
33 34
34 class BASE_EXPORT TraceConfig { 35 class BASE_EXPORT TraceConfig {
35 public: 36 public:
36 typedef std::vector<std::string> StringList; 37 typedef std::vector<std::string> StringList;
37 38
39 // Specifies the memory dump config for tracing. Used only when
40 // "memory-infra" category is enabled.
41 struct MemoryDumpTriggerConfig {
42 uint32 periodic_interval_ms;
43 MemoryDumpArgs::LevelOfDetail level_of_detail;
44 };
45
46 typedef std::vector<MemoryDumpTriggerConfig> MemoryDumpConfig;
47
38 TraceConfig(); 48 TraceConfig();
39 49
40 // Create TraceConfig object from category filter and trace options strings. 50 // Create TraceConfig object from category filter and trace options strings.
41 // 51 //
42 // |category_filter_string| is a comma-delimited list of category wildcards. 52 // |category_filter_string| is a comma-delimited list of category wildcards.
43 // A category can have an optional '-' prefix to make it an excluded category. 53 // A category can have an optional '-' prefix to make it an excluded category.
44 // All the same rules apply above, so for example, having both included and 54 // All the same rules apply above, so for example, having both included and
45 // excluded categories in the same list would not be supported. 55 // excluded categories in the same list would not be supported.
46 // 56 //
47 // Category filters can also be used to configure synthetic delays. 57 // Category filters can also be used to configure synthetic delays.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 // category filters and trace options. 102 // category filters and trace options.
93 // 103 //
94 // Example: 104 // Example:
95 // { 105 // {
96 // "record_mode": "record-continuously", 106 // "record_mode": "record-continuously",
97 // "enable_sampling": true, 107 // "enable_sampling": true,
98 // "enable_systrace": true, 108 // "enable_systrace": true,
99 // "enable_argument_filter": true, 109 // "enable_argument_filter": true,
100 // "included_categories": ["included", 110 // "included_categories": ["included",
101 // "inc_pattern*", 111 // "inc_pattern*",
102 // "disabled-by-default-category1"], 112 // "disabled-by-default-memory-infra"],
Primiano Tucci (use gerrit) 2015/08/25 18:27:37 remove this line
ssid 2015/08/26 10:19:51 Done.
103 // "excluded_categories": ["excluded", "exc_pattern*"], 113 // "excluded_categories": ["excluded", "exc_pattern*"],
104 // "synthetic_delays": ["test.Delay1;16", "test.Delay2;32"] 114 // "synthetic_delays": ["test.Delay1;16", "test.Delay2;32"]
115 // "memory_dump_config": {
116 // "triggers": [
117 // {
118 // "level_of_detail": "high",
Primiano Tucci (use gerrit) 2015/08/25 18:27:37 s/level_of_detail/mode/ high -> detailed low -> li
ssid 2015/08/26 10:19:51 Done.
119 // "periodic_interval_ms": 2000
120 // }
121 // ]
122 // }
105 // } 123 // }
124 //
125 // Note: memory_dump_config can be specified only if
Primiano Tucci (use gerrit) 2015/08/24 21:26:47 ssid: according to our last chat offline this comm
ssid 2015/08/24 22:46:26 For this CL this is true. This will be removed onc
ssid 2015/08/24 22:53:22 Hm, this is true even after the change, right? The
126 // disabled-by-default-memory-infra category is enabled.
Primiano Tucci (use gerrit) 2015/08/25 18:27:37 Had offline chat, remove this comment
ssid 2015/08/26 10:19:51 Done.
106 explicit TraceConfig(const std::string& config_string); 127 explicit TraceConfig(const std::string& config_string);
107 128
108 TraceConfig(const TraceConfig& tc); 129 TraceConfig(const TraceConfig& tc);
109 130
110 ~TraceConfig(); 131 ~TraceConfig();
111 132
112 TraceConfig& operator=(const TraceConfig& rhs); 133 TraceConfig& operator=(const TraceConfig& rhs);
113 134
114 // Return a list of the synthetic delays specified in this category filter. 135 // Return a list of the synthetic delays specified in this category filter.
115 const StringList& GetSyntheticDelayValues() const; 136 const StringList& GetSyntheticDelayValues() const;
(...skipping 17 matching lines...) Expand all
133 154
134 // Returns true if at least one category in the list is enabled by this 155 // Returns true if at least one category in the list is enabled by this
135 // trace config. 156 // trace config.
136 bool IsCategoryGroupEnabled(const char* category_group) const; 157 bool IsCategoryGroupEnabled(const char* category_group) const;
137 158
138 // Merges config with the current TraceConfig 159 // Merges config with the current TraceConfig
139 void Merge(const TraceConfig& config); 160 void Merge(const TraceConfig& config);
140 161
141 void Clear(); 162 void Clear();
142 163
164 const MemoryDumpConfig& memory_dump_config() const {
165 return memory_dump_config_;
166 }
167
143 private: 168 private:
144 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, TraceConfigFromValidLegacyFormat); 169 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, TraceConfigFromValidLegacyFormat);
145 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, 170 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest,
146 TraceConfigFromInvalidLegacyStrings); 171 TraceConfigFromInvalidLegacyStrings);
147 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, ConstructDefaultTraceConfig); 172 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, ConstructDefaultTraceConfig);
148 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, TraceConfigFromValidString); 173 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, TraceConfigFromValidString);
149 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, TraceConfigFromInvalidString); 174 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, TraceConfigFromInvalidString);
150 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, 175 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest,
151 IsEmptyOrContainsLeadingOrTrailingWhitespace); 176 IsEmptyOrContainsLeadingOrTrailingWhitespace);
177 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, TraceConfigFromMemoryConfigString);
178 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, InvalidMemoryConfigString);
152 179
153 // The default trace config, used when none is provided. 180 // The default trace config, used when none is provided.
154 // Allows all non-disabled-by-default categories through, except if they end 181 // Allows all non-disabled-by-default categories through, except if they end
155 // in the suffix 'Debug' or 'Test'. 182 // in the suffix 'Debug' or 'Test'.
156 void InitializeDefault(); 183 void InitializeDefault();
157 184
158 // Initialize from the config string 185 // Initialize from the config string
159 void InitializeFromConfigString(const std::string& config_string); 186 void InitializeFromConfigString(const std::string& config_string);
160 187
161 // Initialize from category filter and trace options strings 188 // Initialize from category filter and trace options strings
162 void InitializeFromStrings(const std::string& category_filter_string, 189 void InitializeFromStrings(const std::string& category_filter_string,
163 const std::string& trace_options_string); 190 const std::string& trace_options_string);
164 191
165 void SetCategoriesFromIncludedList(const base::ListValue& included_list); 192 void SetCategoriesFromIncludedList(const base::ListValue& included_list);
166 void SetCategoriesFromExcludedList(const base::ListValue& excluded_list); 193 void SetCategoriesFromExcludedList(const base::ListValue& excluded_list);
167 void SetSyntheticDelaysFromList(const base::ListValue& list); 194 void SetSyntheticDelaysFromList(const base::ListValue& list);
168 void AddCategoryToDict(base::DictionaryValue& dict, 195 void AddCategoryToDict(base::DictionaryValue& dict,
169 const char* param, 196 const char* param,
170 const StringList& categories) const; 197 const StringList& categories) const;
171 198
199 void SetMemoryDumpConfig(const base::DictionaryValue& memory_dump_config);
200
172 // Convert TraceConfig to the dict representation of the TraceConfig. 201 // Convert TraceConfig to the dict representation of the TraceConfig.
173 void ToDict(base::DictionaryValue& dict) const; 202 void ToDict(base::DictionaryValue& dict) const;
174 203
175 std::string ToTraceOptionsString() const; 204 std::string ToTraceOptionsString() const;
176 205
177 void WriteCategoryFilterString(const StringList& values, 206 void WriteCategoryFilterString(const StringList& values,
178 std::string* out, 207 std::string* out,
179 bool included) const; 208 bool included) const;
180 void WriteCategoryFilterString(const StringList& delays, 209 void WriteCategoryFilterString(const StringList& delays,
181 std::string* out) const; 210 std::string* out) const;
182 211
183 // Returns true if category is enable according to this trace config. 212 // Returns true if category is enable according to this trace config.
184 bool IsCategoryEnabled(const char* category_name) const; 213 bool IsCategoryEnabled(const char* category_name) const;
185 214
186 static bool IsEmptyOrContainsLeadingOrTrailingWhitespace( 215 static bool IsEmptyOrContainsLeadingOrTrailingWhitespace(
187 const std::string& str); 216 const std::string& str);
188 217
189 bool HasIncludedPatterns() const; 218 bool HasIncludedPatterns() const;
190 219
191 TraceRecordMode record_mode_; 220 TraceRecordMode record_mode_;
192 bool enable_sampling_ : 1; 221 bool enable_sampling_ : 1;
193 bool enable_systrace_ : 1; 222 bool enable_systrace_ : 1;
194 bool enable_argument_filter_ : 1; 223 bool enable_argument_filter_ : 1;
195 224
225 MemoryDumpConfig memory_dump_config_;
226
196 StringList included_categories_; 227 StringList included_categories_;
197 StringList disabled_categories_; 228 StringList disabled_categories_;
198 StringList excluded_categories_; 229 StringList excluded_categories_;
199 StringList synthetic_delays_; 230 StringList synthetic_delays_;
200 }; 231 };
201 232
202 } // namespace trace_event 233 } // namespace trace_event
203 } // namespace base 234 } // namespace base
204 235
205 #endif // BASE_TRACE_EVENT_TRACE_CONFIG_H_ 236 #endif // BASE_TRACE_EVENT_TRACE_CONFIG_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698