summaryrefslogtreecommitdiffstats
path: root/base/trace_event/trace_event_etw_export_win.h
diff options
context:
space:
mode:
authorgeorgesak <georgesak@chromium.org>2015-06-25 08:17:25 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-25 15:17:46 +0000
commit40ff770be17a5ffcea06b7475be554118612f4a9 (patch)
tree6bf6de58e4499d8fc1cd53c93e94ee28ee9a5418 /base/trace_event/trace_event_etw_export_win.h
parentdad2a66e603de9b0f1cdf7e99a010b2cd2ecb711 (diff)
downloadchromium_src-40ff770be17a5ffcea06b7475be554118612f4a9.zip
chromium_src-40ff770be17a5ffcea06b7475be554118612f4a9.tar.gz
chromium_src-40ff770be17a5ffcea06b7475be554118612f4a9.tar.bz2
[ETW Export] Add event filtering.
This adds the possibility to filter which events get exported via ETW Keywords. A keyword is a 64-bit flag and we attribute one bit per category. We can therefore enable a particular category by setting its corresponding bit in the keyword. For events that are not present in |filtered_event_group_names|, we have two bits that control their behavior. When bit 61 is enabled, any event that is not disabled by default (ie. doesn't start with disabled-by-default-) will be exported. Likewise, when bit 62 is enabled, any event that is disabled by default will be exported. Note that bit 63 (MSB) must always be set, otherwise tracing will be disabled by ETW. Therefore, the keyword will always be greater than 0x8000000000000000. Examples of passing keywords to the provider using xperf: # This exports "browser" and "cc" events xperf -start chrome -on Chrome:0x8000000000000005 # This exports "gpu", "netlog" and all other events that are not disabled by # default xperf -start chrome -on Chrome:0xA0000000000000A0 More info about starting a trace and keyword can be obtained by using the help section of xperf (xperf -help start). Note that xperf documentation refers to keywords as flags and there are two ways to enable them, using group names or the hex representation. We only support the latter. Also, we ignore the level. Notes: - For now, checking the keyword is only done once, at the start. Polling the value and updating the categories when it changes will be added by a subsequent CL. - Native support for filtering will be added to UIForETW in a near future. - Also fixed some outstanding nits from an earlier CL. BUG=491909 Review URL: https://codereview.chromium.org/1176243016 Cr-Commit-Position: refs/heads/master@{#336156}
Diffstat (limited to 'base/trace_event/trace_event_etw_export_win.h')
-rw-r--r--base/trace_event/trace_event_etw_export_win.h28
1 files changed, 24 insertions, 4 deletions
diff --git a/base/trace_event/trace_event_etw_export_win.h b/base/trace_event/trace_event_etw_export_win.h
index eefe820..a9b580c 100644
--- a/base/trace_event/trace_event_etw_export_win.h
+++ b/base/trace_event/trace_event_etw_export_win.h
@@ -6,7 +6,10 @@
#ifndef BASE_TRACE_EVENT_TRACE_EVENT_ETW_EXPORT_WIN_H_
#define BASE_TRACE_EVENT_TRACE_EVENT_ETW_EXPORT_WIN_H_
+#include <map>
+
#include "base/base_export.h"
+#include "base/strings/string_piece.h"
#include "base/trace_event/trace_event_impl.h"
// Fwd.
@@ -29,8 +32,8 @@ class BASE_EXPORT TraceEventETWExport {
static void EnableETWExport();
static void DisableETWExport();
- static bool isETWExportEnabled() {
- return (GetInstance() && GetInstance()->ETWExportEnabled_);
+ static bool IsETWExportEnabled() {
+ return (GetInstance() && GetInstance()->etw_match_any_keyword_);
}
// Exports an event to ETW. This is mainly used in
@@ -50,7 +53,7 @@ class BASE_EXPORT TraceEventETWExport {
// to ETW. Supports three arguments to be passed to ETW.
// TODO(georgesak): Allow different providers.
static void AddCustomEvent(const char* name,
- char const* phase,
+ const char* phase,
const char* arg_name_1,
const char* arg_value_1,
const char* arg_name_2,
@@ -58,14 +61,31 @@ class BASE_EXPORT TraceEventETWExport {
const char* arg_name_3,
const char* arg_value_3);
+ // Returns true if any category in the group is enabled.
+ static bool IsCategoryGroupEnabled(const char* category_group_name);
+
void Resurrect();
private:
- bool ETWExportEnabled_;
// Ensure only the provider can construct us.
friend struct StaticMemorySingletonTraits<TraceEventETWExport>;
TraceEventETWExport();
+ // Updates the list of enabled categories by consulting the ETW keyword.
+ void UpdateEnabledCategories();
+
+ // Returns true if the category is enabled.
+ bool IsCategoryEnabled(const char* category_name) const;
+
+ // True if ETW is enabled. Allows hiding the exporting behind a flag.
+ bool etw_export_enabled_;
+
+ // Maps category names to their status (enabled/disabled).
+ std::map<base::StringPiece, bool> categories_status_;
+
+ // Local copy of the ETW keyword.
+ uint64 etw_match_any_keyword_;
+
DISALLOW_COPY_AND_ASSIGN(TraceEventETWExport);
};