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 "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> |
| 11 | 11 |
| 12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 13 #include "base/files/scoped_file.h" | 13 #include "base/files/scoped_file.h" |
| 14 #include "base/format_macros.h" | 14 #include "base/format_macros.h" |
| 15 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
| 18 #include "base/process/process_metrics.h" | 18 #include "base/process/process_metrics.h" |
| 19 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 20 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
| 21 #include "base/trace_event/memory_dump_manager.h" | 21 #include "base/trace_event/memory_dump_manager.h" |
| 22 #include "base/trace_event/process_memory_dump.h" | 22 #include "base/trace_event/process_memory_dump.h" |
| 23 #include "base/trace_event/process_memory_maps.h" | 23 #include "base/trace_event/process_memory_maps.h" |
| 24 #include "base/trace_event/process_memory_totals.h" | 24 #include "base/trace_event/process_memory_totals.h" |
| 25 #include "base/win/pe_image.h" | |
|
Primiano Tucci (use gerrit)
2017/05/09 16:34:01
this needs to be under #if defined(OS_WIN) right?
etienneb
2017/05/09 17:39:31
right.
| |
| 25 #include "build/build_config.h" | 26 #include "build/build_config.h" |
| 26 | 27 |
| 27 #if defined(OS_MACOSX) | 28 #if defined(OS_MACOSX) |
| 28 #include <libproc.h> | 29 #include <libproc.h> |
| 29 #include <mach/mach.h> | 30 #include <mach/mach.h> |
| 30 #include <mach/mach_vm.h> | 31 #include <mach/mach_vm.h> |
| 31 #include <mach/shared_region.h> | 32 #include <mach/shared_region.h> |
| 32 #include <sys/param.h> | 33 #include <sys/param.h> |
| 33 | 34 |
| 34 #include <mach-o/dyld_images.h> | 35 #include <mach-o/dyld_images.h> |
| (...skipping 231 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); | |
|
Primiano Tucci (use gerrit)
2017/05/09 16:34:01
how long does this take? is it fine to keep doing
etienneb
2017/05/09 17:39:31
This is a trivial cost.
Roughly, the PE image is a
| |
| 281 region.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 |