Chromium Code Reviews| 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/memory_dump_manager.h" | 5 #include "base/trace_event/memory_dump_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/allocator/features.h" | 10 #include "base/allocator/features.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 TRACE_EVENT_NESTABLE_ASYNC_END1( | 85 TRACE_EVENT_NESTABLE_ASYNC_END1( |
| 86 MemoryDumpManager::kTraceCategory, "GlobalMemoryDump", | 86 MemoryDumpManager::kTraceCategory, "GlobalMemoryDump", |
| 87 TRACE_ID_MANGLE(dump_guid), "success", success); | 87 TRACE_ID_MANGLE(dump_guid), "success", success); |
| 88 | 88 |
| 89 if (!wrapped_callback.is_null()) { | 89 if (!wrapped_callback.is_null()) { |
| 90 wrapped_callback.Run(dump_guid, success); | 90 wrapped_callback.Run(dump_guid, success); |
| 91 wrapped_callback.Reset(); | 91 wrapped_callback.Reset(); |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 | 94 |
| 95 void FillOsDumpFromProcessMemoryDump( | |
| 96 MemoryDumpCallbackResult::OSMemDump& osDump, | |
|
Primiano Tucci (use gerrit)
2017/04/03 08:49:27
output arguments should:
1. use pointers, not refe
| |
| 97 ProcessMemoryDump* pmd) { | |
| 98 if (pmd->has_process_totals()) { | |
| 99 auto* totals = pmd->process_totals(); | |
|
Primiano Tucci (use gerrit)
2017/04/03 08:49:27
minor thing about "auto". There are no official ru
| |
| 100 osDump.resident_set_kb = totals->resident_set_bytes() / 1024; | |
| 101 } | |
| 102 } | |
| 103 | |
| 95 // Proxy class which wraps a ConvertableToTraceFormat owned by the | 104 // Proxy class which wraps a ConvertableToTraceFormat owned by the |
| 96 // |session_state| into a proxy object that can be added to the trace event log. | 105 // |session_state| into a proxy object that can be added to the trace event log. |
| 97 // This is to solve the problem that the MemoryDumpSessionState is refcounted | 106 // This is to solve the problem that the MemoryDumpSessionState is refcounted |
| 98 // but the tracing subsystem wants a std::unique_ptr<ConvertableToTraceFormat>. | 107 // but the tracing subsystem wants a std::unique_ptr<ConvertableToTraceFormat>. |
| 99 template <typename T> | 108 template <typename T> |
| 100 struct SessionStateConvertableProxy : public ConvertableToTraceFormat { | 109 struct SessionStateConvertableProxy : public ConvertableToTraceFormat { |
| 101 using GetterFunctPtr = T* (MemoryDumpSessionState::*)() const; | 110 using GetterFunctPtr = T* (MemoryDumpSessionState::*)() const; |
| 102 | 111 |
| 103 SessionStateConvertableProxy( | 112 SessionStateConvertableProxy( |
| 104 scoped_refptr<MemoryDumpSessionState> session_state, | 113 scoped_refptr<MemoryDumpSessionState> session_state, |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 791 GetDumpsSumKb("v8/*", process_memory_dump); | 800 GetDumpsSumKb("v8/*", process_memory_dump); |
| 792 | 801 |
| 793 // partition_alloc reports sizes for both allocated_objects and | 802 // partition_alloc reports sizes for both allocated_objects and |
| 794 // partitions. The memory allocated_objects uses is a subset of | 803 // partitions. The memory allocated_objects uses is a subset of |
| 795 // the partitions memory so to avoid double counting we only | 804 // the partitions memory so to avoid double counting we only |
| 796 // count partitions memory. | 805 // count partitions memory. |
| 797 result.chrome_dump.partition_alloc_total_kb = | 806 result.chrome_dump.partition_alloc_total_kb = |
| 798 GetDumpsSumKb("partition_alloc/partitions/*", process_memory_dump); | 807 GetDumpsSumKb("partition_alloc/partitions/*", process_memory_dump); |
| 799 result.chrome_dump.blink_gc_total_kb = | 808 result.chrome_dump.blink_gc_total_kb = |
| 800 GetDumpsSumKb("blink_gc", process_memory_dump); | 809 GetDumpsSumKb("blink_gc", process_memory_dump); |
| 810 FillOsDumpFromProcessMemoryDump(result.os_dump, process_memory_dump); | |
| 811 } else { | |
| 812 auto& os_dump = result.extra_processes_dump[pid]; | |
| 813 FillOsDumpFromProcessMemoryDump(os_dump, process_memory_dump); | |
| 801 } | 814 } |
| 802 } | 815 } |
| 803 | 816 |
| 804 bool tracing_still_enabled; | 817 bool tracing_still_enabled; |
| 805 TRACE_EVENT_CATEGORY_GROUP_ENABLED(kTraceCategory, &tracing_still_enabled); | 818 TRACE_EVENT_CATEGORY_GROUP_ENABLED(kTraceCategory, &tracing_still_enabled); |
| 806 if (!tracing_still_enabled) { | 819 if (!tracing_still_enabled) { |
| 807 pmd_async_state->dump_successful = false; | 820 pmd_async_state->dump_successful = false; |
| 808 VLOG(1) << kLogPrefix << " failed because tracing was disabled before" | 821 VLOG(1) << kLogPrefix << " failed because tracing was disabled before" |
| 809 << " the dump was completed"; | 822 << " the dump was completed"; |
| 810 } | 823 } |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1003 if (iter == process_dumps.end()) { | 1016 if (iter == process_dumps.end()) { |
| 1004 std::unique_ptr<ProcessMemoryDump> new_pmd( | 1017 std::unique_ptr<ProcessMemoryDump> new_pmd( |
| 1005 new ProcessMemoryDump(session_state, dump_args)); | 1018 new ProcessMemoryDump(session_state, dump_args)); |
| 1006 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; | 1019 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; |
| 1007 } | 1020 } |
| 1008 return iter->second.get(); | 1021 return iter->second.get(); |
| 1009 } | 1022 } |
| 1010 | 1023 |
| 1011 } // namespace trace_event | 1024 } // namespace trace_event |
| 1012 } // namespace base | 1025 } // namespace base |
| OLD | NEW |