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/trace_event/process_memory_dump.h" | 10 #include "base/trace_event/process_memory_dump.h" |
10 #include "base/win/windows_version.h" | 11 #include "base/win/windows_version.h" |
11 | 12 |
12 namespace base { | 13 namespace base { |
13 namespace trace_event { | 14 namespace trace_event { |
14 | 15 |
15 namespace { | 16 namespace { |
16 | 17 |
17 // Report a heap dump to a process memory dump. The |heap_info| structure | 18 // Report a heap dump to a process memory dump. The |heap_info| structure |
18 // contains the information about this heap, and |dump_absolute_name| will be | 19 // contains the information about this heap, and |dump_absolute_name| will be |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // - The MSDN page for HeapLock says: "If the HeapLock function is called on | 53 // - The MSDN page for HeapLock says: "If the HeapLock function is called on |
53 // a heap created with the HEAP_NO_SERIALIZATION flag, the results are | 54 // a heap created with the HEAP_NO_SERIALIZATION flag, the results are |
54 // undefined.". This is a problem on Windows XP where some system DLLs are | 55 // undefined.". This is a problem on Windows XP where some system DLLs are |
55 // known for creating heaps with this particular flag. For this reason | 56 // known for creating heaps with this particular flag. For this reason |
56 // this function should be disabled on XP. | 57 // this function should be disabled on XP. |
57 // | 58 // |
58 // See https://crbug.com/487291 for more details about this. | 59 // See https://crbug.com/487291 for more details about this. |
59 if (base::win::GetVersion() < base::win::VERSION_VISTA) | 60 if (base::win::GetVersion() < base::win::VERSION_VISTA) |
60 return false; | 61 return false; |
61 | 62 |
| 63 // Disable this dump provider for the SyzyASan instrumented build |
| 64 // because they don't support the heap walking functions yet. |
| 65 #if defined(SYZYASAN) |
| 66 if (base::debug::IsBinaryInstrumented()) |
| 67 return false; |
| 68 #endif |
| 69 |
62 // Retrieves the number of heaps in the current process. | 70 // Retrieves the number of heaps in the current process. |
63 DWORD number_of_heaps = ::GetProcessHeaps(0, NULL); | 71 DWORD number_of_heaps = ::GetProcessHeaps(0, NULL); |
64 WinHeapInfo all_heap_info = {0}; | 72 WinHeapInfo all_heap_info = {0}; |
65 | 73 |
66 // Try to retrieve a handle to all the heaps owned by this process. Returns | 74 // Try to retrieve a handle to all the heaps owned by this process. Returns |
67 // false if the number of heaps has changed. | 75 // false if the number of heaps has changed. |
68 // | 76 // |
69 // This is inherently racy as is, but it's not something that we observe a lot | 77 // This is inherently racy as is, but it's not something that we observe a lot |
70 // in Chrome, the heaps tend to be created at startup only. | 78 // in Chrome, the heaps tend to be created at startup only. |
71 scoped_ptr<HANDLE[]> all_heaps(new HANDLE[number_of_heaps]); | 79 scoped_ptr<HANDLE[]> all_heaps(new HANDLE[number_of_heaps]); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 } else if ((heap_entry.wFlags & PROCESS_HEAP_REGION) != 0) { | 116 } else if ((heap_entry.wFlags & PROCESS_HEAP_REGION) != 0) { |
109 heap_info->committed_size += heap_entry.Region.dwCommittedSize; | 117 heap_info->committed_size += heap_entry.Region.dwCommittedSize; |
110 } | 118 } |
111 } | 119 } |
112 CHECK(::HeapUnlock(heap_info->heap_id) == TRUE); | 120 CHECK(::HeapUnlock(heap_info->heap_id) == TRUE); |
113 return true; | 121 return true; |
114 } | 122 } |
115 | 123 |
116 } // namespace trace_event | 124 } // namespace trace_event |
117 } // namespace base | 125 } // namespace base |
OLD | NEW |