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/process_memory_maps_dump_provider.h" | 5 #include "base/trace_event/process_memory_maps_dump_provider.h" |
6 | 6 |
7 #include <cctype> | 7 #include <cctype> |
8 #include <fstream> | 8 #include <fstream> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 return Singleton<ProcessMemoryMapsDumpProvider, | 156 return Singleton<ProcessMemoryMapsDumpProvider, |
157 LeakySingletonTraits<ProcessMemoryMapsDumpProvider>>::get(); | 157 LeakySingletonTraits<ProcessMemoryMapsDumpProvider>>::get(); |
158 } | 158 } |
159 | 159 |
160 ProcessMemoryMapsDumpProvider::ProcessMemoryMapsDumpProvider() { | 160 ProcessMemoryMapsDumpProvider::ProcessMemoryMapsDumpProvider() { |
161 } | 161 } |
162 | 162 |
163 ProcessMemoryMapsDumpProvider::~ProcessMemoryMapsDumpProvider() { | 163 ProcessMemoryMapsDumpProvider::~ProcessMemoryMapsDumpProvider() { |
164 } | 164 } |
165 | 165 |
166 // Called at trace dump point time. Creates a snapshot the memory maps for the | 166 // Called at trace dump point time. Creates a snapshot of the memory maps for |
167 // current process. | 167 // the current process. |
168 bool ProcessMemoryMapsDumpProvider::OnMemoryDump(ProcessMemoryDump* pmd) { | 168 bool ProcessMemoryMapsDumpProvider::OnMemoryDump(const MemoryDumpArgs& args, |
| 169 ProcessMemoryDump* pmd) { |
| 170 // TODO(ssid): Use MemoryDumpArgs to create light dumps when requested |
| 171 // (crbug.com/499731). |
| 172 |
169 uint32 res = 0; | 173 uint32 res = 0; |
170 | 174 |
171 #if defined(OS_LINUX) || defined(OS_ANDROID) | 175 #if defined(OS_LINUX) || defined(OS_ANDROID) |
172 if (UNLIKELY(proc_smaps_for_testing)) { | 176 if (UNLIKELY(proc_smaps_for_testing)) { |
173 res = ReadLinuxProcSmapsFile(proc_smaps_for_testing, pmd->process_mmaps()); | 177 res = ReadLinuxProcSmapsFile(proc_smaps_for_testing, pmd->process_mmaps()); |
174 } else { | 178 } else { |
175 std::ifstream proc_self_smaps("/proc/self/smaps"); | 179 std::ifstream proc_self_smaps("/proc/self/smaps"); |
176 res = ReadLinuxProcSmapsFile(&proc_self_smaps, pmd->process_mmaps()); | 180 res = ReadLinuxProcSmapsFile(&proc_self_smaps, pmd->process_mmaps()); |
177 } | 181 } |
178 #else | 182 #else |
179 LOG(ERROR) << "ProcessMemoryMaps dump provider is supported only on Linux"; | 183 LOG(ERROR) << "ProcessMemoryMaps dump provider is supported only on Linux"; |
180 #endif | 184 #endif |
181 | 185 |
182 if (res > 0) { | 186 if (res > 0) { |
183 pmd->set_has_process_mmaps(); | 187 pmd->set_has_process_mmaps(); |
184 return true; | 188 return true; |
185 } | 189 } |
186 | 190 |
187 return false; | 191 return false; |
188 } | 192 } |
189 | 193 |
190 } // namespace trace_event | 194 } // namespace trace_event |
191 } // namespace base | 195 } // namespace base |
OLD | NEW |