OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_event_impl.h" | 5 #include "base/trace_event/trace_event_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 17 matching lines...) Expand all Loading... | |
28 #include "base/synchronization/waitable_event.h" | 28 #include "base/synchronization/waitable_event.h" |
29 #include "base/sys_info.h" | 29 #include "base/sys_info.h" |
30 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 30 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
31 #include "base/threading/platform_thread.h" | 31 #include "base/threading/platform_thread.h" |
32 #include "base/threading/thread_id_name_manager.h" | 32 #include "base/threading/thread_id_name_manager.h" |
33 #include "base/time/time.h" | 33 #include "base/time/time.h" |
34 #include "base/trace_event/trace_event.h" | 34 #include "base/trace_event/trace_event.h" |
35 #include "base/trace_event/trace_event_synthetic_delay.h" | 35 #include "base/trace_event/trace_event_synthetic_delay.h" |
36 | 36 |
37 #if defined(OS_WIN) | 37 #if defined(OS_WIN) |
38 #include "base/trace_event/trace_event_etw_export_win.h" | |
38 #include "base/trace_event/trace_event_win.h" | 39 #include "base/trace_event/trace_event_win.h" |
39 #endif | 40 #endif |
40 | 41 |
41 class DeleteTraceLogForTesting { | 42 class DeleteTraceLogForTesting { |
42 public: | 43 public: |
43 static void Delete() { | 44 static void Delete() { |
44 Singleton<base::trace_event::TraceLog, | 45 Singleton<base::trace_event::TraceLog, |
45 LeakySingletonTraits<base::trace_event::TraceLog>>::OnExit(0); | 46 LeakySingletonTraits<base::trace_event::TraceLog>>::OnExit(0); |
46 } | 47 } |
47 }; | 48 }; |
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1283 const char* category_group = g_category_groups[category_index]; | 1284 const char* category_group = g_category_groups[category_index]; |
1284 if (mode_ == RECORDING_MODE && | 1285 if (mode_ == RECORDING_MODE && |
1285 category_filter_.IsCategoryGroupEnabled(category_group)) | 1286 category_filter_.IsCategoryGroupEnabled(category_group)) |
1286 enabled_flag |= ENABLED_FOR_RECORDING; | 1287 enabled_flag |= ENABLED_FOR_RECORDING; |
1287 else if (mode_ == MONITORING_MODE && | 1288 else if (mode_ == MONITORING_MODE && |
1288 category_filter_.IsCategoryGroupEnabled(category_group)) | 1289 category_filter_.IsCategoryGroupEnabled(category_group)) |
1289 enabled_flag |= ENABLED_FOR_MONITORING; | 1290 enabled_flag |= ENABLED_FOR_MONITORING; |
1290 if (event_callback_ && | 1291 if (event_callback_ && |
1291 event_callback_category_filter_.IsCategoryGroupEnabled(category_group)) | 1292 event_callback_category_filter_.IsCategoryGroupEnabled(category_group)) |
1292 enabled_flag |= ENABLED_FOR_EVENT_CALLBACK; | 1293 enabled_flag |= ENABLED_FOR_EVENT_CALLBACK; |
1294 #if defined(OS_WIN) | |
1295 if (base::trace_event::TraceEventETWExport::isETWExportEnabled()) | |
1296 enabled_flag |= ENABLED_FOR_ETW_EXPORT; | |
1297 #endif | |
1298 | |
1293 g_category_group_enabled[category_index] = enabled_flag; | 1299 g_category_group_enabled[category_index] = enabled_flag; |
1294 } | 1300 } |
1295 | 1301 |
1296 void TraceLog::UpdateCategoryGroupEnabledFlags() { | 1302 void TraceLog::UpdateCategoryGroupEnabledFlags() { |
1297 size_t category_index = base::subtle::NoBarrier_Load(&g_category_index); | 1303 size_t category_index = base::subtle::NoBarrier_Load(&g_category_index); |
1298 for (size_t i = 0; i < category_index; i++) | 1304 for (size_t i = 0; i < category_index; i++) |
1299 UpdateCategoryGroupEnabledFlag(i); | 1305 UpdateCategoryGroupEnabledFlag(i); |
1300 } | 1306 } |
1301 | 1307 |
1302 void TraceLog::UpdateSyntheticDelaysFromCategoryFilter() { | 1308 void TraceLog::UpdateSyntheticDelaysFromCategoryFilter() { |
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1889 int num_args, | 1895 int num_args, |
1890 const char** arg_names, | 1896 const char** arg_names, |
1891 const unsigned char* arg_types, | 1897 const unsigned char* arg_types, |
1892 const unsigned long long* arg_values, | 1898 const unsigned long long* arg_values, |
1893 const scoped_refptr<ConvertableToTraceFormat>* convertable_values, | 1899 const scoped_refptr<ConvertableToTraceFormat>* convertable_values, |
1894 unsigned char flags) { | 1900 unsigned char flags) { |
1895 TraceEventHandle handle = { 0, 0, 0 }; | 1901 TraceEventHandle handle = { 0, 0, 0 }; |
1896 if (!*category_group_enabled) | 1902 if (!*category_group_enabled) |
1897 return handle; | 1903 return handle; |
1898 | 1904 |
1905 #if defined(OS_WIN) | |
1906 if (*category_group_enabled & ENABLED_FOR_ETW_EXPORT) | |
dsinclair
2015/03/26 18:18:17
I think this should be down around where the andro
Georges Khalil
2015/03/26 23:09:19
After discussion, brought this down but before the
| |
1907 TraceEventETWExport::AddEvent(phase, category_group_enabled, name, id, | |
1908 num_args, arg_names, arg_types, arg_values, | |
1909 convertable_values); | |
1910 #endif // OS_WIN | |
1911 | |
1899 // Avoid re-entrance of AddTraceEvent. This may happen in GPU process when | 1912 // Avoid re-entrance of AddTraceEvent. This may happen in GPU process when |
1900 // ECHO_TO_CONSOLE is enabled: AddTraceEvent -> LOG(ERROR) -> | 1913 // ECHO_TO_CONSOLE is enabled: AddTraceEvent -> LOG(ERROR) -> |
1901 // GpuProcessLogMessageHandler -> PostPendingTask -> TRACE_EVENT ... | 1914 // GpuProcessLogMessageHandler -> PostPendingTask -> TRACE_EVENT ... |
1902 if (thread_is_in_trace_event_.Get()) | 1915 if (thread_is_in_trace_event_.Get()) |
1903 return handle; | 1916 return handle; |
1904 | 1917 |
1905 AutoThreadLocalBoolean thread_is_in_trace_event(&thread_is_in_trace_event_); | 1918 AutoThreadLocalBoolean thread_is_in_trace_event(&thread_is_in_trace_event_); |
1906 | 1919 |
1907 DCHECK(name); | 1920 DCHECK(name); |
1908 DCHECK(!timestamp.is_null()); | 1921 DCHECK(!timestamp.is_null()); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2107 TraceEventETWProvider::Trace(name, phase, id, extra); | 2120 TraceEventETWProvider::Trace(name, phase, id, extra); |
2108 #endif | 2121 #endif |
2109 INTERNAL_TRACE_EVENT_ADD(phase, "ETW Trace Event", name, | 2122 INTERNAL_TRACE_EVENT_ADD(phase, "ETW Trace Event", name, |
2110 TRACE_EVENT_FLAG_COPY, "id", id, "extra", extra); | 2123 TRACE_EVENT_FLAG_COPY, "id", id, "extra", extra); |
2111 } | 2124 } |
2112 | 2125 |
2113 void TraceLog::UpdateTraceEventDuration( | 2126 void TraceLog::UpdateTraceEventDuration( |
2114 const unsigned char* category_group_enabled, | 2127 const unsigned char* category_group_enabled, |
2115 const char* name, | 2128 const char* name, |
2116 TraceEventHandle handle) { | 2129 TraceEventHandle handle) { |
2130 #if defined(OS_WIN) | |
2131 if (*category_group_enabled & ENABLED_FOR_ETW_EXPORT) | |
2132 TraceEventETWExport::AddEvent(TRACE_EVENT_PHASE_END, category_group_enabled, | |
dsinclair
2015/03/26 18:18:17
This isn't what you want here. This is just going
Georges Khalil
2015/03/26 23:09:19
After review and discussion, this code should be r
| |
2133 name, 0, 0, NULL, NULL, NULL, NULL); | |
2134 #endif // OS_WIN | |
2135 | |
2117 // Avoid re-entrance of AddTraceEvent. This may happen in GPU process when | 2136 // Avoid re-entrance of AddTraceEvent. This may happen in GPU process when |
2118 // ECHO_TO_CONSOLE is enabled: AddTraceEvent -> LOG(ERROR) -> | 2137 // ECHO_TO_CONSOLE is enabled: AddTraceEvent -> LOG(ERROR) -> |
2119 // GpuProcessLogMessageHandler -> PostPendingTask -> TRACE_EVENT ... | 2138 // GpuProcessLogMessageHandler -> PostPendingTask -> TRACE_EVENT ... |
2120 if (thread_is_in_trace_event_.Get()) | 2139 if (thread_is_in_trace_event_.Get()) |
2121 return; | 2140 return; |
2122 | 2141 |
2123 AutoThreadLocalBoolean thread_is_in_trace_event(&thread_is_in_trace_event_); | 2142 AutoThreadLocalBoolean thread_is_in_trace_event(&thread_is_in_trace_event_); |
2124 | 2143 |
2125 TimeTicks thread_now = ThreadNow(); | 2144 TimeTicks thread_now = ThreadNow(); |
2126 TimeTicks now = OffsetNow(); | 2145 TimeTicks now = OffsetNow(); |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2602 } | 2621 } |
2603 | 2622 |
2604 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { | 2623 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { |
2605 if (*category_group_enabled_) { | 2624 if (*category_group_enabled_) { |
2606 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, | 2625 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, |
2607 name_, event_handle_); | 2626 name_, event_handle_); |
2608 } | 2627 } |
2609 } | 2628 } |
2610 | 2629 |
2611 } // namespace trace_event_internal | 2630 } // namespace trace_event_internal |
OLD | NEW |