| 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 "components/tracing/common/process_metrics_memory_dump_provider.h" | 5 #include "components/tracing/common/process_metrics_memory_dump_provider.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 #include "base/numerics/safe_math.h" | 38 #include "base/numerics/safe_math.h" |
| 39 #include "base/process/process_metrics.h" | 39 #include "base/process/process_metrics.h" |
| 40 #endif // defined(OS_MACOSX) | 40 #endif // defined(OS_MACOSX) |
| 41 | 41 |
| 42 #if defined(OS_WIN) | 42 #if defined(OS_WIN) |
| 43 #include <psapi.h> | 43 #include <psapi.h> |
| 44 #include <tchar.h> | 44 #include <tchar.h> |
| 45 #include <windows.h> | 45 #include <windows.h> |
| 46 | 46 |
| 47 #include <base/strings/sys_string_conversions.h> | 47 #include <base/strings/sys_string_conversions.h> |
| 48 #include <base/win/pe_image.h> |
| 48 #include <base/win/win_util.h> | 49 #include <base/win/win_util.h> |
| 49 #endif // defined(OS_WIN) | 50 #endif // defined(OS_WIN) |
| 50 | 51 |
| 51 namespace tracing { | 52 namespace tracing { |
| 52 | 53 |
| 53 namespace { | 54 namespace { |
| 54 | 55 |
| 55 base::LazyInstance< | 56 base::LazyInstance< |
| 56 std::map<base::ProcessId, | 57 std::map<base::ProcessId, |
| 57 std::unique_ptr<ProcessMetricsMemoryDumpProvider>>>::Leaky | 58 std::unique_ptr<ProcessMetricsMemoryDumpProvider>>>::Leaky |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 | 267 |
| 267 MODULEINFO module_info; | 268 MODULEINFO module_info; |
| 268 if (!::GetModuleInformation(::GetCurrentProcess(), modules[i], | 269 if (!::GetModuleInformation(::GetCurrentProcess(), modules[i], |
| 269 &module_info, sizeof(MODULEINFO))) { | 270 &module_info, sizeof(MODULEINFO))) { |
| 270 continue; | 271 continue; |
| 271 } | 272 } |
| 272 base::trace_event::ProcessMemoryMaps::VMRegion region; | 273 base::trace_event::ProcessMemoryMaps::VMRegion region; |
| 273 region.size_in_bytes = module_info.SizeOfImage; | 274 region.size_in_bytes = module_info.SizeOfImage; |
| 274 region.mapped_file = base::SysWideToNativeMB(module_name); | 275 region.mapped_file = base::SysWideToNativeMB(module_name); |
| 275 region.start_address = reinterpret_cast<uint64_t>(module_info.lpBaseOfDll); | 276 region.start_address = reinterpret_cast<uint64_t>(module_info.lpBaseOfDll); |
| 277 |
| 278 // The PE header field |TimeDateStamp| is required to build the PE code |
| 279 // identifier which is used as a key to query symbols servers. |
| 280 base::win::PEImage pe_image(module_info.lpBaseOfDll); |
| 281 region.module_timestamp = pe_image.GetNTHeaders()->FileHeader.TimeDateStamp; |
| 282 |
| 276 pmd->process_mmaps()->AddVMRegion(region); | 283 pmd->process_mmaps()->AddVMRegion(region); |
| 277 } | 284 } |
| 278 if (!pmd->process_mmaps()->vm_regions().empty()) | 285 if (!pmd->process_mmaps()->vm_regions().empty()) |
| 279 pmd->set_has_process_mmaps(); | 286 pmd->set_has_process_mmaps(); |
| 280 return true; | 287 return true; |
| 281 } | 288 } |
| 282 #endif // defined(OS_WIN) | 289 #endif // defined(OS_WIN) |
| 283 | 290 |
| 284 #if defined(OS_MACOSX) | 291 #if defined(OS_MACOSX) |
| 285 | 292 |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 #endif | 749 #endif |
| 743 } | 750 } |
| 744 | 751 |
| 745 void ProcessMetricsMemoryDumpProvider::SuspendFastMemoryPolling() { | 752 void ProcessMetricsMemoryDumpProvider::SuspendFastMemoryPolling() { |
| 746 #if defined(OS_LINUX) || defined(OS_ANDROID) | 753 #if defined(OS_LINUX) || defined(OS_ANDROID) |
| 747 fast_polling_statm_fd_.reset(); | 754 fast_polling_statm_fd_.reset(); |
| 748 #endif | 755 #endif |
| 749 } | 756 } |
| 750 | 757 |
| 751 } // namespace tracing | 758 } // namespace tracing |
| OLD | NEW |