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/winheap_dump_provider_win.h" | 5 #include "base/trace_event/winheap_dump_provider_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/debug/profiler.h" | 9 #include "base/debug/profiler.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "base/trace_event/process_memory_dump.h" | 11 #include "base/trace_event/process_memory_dump.h" |
12 #include "base/win/windows_version.h" | |
13 | 12 |
14 namespace base { | 13 namespace base { |
15 namespace trace_event { | 14 namespace trace_event { |
16 | 15 |
17 #define DUMP_ROOT_NAME "winheap" | 16 #define DUMP_ROOT_NAME "winheap" |
18 // static | 17 // static |
19 const char WinHeapDumpProvider::kAllocatedObjects[] = | 18 const char WinHeapDumpProvider::kAllocatedObjects[] = |
20 DUMP_ROOT_NAME "/allocated_objects"; | 19 DUMP_ROOT_NAME "/allocated_objects"; |
21 | 20 |
22 namespace { | 21 namespace { |
(...skipping 26 matching lines...) Expand all Loading... |
49 | 48 |
50 bool WinHeapDumpProvider::OnMemoryDump(const MemoryDumpArgs& args, | 49 bool WinHeapDumpProvider::OnMemoryDump(const MemoryDumpArgs& args, |
51 ProcessMemoryDump* pmd) { | 50 ProcessMemoryDump* pmd) { |
52 // This method might be flaky for 2 reasons: | 51 // This method might be flaky for 2 reasons: |
53 // - GetProcessHeaps is racy by design. It returns a snapshot of the | 52 // - GetProcessHeaps is racy by design. It returns a snapshot of the |
54 // available heaps, but there's no guarantee that that snapshot remains | 53 // available heaps, but there's no guarantee that that snapshot remains |
55 // valid. If a heap disappears between GetProcessHeaps() and HeapWalk() | 54 // valid. If a heap disappears between GetProcessHeaps() and HeapWalk() |
56 // then chaos should be assumed. This flakyness is acceptable for tracing. | 55 // then chaos should be assumed. This flakyness is acceptable for tracing. |
57 // - The MSDN page for HeapLock says: "If the HeapLock function is called on | 56 // - The MSDN page for HeapLock says: "If the HeapLock function is called on |
58 // a heap created with the HEAP_NO_SERIALIZATION flag, the results are | 57 // a heap created with the HEAP_NO_SERIALIZATION flag, the results are |
59 // undefined.". This is a problem on Windows XP where some system DLLs are | 58 // undefined." |
60 // known for creating heaps with this particular flag. For this reason | |
61 // this function should be disabled on XP. | |
62 // | |
63 // See https://crbug.com/487291 for more details about this. | |
64 if (base::win::GetVersion() < base::win::VERSION_VISTA) | |
65 return false; | |
66 | 59 |
67 // Disable this dump provider for the SyzyASan instrumented build | 60 // Disable this dump provider for the SyzyASan instrumented build |
68 // because they don't support the heap walking functions yet. | 61 // because they don't support the heap walking functions yet. |
69 #if defined(SYZYASAN) | 62 #if defined(SYZYASAN) |
70 if (base::debug::IsBinaryInstrumented()) | 63 if (base::debug::IsBinaryInstrumented()) |
71 return false; | 64 return false; |
72 #endif | 65 #endif |
73 | 66 |
74 // Retrieves the number of heaps in the current process. | 67 // Retrieves the number of heaps in the current process. |
75 DWORD number_of_heaps = ::GetProcessHeaps(0, NULL); | 68 DWORD number_of_heaps = ::GetProcessHeaps(0, NULL); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 } else if ((heap_entry.wFlags & PROCESS_HEAP_REGION) != 0) { | 113 } else if ((heap_entry.wFlags & PROCESS_HEAP_REGION) != 0) { |
121 heap_info->committed_size += heap_entry.Region.dwCommittedSize; | 114 heap_info->committed_size += heap_entry.Region.dwCommittedSize; |
122 } | 115 } |
123 } | 116 } |
124 CHECK(::HeapUnlock(heap_info->heap_id) == TRUE); | 117 CHECK(::HeapUnlock(heap_info->heap_id) == TRUE); |
125 return true; | 118 return true; |
126 } | 119 } |
127 | 120 |
128 } // namespace trace_event | 121 } // namespace trace_event |
129 } // namespace base | 122 } // namespace base |
OLD | NEW |