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 "build/build_config.h" | 25 #include "build/build_config.h" |
| 26 | 26 |
| 27 #if defined(OS_WIN) | |
| 28 #include "base/win/pe_image.h" | |
|
Primiano Tucci (use gerrit)
2017/05/09 17:46:12
there is another OS_WIN section down on line 51, c
etienneb
2017/05/09 18:12:54
Done.
| |
| 29 #endif // defined(OS_WIN) | |
| 30 | |
| 27 #if defined(OS_MACOSX) | 31 #if defined(OS_MACOSX) |
| 28 #include <libproc.h> | 32 #include <libproc.h> |
| 29 #include <mach/mach.h> | 33 #include <mach/mach.h> |
| 30 #include <mach/mach_vm.h> | 34 #include <mach/mach_vm.h> |
| 31 #include <mach/shared_region.h> | 35 #include <mach/shared_region.h> |
| 32 #include <sys/param.h> | 36 #include <sys/param.h> |
| 33 | 37 |
| 34 #include <mach-o/dyld_images.h> | 38 #include <mach-o/dyld_images.h> |
| 35 #include <mach-o/loader.h> | 39 #include <mach-o/loader.h> |
| 36 #include <mach/mach.h> | 40 #include <mach/mach.h> |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 266 | 270 |
| 267 MODULEINFO module_info; | 271 MODULEINFO module_info; |
| 268 if (!::GetModuleInformation(::GetCurrentProcess(), modules[i], | 272 if (!::GetModuleInformation(::GetCurrentProcess(), modules[i], |
| 269 &module_info, sizeof(MODULEINFO))) { | 273 &module_info, sizeof(MODULEINFO))) { |
| 270 continue; | 274 continue; |
| 271 } | 275 } |
| 272 base::trace_event::ProcessMemoryMaps::VMRegion region; | 276 base::trace_event::ProcessMemoryMaps::VMRegion region; |
| 273 region.size_in_bytes = module_info.SizeOfImage; | 277 region.size_in_bytes = module_info.SizeOfImage; |
| 274 region.mapped_file = base::SysWideToNativeMB(module_name); | 278 region.mapped_file = base::SysWideToNativeMB(module_name); |
| 275 region.start_address = reinterpret_cast<uint64_t>(module_info.lpBaseOfDll); | 279 region.start_address = reinterpret_cast<uint64_t>(module_info.lpBaseOfDll); |
| 280 | |
| 281 // The PE header field |TimeDateStamp| is required to build the PE code | |
| 282 // identifier which is used as a key to query symbols servers. | |
| 283 base::win::PEImage pe_image(module_info.lpBaseOfDll); | |
| 284 region.module_timestamp = pe_image.GetNTHeaders()->FileHeader.TimeDateStamp; | |
| 285 | |
| 276 pmd->process_mmaps()->AddVMRegion(region); | 286 pmd->process_mmaps()->AddVMRegion(region); |
| 277 } | 287 } |
| 278 if (!pmd->process_mmaps()->vm_regions().empty()) | 288 if (!pmd->process_mmaps()->vm_regions().empty()) |
| 279 pmd->set_has_process_mmaps(); | 289 pmd->set_has_process_mmaps(); |
| 280 return true; | 290 return true; |
| 281 } | 291 } |
| 282 #endif // defined(OS_WIN) | 292 #endif // defined(OS_WIN) |
| 283 | 293 |
| 284 #if defined(OS_MACOSX) | 294 #if defined(OS_MACOSX) |
| 285 | 295 |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 742 #endif | 752 #endif |
| 743 } | 753 } |
| 744 | 754 |
| 745 void ProcessMetricsMemoryDumpProvider::SuspendFastMemoryPolling() { | 755 void ProcessMetricsMemoryDumpProvider::SuspendFastMemoryPolling() { |
| 746 #if defined(OS_LINUX) || defined(OS_ANDROID) | 756 #if defined(OS_LINUX) || defined(OS_ANDROID) |
| 747 fast_polling_statm_fd_.reset(); | 757 fast_polling_statm_fd_.reset(); |
| 748 #endif | 758 #endif |
| 749 } | 759 } |
| 750 | 760 |
| 751 } // namespace tracing | 761 } // namespace tracing |
| OLD | NEW |