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 <inttypes.h> | 7 #include <inttypes.h> |
8 #include <stdio.h> | 8 #include <stdio.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 "GlobalMemoryDump", TRACE_ID_LOCAL(dump_guid), | 91 "GlobalMemoryDump", TRACE_ID_LOCAL(dump_guid), |
92 "dump_guid", TRACE_STR_COPY(guid_str), | 92 "dump_guid", TRACE_STR_COPY(guid_str), |
93 "success", success); | 93 "success", success); |
94 | 94 |
95 if (!wrapped_callback.is_null()) { | 95 if (!wrapped_callback.is_null()) { |
96 wrapped_callback.Run(dump_guid, success); | 96 wrapped_callback.Run(dump_guid, success); |
97 wrapped_callback.Reset(); | 97 wrapped_callback.Reset(); |
98 } | 98 } |
99 } | 99 } |
100 | 100 |
| 101 void FillOsDumpFromProcessMemoryDump( |
| 102 const ProcessMemoryDump* pmd, |
| 103 MemoryDumpCallbackResult::OSMemDump* osDump) { |
| 104 if (pmd->has_process_totals()) { |
| 105 const ProcessMemoryTotals* totals = pmd->process_totals(); |
| 106 osDump->resident_set_kb = totals->resident_set_bytes() / 1024; |
| 107 } |
| 108 } |
| 109 |
101 // Proxy class which wraps a ConvertableToTraceFormat owned by the | 110 // Proxy class which wraps a ConvertableToTraceFormat owned by the |
102 // |session_state| into a proxy object that can be added to the trace event log. | 111 // |session_state| into a proxy object that can be added to the trace event log. |
103 // This is to solve the problem that the MemoryDumpSessionState is refcounted | 112 // This is to solve the problem that the MemoryDumpSessionState is refcounted |
104 // but the tracing subsystem wants a std::unique_ptr<ConvertableToTraceFormat>. | 113 // but the tracing subsystem wants a std::unique_ptr<ConvertableToTraceFormat>. |
105 template <typename T> | 114 template <typename T> |
106 struct SessionStateConvertableProxy : public ConvertableToTraceFormat { | 115 struct SessionStateConvertableProxy : public ConvertableToTraceFormat { |
107 using GetterFunctPtr = T* (MemoryDumpSessionState::*)() const; | 116 using GetterFunctPtr = T* (MemoryDumpSessionState::*)() const; |
108 | 117 |
109 SessionStateConvertableProxy( | 118 SessionStateConvertableProxy( |
110 scoped_refptr<MemoryDumpSessionState> session_state, | 119 scoped_refptr<MemoryDumpSessionState> session_state, |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 GetDumpsSumKb("v8/*", process_memory_dump); | 809 GetDumpsSumKb("v8/*", process_memory_dump); |
801 | 810 |
802 // partition_alloc reports sizes for both allocated_objects and | 811 // partition_alloc reports sizes for both allocated_objects and |
803 // partitions. The memory allocated_objects uses is a subset of | 812 // partitions. The memory allocated_objects uses is a subset of |
804 // the partitions memory so to avoid double counting we only | 813 // the partitions memory so to avoid double counting we only |
805 // count partitions memory. | 814 // count partitions memory. |
806 result.chrome_dump.partition_alloc_total_kb = | 815 result.chrome_dump.partition_alloc_total_kb = |
807 GetDumpsSumKb("partition_alloc/partitions/*", process_memory_dump); | 816 GetDumpsSumKb("partition_alloc/partitions/*", process_memory_dump); |
808 result.chrome_dump.blink_gc_total_kb = | 817 result.chrome_dump.blink_gc_total_kb = |
809 GetDumpsSumKb("blink_gc", process_memory_dump); | 818 GetDumpsSumKb("blink_gc", process_memory_dump); |
| 819 FillOsDumpFromProcessMemoryDump(process_memory_dump, &result.os_dump); |
| 820 } else { |
| 821 auto& os_dump = result.extra_processes_dump[pid]; |
| 822 FillOsDumpFromProcessMemoryDump(process_memory_dump, &os_dump); |
810 } | 823 } |
811 } | 824 } |
812 | 825 |
813 bool tracing_still_enabled; | 826 bool tracing_still_enabled; |
814 TRACE_EVENT_CATEGORY_GROUP_ENABLED(kTraceCategory, &tracing_still_enabled); | 827 TRACE_EVENT_CATEGORY_GROUP_ENABLED(kTraceCategory, &tracing_still_enabled); |
815 if (!tracing_still_enabled) { | 828 if (!tracing_still_enabled) { |
816 pmd_async_state->dump_successful = false; | 829 pmd_async_state->dump_successful = false; |
817 VLOG(1) << kLogPrefix << " failed because tracing was disabled before" | 830 VLOG(1) << kLogPrefix << " failed because tracing was disabled before" |
818 << " the dump was completed"; | 831 << " the dump was completed"; |
819 } | 832 } |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 if (iter == process_dumps.end()) { | 995 if (iter == process_dumps.end()) { |
983 std::unique_ptr<ProcessMemoryDump> new_pmd( | 996 std::unique_ptr<ProcessMemoryDump> new_pmd( |
984 new ProcessMemoryDump(session_state, dump_args)); | 997 new ProcessMemoryDump(session_state, dump_args)); |
985 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; | 998 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; |
986 } | 999 } |
987 return iter->second.get(); | 1000 return iter->second.get(); |
988 } | 1001 } |
989 | 1002 |
990 } // namespace trace_event | 1003 } // namespace trace_event |
991 } // namespace base | 1004 } // namespace base |
OLD | NEW |