| 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 | 9 |
| 10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "base/trace_event/memory_profiler_allocation_context.h" | 30 #include "base/trace_event/memory_profiler_allocation_context.h" |
| 31 #include "base/trace_event/process_memory_dump.h" | 31 #include "base/trace_event/process_memory_dump.h" |
| 32 #include "base/trace_event/trace_buffer.h" | 32 #include "base/trace_event/trace_buffer.h" |
| 33 #include "base/trace_event/trace_event.h" | 33 #include "base/trace_event/trace_event.h" |
| 34 #include "base/trace_event/trace_event_synthetic_delay.h" | 34 #include "base/trace_event/trace_event_synthetic_delay.h" |
| 35 #include "base/trace_event/trace_log.h" | 35 #include "base/trace_event/trace_log.h" |
| 36 #include "base/trace_event/trace_sampling_thread.h" | 36 #include "base/trace_event/trace_sampling_thread.h" |
| 37 | 37 |
| 38 #if defined(OS_WIN) | 38 #if defined(OS_WIN) |
| 39 #include "base/trace_event/trace_event_etw_export_win.h" | 39 #include "base/trace_event/trace_event_etw_export_win.h" |
| 40 #include "base/trace_event/trace_event_win.h" | |
| 41 #endif | 40 #endif |
| 42 | 41 |
| 43 // The thread buckets for the sampling profiler. | 42 // The thread buckets for the sampling profiler. |
| 44 BASE_EXPORT TRACE_EVENT_API_ATOMIC_WORD g_trace_state[3]; | 43 BASE_EXPORT TRACE_EVENT_API_ATOMIC_WORD g_trace_state[3]; |
| 45 | 44 |
| 46 namespace base { | 45 namespace base { |
| 47 namespace internal { | 46 namespace internal { |
| 48 | 47 |
| 49 class DeleteTraceLogForTesting { | 48 class DeleteTraceLogForTesting { |
| 50 public: | 49 public: |
| (...skipping 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1374 log << base::StringPrintf(" (%.3f ms)", duration.InMillisecondsF()); | 1373 log << base::StringPrintf(" (%.3f ms)", duration.InMillisecondsF()); |
| 1375 | 1374 |
| 1376 log << "\x1b[0;m"; | 1375 log << "\x1b[0;m"; |
| 1377 | 1376 |
| 1378 if (phase == TRACE_EVENT_PHASE_BEGIN) | 1377 if (phase == TRACE_EVENT_PHASE_BEGIN) |
| 1379 thread_event_start_times_[thread_id].push(timestamp); | 1378 thread_event_start_times_[thread_id].push(timestamp); |
| 1380 | 1379 |
| 1381 return log.str(); | 1380 return log.str(); |
| 1382 } | 1381 } |
| 1383 | 1382 |
| 1384 void TraceLog::AddTraceEventEtw(char phase, | |
| 1385 const char* name, | |
| 1386 const void* id, | |
| 1387 const char* extra) { | |
| 1388 #if defined(OS_WIN) | |
| 1389 TraceEventETWProvider::Trace(name, phase, id, extra); | |
| 1390 #endif | |
| 1391 INTERNAL_TRACE_EVENT_ADD(phase, "ETW Trace Event", name, | |
| 1392 TRACE_EVENT_FLAG_COPY, "id", id, "extra", extra); | |
| 1393 } | |
| 1394 | |
| 1395 void TraceLog::AddTraceEventEtw(char phase, | |
| 1396 const char* name, | |
| 1397 const void* id, | |
| 1398 const std::string& extra) { | |
| 1399 #if defined(OS_WIN) | |
| 1400 TraceEventETWProvider::Trace(name, phase, id, extra); | |
| 1401 #endif | |
| 1402 INTERNAL_TRACE_EVENT_ADD(phase, "ETW Trace Event", name, | |
| 1403 TRACE_EVENT_FLAG_COPY, "id", id, "extra", extra); | |
| 1404 } | |
| 1405 | |
| 1406 void TraceLog::UpdateTraceEventDuration( | 1383 void TraceLog::UpdateTraceEventDuration( |
| 1407 const unsigned char* category_group_enabled, | 1384 const unsigned char* category_group_enabled, |
| 1408 const char* name, | 1385 const char* name, |
| 1409 TraceEventHandle handle) { | 1386 TraceEventHandle handle) { |
| 1410 // Avoid re-entrance of AddTraceEvent. This may happen in GPU process when | 1387 // Avoid re-entrance of AddTraceEvent. This may happen in GPU process when |
| 1411 // ECHO_TO_CONSOLE is enabled: AddTraceEvent -> LOG(ERROR) -> | 1388 // ECHO_TO_CONSOLE is enabled: AddTraceEvent -> LOG(ERROR) -> |
| 1412 // GpuProcessLogMessageHandler -> PostPendingTask -> TRACE_EVENT ... | 1389 // GpuProcessLogMessageHandler -> PostPendingTask -> TRACE_EVENT ... |
| 1413 if (thread_is_in_trace_event_.Get()) | 1390 if (thread_is_in_trace_event_.Get()) |
| 1414 return; | 1391 return; |
| 1415 | 1392 |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1719 } | 1696 } |
| 1720 | 1697 |
| 1721 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { | 1698 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { |
| 1722 if (*category_group_enabled_) { | 1699 if (*category_group_enabled_) { |
| 1723 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, | 1700 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, |
| 1724 event_handle_); | 1701 event_handle_); |
| 1725 } | 1702 } |
| 1726 } | 1703 } |
| 1727 | 1704 |
| 1728 } // namespace trace_event_internal | 1705 } // namespace trace_event_internal |
| OLD | NEW |