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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } | 161 } |
162 | 162 |
163 ProcessMemoryMapsDumpProvider::~ProcessMemoryMapsDumpProvider() { | 163 ProcessMemoryMapsDumpProvider::~ProcessMemoryMapsDumpProvider() { |
164 } | 164 } |
165 | 165 |
166 // Called at trace dump point time. Creates a snapshot of the memory maps for | 166 // Called at trace dump point time. Creates a snapshot of the memory maps for |
167 // the current process. | 167 // the current process. |
168 bool ProcessMemoryMapsDumpProvider::OnMemoryDump(const MemoryDumpArgs& args, | 168 bool ProcessMemoryMapsDumpProvider::OnMemoryDump(const MemoryDumpArgs& args, |
169 ProcessMemoryDump* pmd) { | 169 ProcessMemoryDump* pmd) { |
170 // Snapshot of memory maps is not taken for light dump requests. | 170 // Snapshot of memory maps is not taken for light dump requests. |
171 if (args.level_of_detail == MemoryDumpArgs::LevelOfDetail::LOW) | 171 if (args.level_of_detail == MemoryDumpLevelOfDetail::LIGHT) |
172 return true; | 172 return true; |
173 | 173 |
174 uint32 res = 0; | 174 uint32 res = 0; |
175 | 175 |
176 #if defined(OS_LINUX) || defined(OS_ANDROID) | 176 #if defined(OS_LINUX) || defined(OS_ANDROID) |
177 if (UNLIKELY(proc_smaps_for_testing)) { | 177 if (UNLIKELY(proc_smaps_for_testing)) { |
178 res = ReadLinuxProcSmapsFile(proc_smaps_for_testing, pmd->process_mmaps()); | 178 res = ReadLinuxProcSmapsFile(proc_smaps_for_testing, pmd->process_mmaps()); |
179 } else { | 179 } else { |
180 std::ifstream proc_self_smaps("/proc/self/smaps"); | 180 std::ifstream proc_self_smaps("/proc/self/smaps"); |
181 res = ReadLinuxProcSmapsFile(&proc_self_smaps, pmd->process_mmaps()); | 181 res = ReadLinuxProcSmapsFile(&proc_self_smaps, pmd->process_mmaps()); |
182 } | 182 } |
183 #else | 183 #else |
184 LOG(ERROR) << "ProcessMemoryMaps dump provider is supported only on Linux"; | 184 LOG(ERROR) << "ProcessMemoryMaps dump provider is supported only on Linux"; |
185 #endif | 185 #endif |
186 | 186 |
187 if (res > 0) { | 187 if (res > 0) { |
188 pmd->set_has_process_mmaps(); | 188 pmd->set_has_process_mmaps(); |
189 return true; | 189 return true; |
190 } | 190 } |
191 | 191 |
192 return false; | 192 return false; |
193 } | 193 } |
194 | 194 |
195 } // namespace trace_event | 195 } // namespace trace_event |
196 } // namespace base | 196 } // namespace base |
OLD | NEW |