| 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" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/debug/leak_annotations.h" | 13 #include "base/debug/leak_annotations.h" |
| 14 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
| 15 #include "base/location.h" | 15 #include "base/location.h" |
| 16 #include "base/memory/singleton.h" | 16 #include "base/memory/singleton.h" |
| 17 #include "base/process/process_metrics.h" | 17 #include "base/process/process_metrics.h" |
| 18 #include "base/strings/string_split.h" | 18 #include "base/strings/string_split.h" |
| 19 #include "base/strings/string_tokenizer.h" | 19 #include "base/strings/string_tokenizer.h" |
| 20 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
| 21 #include "base/sys_info.h" | 21 #include "base/sys_info.h" |
| 22 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 22 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
| 23 #include "base/thread_task_runner_handle.h" | 23 #include "base/thread_task_runner_handle.h" |
| 24 #include "base/threading/platform_thread.h" | 24 #include "base/threading/platform_thread.h" |
| 25 #include "base/threading/thread_id_name_manager.h" | 25 #include "base/threading/thread_id_name_manager.h" |
| 26 #include "base/threading/worker_pool.h" | 26 #include "base/threading/worker_pool.h" |
| 27 #include "base/time/time.h" | 27 #include "base/time/time.h" |
| 28 #include "base/trace_event/memory_dump_manager.h" | 28 #include "base/trace_event/memory_dump_manager.h" |
| 29 #include "base/trace_event/memory_dump_provider.h" | 29 #include "base/trace_event/memory_dump_provider.h" |
| 30 #include "base/trace_event/memory_profiler_allocation_context.h" | |
| 31 #include "base/trace_event/process_memory_dump.h" | 30 #include "base/trace_event/process_memory_dump.h" |
| 32 #include "base/trace_event/trace_buffer.h" | 31 #include "base/trace_event/trace_buffer.h" |
| 33 #include "base/trace_event/trace_event.h" | 32 #include "base/trace_event/trace_event.h" |
| 34 #include "base/trace_event/trace_event_synthetic_delay.h" | 33 #include "base/trace_event/trace_event_synthetic_delay.h" |
| 35 #include "base/trace_event/trace_log.h" | 34 #include "base/trace_event/trace_log.h" |
| 36 #include "base/trace_event/trace_sampling_thread.h" | 35 #include "base/trace_event/trace_sampling_thread.h" |
| 37 | 36 |
| 38 #if defined(OS_WIN) | 37 #if defined(OS_WIN) |
| 39 #include "base/trace_event/trace_event_etw_export_win.h" | 38 #include "base/trace_event/trace_event_etw_export_win.h" |
| 40 #include "base/trace_event/trace_event_win.h" | 39 #include "base/trace_event/trace_event_win.h" |
| (...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1314 subtle::NoBarrier_Load(&event_callback_)); | 1313 subtle::NoBarrier_Load(&event_callback_)); |
| 1315 if (event_callback) { | 1314 if (event_callback) { |
| 1316 event_callback( | 1315 event_callback( |
| 1317 offset_event_timestamp, | 1316 offset_event_timestamp, |
| 1318 phase == TRACE_EVENT_PHASE_COMPLETE ? TRACE_EVENT_PHASE_BEGIN : phase, | 1317 phase == TRACE_EVENT_PHASE_COMPLETE ? TRACE_EVENT_PHASE_BEGIN : phase, |
| 1319 category_group_enabled, name, id, num_args, arg_names, arg_types, | 1318 category_group_enabled, name, id, num_args, arg_names, arg_types, |
| 1320 arg_values, flags); | 1319 arg_values, flags); |
| 1321 } | 1320 } |
| 1322 } | 1321 } |
| 1323 | 1322 |
| 1324 if (base::trace_event::AllocationContextTracker::capture_enabled()) { | |
| 1325 if (phase == TRACE_EVENT_PHASE_BEGIN || phase == TRACE_EVENT_PHASE_COMPLETE) | |
| 1326 base::trace_event::AllocationContextTracker::PushPseudoStackFrame(name); | |
| 1327 else if (phase == TRACE_EVENT_PHASE_END) | |
| 1328 // The pop for |TRACE_EVENT_PHASE_COMPLETE| events | |
| 1329 // is in |TraceLog::UpdateTraceEventDuration|. | |
| 1330 base::trace_event::AllocationContextTracker::PopPseudoStackFrame(name); | |
| 1331 } | |
| 1332 | |
| 1333 return handle; | 1323 return handle; |
| 1334 } | 1324 } |
| 1335 | 1325 |
| 1336 // May be called when a COMPELETE event ends and the unfinished event has been | 1326 // May be called when a COMPELETE event ends and the unfinished event has been |
| 1337 // recycled (phase == TRACE_EVENT_PHASE_END and trace_event == NULL). | 1327 // recycled (phase == TRACE_EVENT_PHASE_END and trace_event == NULL). |
| 1338 std::string TraceLog::EventToConsoleMessage(unsigned char phase, | 1328 std::string TraceLog::EventToConsoleMessage(unsigned char phase, |
| 1339 const TraceTicks& timestamp, | 1329 const TraceTicks& timestamp, |
| 1340 TraceEvent* trace_event) { | 1330 TraceEvent* trace_event) { |
| 1341 AutoLock thread_info_lock(thread_info_lock_); | 1331 AutoLock thread_info_lock(thread_info_lock_); |
| 1342 | 1332 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1428 trace_event->UpdateDuration(now, thread_now); | 1418 trace_event->UpdateDuration(now, thread_now); |
| 1429 #if defined(OS_ANDROID) | 1419 #if defined(OS_ANDROID) |
| 1430 trace_event->SendToATrace(); | 1420 trace_event->SendToATrace(); |
| 1431 #endif | 1421 #endif |
| 1432 } | 1422 } |
| 1433 | 1423 |
| 1434 if (trace_options() & kInternalEchoToConsole) { | 1424 if (trace_options() & kInternalEchoToConsole) { |
| 1435 console_message = | 1425 console_message = |
| 1436 EventToConsoleMessage(TRACE_EVENT_PHASE_END, now, trace_event); | 1426 EventToConsoleMessage(TRACE_EVENT_PHASE_END, now, trace_event); |
| 1437 } | 1427 } |
| 1438 | |
| 1439 if (base::trace_event::AllocationContextTracker::capture_enabled()) { | |
| 1440 // The corresponding push is in |AddTraceEventWithThreadIdAndTimestamp|. | |
| 1441 base::trace_event::AllocationContextTracker::PopPseudoStackFrame(name); | |
| 1442 } | |
| 1443 } | 1428 } |
| 1444 | 1429 |
| 1445 if (console_message.size()) | 1430 if (console_message.size()) |
| 1446 LOG(ERROR) << console_message; | 1431 LOG(ERROR) << console_message; |
| 1447 | 1432 |
| 1448 if (*category_group_enabled & ENABLED_FOR_EVENT_CALLBACK) { | 1433 if (*category_group_enabled & ENABLED_FOR_EVENT_CALLBACK) { |
| 1449 EventCallback event_callback = reinterpret_cast<EventCallback>( | 1434 EventCallback event_callback = reinterpret_cast<EventCallback>( |
| 1450 subtle::NoBarrier_Load(&event_callback_)); | 1435 subtle::NoBarrier_Load(&event_callback_)); |
| 1451 if (event_callback) { | 1436 if (event_callback) { |
| 1452 event_callback(now, TRACE_EVENT_PHASE_END, category_group_enabled, name, | 1437 event_callback(now, TRACE_EVENT_PHASE_END, category_group_enabled, name, |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1719 } | 1704 } |
| 1720 | 1705 |
| 1721 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { | 1706 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { |
| 1722 if (*category_group_enabled_) { | 1707 if (*category_group_enabled_) { |
| 1723 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, | 1708 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, |
| 1724 event_handle_); | 1709 event_handle_); |
| 1725 } | 1710 } |
| 1726 } | 1711 } |
| 1727 | 1712 |
| 1728 } // namespace trace_event_internal | 1713 } // namespace trace_event_internal |
| OLD | NEW |