OLD | NEW |
1 // Copyright (c) 2010, Google Inc. | 1 // Copyright (c) 2010, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 13 matching lines...) Expand all Loading... |
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | 29 |
30 #include <windows.h> | 30 #include <windows.h> |
31 #include <objbase.h> | 31 #include <objbase.h> |
32 #include <dbghelp.h> | 32 #include <dbghelp.h> |
33 | 33 |
| 34 #include "../crash_generation/minidump_generator.h" |
| 35 #include "dump_analysis.h" // NOLINT |
| 36 |
34 #include "gtest/gtest.h" | 37 #include "gtest/gtest.h" |
35 | 38 |
36 namespace { | 39 namespace { |
37 | 40 |
38 // Convenience to get to the PEB pointer in a TEB. | |
39 struct FakeTEB { | |
40 char dummy[0x30]; | |
41 void* peb; | |
42 }; | |
43 | |
44 // Minidump with stacks, PEB, TEB, and unloaded module list. | 41 // Minidump with stacks, PEB, TEB, and unloaded module list. |
45 const MINIDUMP_TYPE kSmallDumpType = static_cast<MINIDUMP_TYPE>( | 42 const MINIDUMP_TYPE kSmallDumpType = static_cast<MINIDUMP_TYPE>( |
46 MiniDumpWithProcessThreadData | // Get PEB and TEB. | 43 MiniDumpWithProcessThreadData | // Get PEB and TEB. |
47 MiniDumpWithUnloadedModules); // Get unloaded modules when available. | 44 MiniDumpWithUnloadedModules); // Get unloaded modules when available. |
48 | 45 |
49 // Minidump with all of the above, plus memory referenced from stack. | 46 // Minidump with all of the above, plus memory referenced from stack. |
50 const MINIDUMP_TYPE kLargerDumpType = static_cast<MINIDUMP_TYPE>( | 47 const MINIDUMP_TYPE kLargerDumpType = static_cast<MINIDUMP_TYPE>( |
51 MiniDumpWithProcessThreadData | // Get PEB and TEB. | 48 MiniDumpWithProcessThreadData | // Get PEB and TEB. |
52 MiniDumpWithUnloadedModules | // Get unloaded modules when available. | 49 MiniDumpWithUnloadedModules | // Get unloaded modules when available. |
53 MiniDumpWithIndirectlyReferencedMemory); // Get memory referenced by stack. | 50 MiniDumpWithIndirectlyReferencedMemory); // Get memory referenced by stack. |
54 | 51 |
55 // Large dump with all process memory. | 52 // Large dump with all process memory. |
56 const MINIDUMP_TYPE kFullDumpType = static_cast<MINIDUMP_TYPE>( | 53 const MINIDUMP_TYPE kFullDumpType = static_cast<MINIDUMP_TYPE>( |
57 MiniDumpWithFullMemory | // Full memory from process. | 54 MiniDumpWithFullMemory | // Full memory from process. |
58 MiniDumpWithProcessThreadData | // Get PEB and TEB. | 55 MiniDumpWithProcessThreadData | // Get PEB and TEB. |
59 MiniDumpWithHandleData | // Get all handle information. | 56 MiniDumpWithHandleData | // Get all handle information. |
60 MiniDumpWithUnloadedModules); // Get unloaded modules when available. | 57 MiniDumpWithUnloadedModules); // Get unloaded modules when available. |
61 | 58 |
62 class MinidumpTest: public testing::Test { | 59 class MinidumpTest: public testing::Test { |
63 public: | 60 public: |
64 MinidumpTest() : dump_file_view_(NULL), dump_file_handle_(NULL), | 61 MinidumpTest() { |
65 dump_file_mapping_(NULL) { | 62 wchar_t temp_dir_path[ MAX_PATH ] = {0}; |
| 63 ::GetTempPath(MAX_PATH, temp_dir_path); |
| 64 dump_path_ = temp_dir_path; |
66 } | 65 } |
67 | 66 |
68 virtual void SetUp() { | 67 virtual void SetUp() { |
69 // Make sure URLMon isn't loaded into our process. | 68 // Make sure URLMon isn't loaded into our process. |
70 ASSERT_EQ(NULL, ::GetModuleHandle(L"urlmon.dll")); | 69 ASSERT_EQ(NULL, ::GetModuleHandle(L"urlmon.dll")); |
71 | 70 |
72 // Then load and unload it to ensure we have something to | 71 // Then load and unload it to ensure we have something to |
73 // stock the unloaded module list with. | 72 // stock the unloaded module list with. |
74 HMODULE urlmon = ::LoadLibrary(L"urlmon.dll"); | 73 HMODULE urlmon = ::LoadLibrary(L"urlmon.dll"); |
75 ASSERT_TRUE(urlmon != NULL); | 74 ASSERT_TRUE(urlmon != NULL); |
76 ASSERT_TRUE(::FreeLibrary(urlmon)); | 75 ASSERT_TRUE(::FreeLibrary(urlmon)); |
77 | |
78 wchar_t temp_dir_path[ MAX_PATH ] = {0}; | |
79 wchar_t dump_file_name[ MAX_PATH ] = {0}; | |
80 ::GetTempPath(MAX_PATH, temp_dir_path); | |
81 ::GetTempFileName(temp_dir_path, L"tst", 0, dump_file_name); | |
82 dump_file_ = dump_file_name; | |
83 dump_file_handle_ = ::CreateFile(dump_file_.c_str(), | |
84 GENERIC_WRITE | GENERIC_READ, | |
85 0, | |
86 NULL, | |
87 OPEN_EXISTING, | |
88 0, | |
89 NULL); | |
90 ASSERT_TRUE(dump_file_handle_ != NULL); | |
91 } | 76 } |
92 | 77 |
93 virtual void TearDown() { | 78 virtual void TearDown() { |
94 if (dump_file_view_ != NULL) { | 79 if (!dump_file_.empty()) { |
95 EXPECT_TRUE(::UnmapViewOfFile(dump_file_view_)); | 80 ::DeleteFile(dump_file_.c_str()); |
96 ::CloseHandle(dump_file_mapping_); | 81 dump_file_ = L""; |
97 dump_file_mapping_ = NULL; | |
98 } | 82 } |
99 | 83 if (!full_dump_file_.empty()) { |
100 ::CloseHandle(dump_file_handle_); | 84 ::DeleteFile(full_dump_file_.c_str()); |
101 dump_file_handle_ = NULL; | 85 full_dump_file_ = L""; |
102 | |
103 EXPECT_TRUE(::DeleteFile(dump_file_.c_str())); | |
104 } | |
105 | |
106 void EnsureDumpMapped() { | |
107 ASSERT_TRUE(dump_file_handle_ != NULL); | |
108 if (dump_file_view_ == NULL) { | |
109 ASSERT_TRUE(dump_file_mapping_ == NULL); | |
110 | |
111 dump_file_mapping_ = ::CreateFileMapping(dump_file_handle_, | |
112 NULL, | |
113 PAGE_READONLY, | |
114 0, | |
115 0, | |
116 NULL); | |
117 ASSERT_TRUE(dump_file_mapping_ != NULL); | |
118 | |
119 dump_file_view_ = ::MapViewOfFile(dump_file_mapping_, | |
120 FILE_MAP_READ, | |
121 0, | |
122 0, | |
123 0); | |
124 ASSERT_TRUE(dump_file_view_ != NULL); | |
125 } | 86 } |
126 } | 87 } |
127 | 88 |
128 bool WriteDump(ULONG flags) { | 89 bool WriteDump(ULONG flags) { |
| 90 using google_breakpad::MinidumpGenerator; |
| 91 |
129 // Fake exception is access violation on write to this. | 92 // Fake exception is access violation on write to this. |
130 EXCEPTION_RECORD ex_record = { | 93 EXCEPTION_RECORD ex_record = { |
131 STATUS_ACCESS_VIOLATION, // ExceptionCode | 94 STATUS_ACCESS_VIOLATION, // ExceptionCode |
132 0, // ExceptionFlags | 95 0, // ExceptionFlags |
133 NULL, // ExceptionRecord; | 96 NULL, // ExceptionRecord; |
134 reinterpret_cast<void*>(0xCAFEBABE), // ExceptionAddress; | 97 reinterpret_cast<void*>(0xCAFEBABE), // ExceptionAddress; |
135 2, // NumberParameters; | 98 2, // NumberParameters; |
136 { EXCEPTION_WRITE_FAULT, reinterpret_cast<ULONG_PTR>(this) } | 99 { EXCEPTION_WRITE_FAULT, reinterpret_cast<ULONG_PTR>(this) } |
137 }; | 100 }; |
138 CONTEXT ctx_record = {}; | 101 CONTEXT ctx_record = {}; |
139 EXCEPTION_POINTERS ex_ptrs = { | 102 EXCEPTION_POINTERS ex_ptrs = { |
140 &ex_record, | 103 &ex_record, |
141 &ctx_record, | 104 &ctx_record, |
142 }; | 105 }; |
143 MINIDUMP_EXCEPTION_INFORMATION ex_info = { | |
144 ::GetCurrentThreadId(), | |
145 &ex_ptrs, | |
146 FALSE, | |
147 }; | |
148 | 106 |
149 // Capture our register context. | 107 MinidumpGenerator generator(dump_path_); |
150 ::RtlCaptureContext(&ctx_record); | |
151 | 108 |
152 // And write a dump | 109 // And write a dump |
153 BOOL result = ::MiniDumpWriteDump(::GetCurrentProcess(), | 110 bool result = generator.WriteMinidump(::GetCurrentProcess(), |
154 ::GetCurrentProcessId(), | 111 ::GetCurrentProcessId(), |
155 dump_file_handle_, | 112 ::GetCurrentThreadId(), |
156 static_cast<MINIDUMP_TYPE>(flags), | 113 ::GetCurrentThreadId(), |
157 &ex_info, | 114 &ex_ptrs, |
158 NULL, | 115 NULL, |
159 NULL); | 116 static_cast<MINIDUMP_TYPE>(flags), |
| 117 TRUE, |
| 118 &dump_file_, |
| 119 &full_dump_file_); |
160 return result == TRUE; | 120 return result == TRUE; |
161 } | 121 } |
162 | 122 |
163 bool DumpHasStream(ULONG stream_number) { | 123 protected: |
164 EnsureDumpMapped(); | 124 std::wstring dump_file_; |
| 125 std::wstring full_dump_file_; |
165 | 126 |
166 MINIDUMP_DIRECTORY* directory = NULL; | 127 std::wstring dump_path_; |
167 void* stream = NULL; | |
168 ULONG stream_size = 0; | |
169 BOOL ret = ::MiniDumpReadDumpStream(dump_file_view_, | |
170 stream_number, | |
171 &directory, | |
172 &stream, | |
173 &stream_size); | |
174 | |
175 return ret != FALSE && stream != NULL && stream_size > 0; | |
176 } | |
177 | |
178 template <class StreamType> | |
179 size_t GetStream(ULONG stream_number, StreamType** stream) { | |
180 EnsureDumpMapped(); | |
181 MINIDUMP_DIRECTORY* directory = NULL; | |
182 ULONG memory_list_size = 0; | |
183 BOOL ret = ::MiniDumpReadDumpStream(dump_file_view_, | |
184 stream_number, | |
185 &directory, | |
186 reinterpret_cast<void**>(stream), | |
187 &memory_list_size); | |
188 | |
189 return ret ? memory_list_size : 0; | |
190 } | |
191 | |
192 bool DumpHasTebs() { | |
193 MINIDUMP_THREAD_LIST* thread_list = NULL; | |
194 size_t thread_list_size = GetStream(ThreadListStream, &thread_list); | |
195 | |
196 if (thread_list_size > 0 && thread_list != NULL) { | |
197 for (ULONG i = 0; i < thread_list->NumberOfThreads; ++i) { | |
198 if (!DumpHasMemory(thread_list->Threads[i].Teb)) | |
199 return false; | |
200 } | |
201 | |
202 return true; | |
203 } | |
204 | |
205 // No thread list, no TEB info. | |
206 return false; | |
207 } | |
208 | |
209 bool DumpHasPeb() { | |
210 MINIDUMP_THREAD_LIST* thread_list = NULL; | |
211 size_t thread_list_size = GetStream(ThreadListStream, &thread_list); | |
212 | |
213 if (thread_list_size > 0 && thread_list != NULL && | |
214 thread_list->NumberOfThreads > 0) { | |
215 FakeTEB* teb = NULL; | |
216 if (!DumpHasMemory(thread_list->Threads[0].Teb, &teb)) | |
217 return false; | |
218 | |
219 return DumpHasMemory(teb->peb); | |
220 } | |
221 | |
222 return false; | |
223 } | |
224 | |
225 bool DumpHasMemory(ULONG64 address) { | |
226 return DumpHasMemory<BYTE>(address, NULL); | |
227 } | |
228 | |
229 bool DumpHasMemory(const void* address) { | |
230 return DumpHasMemory<BYTE>(address, NULL); | |
231 } | |
232 | |
233 template <class StructureType> | |
234 bool DumpHasMemory(ULONG64 address, StructureType** structure = NULL) { | |
235 // We can't cope with 64 bit addresses for now. | |
236 if (address > 0xFFFFFFFFUL) | |
237 return false; | |
238 | |
239 return DumpHasMemory(reinterpret_cast<void*>(address), structure); | |
240 } | |
241 | |
242 template <class StructureType> | |
243 bool DumpHasMemory(const void* addr_in, StructureType** structure = NULL) { | |
244 uintptr_t address = reinterpret_cast<uintptr_t>(addr_in); | |
245 MINIDUMP_MEMORY_LIST* memory_list = NULL; | |
246 size_t memory_list_size = GetStream(MemoryListStream, &memory_list); | |
247 if (memory_list_size > 0 && memory_list != NULL) { | |
248 for (ULONG i = 0; i < memory_list->NumberOfMemoryRanges; ++i) { | |
249 MINIDUMP_MEMORY_DESCRIPTOR& descr = memory_list->MemoryRanges[i]; | |
250 const uintptr_t range_start = | |
251 static_cast<uintptr_t>(descr.StartOfMemoryRange); | |
252 uintptr_t range_end = range_start + descr.Memory.DataSize; | |
253 | |
254 if (address >= range_start && | |
255 address + sizeof(StructureType) < range_end) { | |
256 // The start address falls in the range, and the end address is | |
257 // in bounds, return a pointer to the structure if requested. | |
258 if (structure != NULL) | |
259 *structure = reinterpret_cast<StructureType*>( | |
260 RVA_TO_ADDR(dump_file_view_, descr.Memory.Rva)); | |
261 | |
262 return true; | |
263 } | |
264 } | |
265 } | |
266 | |
267 // We didn't find the range in a MINIDUMP_MEMORY_LIST, so maybe this | |
268 // is a full dump using MINIDUMP_MEMORY64_LIST with all the memory at the | |
269 // end of the dump file. | |
270 MINIDUMP_MEMORY64_LIST* memory64_list = NULL; | |
271 memory_list_size = GetStream(Memory64ListStream, &memory64_list); | |
272 if (memory_list_size > 0 && memory64_list != NULL) { | |
273 // Keep track of where the current descriptor maps to. | |
274 RVA64 curr_rva = memory64_list->BaseRva; | |
275 for (ULONG i = 0; i < memory64_list->NumberOfMemoryRanges; ++i) { | |
276 MINIDUMP_MEMORY_DESCRIPTOR64& descr = memory64_list->MemoryRanges[i]; | |
277 uintptr_t range_start = | |
278 static_cast<uintptr_t>(descr.StartOfMemoryRange); | |
279 uintptr_t range_end = range_start + static_cast<size_t>(descr.DataSize); | |
280 | |
281 if (address >= range_start && | |
282 address + sizeof(StructureType) < range_end) { | |
283 // The start address falls in the range, and the end address is | |
284 // in bounds, return a pointer to the structure if requested. | |
285 if (structure != NULL) | |
286 *structure = reinterpret_cast<StructureType*>( | |
287 RVA_TO_ADDR(dump_file_view_, curr_rva)); | |
288 | |
289 return true; | |
290 } | |
291 | |
292 // Advance the current RVA. | |
293 curr_rva += descr.DataSize; | |
294 } | |
295 } | |
296 | |
297 | |
298 | |
299 return false; | |
300 } | |
301 | |
302 protected: | |
303 HANDLE dump_file_handle_; | |
304 HANDLE dump_file_mapping_; | |
305 void* dump_file_view_; | |
306 | |
307 std::wstring dump_file_; | |
308 }; | 128 }; |
309 | 129 |
310 // We need to be able to get file information from Windows | 130 // We need to be able to get file information from Windows |
311 bool HasFileInfo(const std::wstring& file_path) { | 131 bool HasFileInfo(const std::wstring& file_path) { |
312 DWORD dummy; | 132 DWORD dummy; |
313 const wchar_t* path = file_path.c_str(); | 133 const wchar_t* path = file_path.c_str(); |
314 DWORD length = ::GetFileVersionInfoSize(path, &dummy); | 134 DWORD length = ::GetFileVersionInfoSize(path, &dummy); |
315 if (length == 0) | 135 if (length == 0) |
316 return NULL; | 136 return NULL; |
317 | 137 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 dbg_help_file, | 171 dbg_help_file, |
352 sizeof(dbg_help_file) / | 172 sizeof(dbg_help_file) / |
353 sizeof(*dbg_help_file))); | 173 sizeof(*dbg_help_file))); |
354 ASSERT_TRUE(HasFileInfo(std::wstring(dbg_help_file)) != NULL); | 174 ASSERT_TRUE(HasFileInfo(std::wstring(dbg_help_file)) != NULL); |
355 | 175 |
356 // LOG(INFO) << "DbgHelp.dll version: " << file_info->file_version(); | 176 // LOG(INFO) << "DbgHelp.dll version: " << file_info->file_version(); |
357 } | 177 } |
358 | 178 |
359 TEST_F(MinidumpTest, Normal) { | 179 TEST_F(MinidumpTest, Normal) { |
360 EXPECT_TRUE(WriteDump(MiniDumpNormal)); | 180 EXPECT_TRUE(WriteDump(MiniDumpNormal)); |
| 181 DumpAnalysis mini(dump_file_); |
361 | 182 |
362 // We expect threads, modules and some memory. | 183 // We expect threads, modules and some memory. |
363 EXPECT_TRUE(DumpHasStream(ThreadListStream)); | 184 EXPECT_TRUE(mini.HasStream(ThreadListStream)); |
364 EXPECT_TRUE(DumpHasStream(ModuleListStream)); | 185 EXPECT_TRUE(mini.HasStream(ModuleListStream)); |
365 EXPECT_TRUE(DumpHasStream(MemoryListStream)); | 186 EXPECT_TRUE(mini.HasStream(MemoryListStream)); |
366 EXPECT_TRUE(DumpHasStream(ExceptionStream)); | 187 EXPECT_TRUE(mini.HasStream(ExceptionStream)); |
367 EXPECT_TRUE(DumpHasStream(SystemInfoStream)); | 188 EXPECT_TRUE(mini.HasStream(SystemInfoStream)); |
368 EXPECT_TRUE(DumpHasStream(MiscInfoStream)); | 189 EXPECT_TRUE(mini.HasStream(MiscInfoStream)); |
369 | 190 |
370 EXPECT_FALSE(DumpHasStream(ThreadExListStream)); | 191 EXPECT_FALSE(mini.HasStream(ThreadExListStream)); |
371 EXPECT_FALSE(DumpHasStream(Memory64ListStream)); | 192 EXPECT_FALSE(mini.HasStream(Memory64ListStream)); |
372 EXPECT_FALSE(DumpHasStream(CommentStreamA)); | 193 EXPECT_FALSE(mini.HasStream(CommentStreamA)); |
373 EXPECT_FALSE(DumpHasStream(CommentStreamW)); | 194 EXPECT_FALSE(mini.HasStream(CommentStreamW)); |
374 EXPECT_FALSE(DumpHasStream(HandleDataStream)); | 195 EXPECT_FALSE(mini.HasStream(HandleDataStream)); |
375 EXPECT_FALSE(DumpHasStream(FunctionTableStream)); | 196 EXPECT_FALSE(mini.HasStream(FunctionTableStream)); |
376 EXPECT_FALSE(DumpHasStream(UnloadedModuleListStream)); | 197 EXPECT_FALSE(mini.HasStream(UnloadedModuleListStream)); |
377 EXPECT_FALSE(DumpHasStream(MemoryInfoListStream)); | 198 EXPECT_FALSE(mini.HasStream(MemoryInfoListStream)); |
378 EXPECT_FALSE(DumpHasStream(ThreadInfoListStream)); | 199 EXPECT_FALSE(mini.HasStream(ThreadInfoListStream)); |
379 EXPECT_FALSE(DumpHasStream(HandleOperationListStream)); | 200 EXPECT_FALSE(mini.HasStream(HandleOperationListStream)); |
380 EXPECT_FALSE(DumpHasStream(TokenStream)); | 201 EXPECT_FALSE(mini.HasStream(TokenStream)); |
381 | 202 |
382 // We expect no PEB nor TEBs in this dump. | 203 // We expect no PEB nor TEBs in this dump. |
383 EXPECT_FALSE(DumpHasTebs()); | 204 EXPECT_FALSE(mini.HasTebs()); |
384 EXPECT_FALSE(DumpHasPeb()); | 205 EXPECT_FALSE(mini.HasPeb()); |
385 | 206 |
386 // We expect no off-stack memory in this dump. | 207 // We expect no off-stack memory in this dump. |
387 EXPECT_FALSE(DumpHasMemory(this)); | 208 EXPECT_FALSE(mini.HasMemory(this)); |
388 } | 209 } |
389 | 210 |
390 TEST_F(MinidumpTest, SmallDump) { | 211 TEST_F(MinidumpTest, SmallDump) { |
391 ASSERT_TRUE(WriteDump(kSmallDumpType)); | 212 ASSERT_TRUE(WriteDump(kSmallDumpType)); |
| 213 DumpAnalysis mini(dump_file_); |
392 | 214 |
393 EXPECT_TRUE(DumpHasStream(ThreadListStream)); | 215 EXPECT_TRUE(mini.HasStream(ThreadListStream)); |
394 EXPECT_TRUE(DumpHasStream(ModuleListStream)); | 216 EXPECT_TRUE(mini.HasStream(ModuleListStream)); |
395 EXPECT_TRUE(DumpHasStream(MemoryListStream)); | 217 EXPECT_TRUE(mini.HasStream(MemoryListStream)); |
396 EXPECT_TRUE(DumpHasStream(ExceptionStream)); | 218 EXPECT_TRUE(mini.HasStream(ExceptionStream)); |
397 EXPECT_TRUE(DumpHasStream(SystemInfoStream)); | 219 EXPECT_TRUE(mini.HasStream(SystemInfoStream)); |
398 EXPECT_TRUE(DumpHasStream(UnloadedModuleListStream)); | 220 EXPECT_TRUE(mini.HasStream(UnloadedModuleListStream)); |
399 EXPECT_TRUE(DumpHasStream(MiscInfoStream)); | 221 EXPECT_TRUE(mini.HasStream(MiscInfoStream)); |
400 | 222 |
401 // We expect PEB and TEBs in this dump. | 223 // We expect PEB and TEBs in this dump. |
402 EXPECT_TRUE(DumpHasTebs()); | 224 EXPECT_TRUE(mini.HasTebs()); |
403 EXPECT_TRUE(DumpHasPeb()); | 225 EXPECT_TRUE(mini.HasPeb()); |
404 | 226 |
405 EXPECT_FALSE(DumpHasStream(ThreadExListStream)); | 227 EXPECT_FALSE(mini.HasStream(ThreadExListStream)); |
406 EXPECT_FALSE(DumpHasStream(Memory64ListStream)); | 228 EXPECT_FALSE(mini.HasStream(Memory64ListStream)); |
407 EXPECT_FALSE(DumpHasStream(CommentStreamA)); | 229 EXPECT_FALSE(mini.HasStream(CommentStreamA)); |
408 EXPECT_FALSE(DumpHasStream(CommentStreamW)); | 230 EXPECT_FALSE(mini.HasStream(CommentStreamW)); |
409 EXPECT_FALSE(DumpHasStream(HandleDataStream)); | 231 EXPECT_FALSE(mini.HasStream(HandleDataStream)); |
410 EXPECT_FALSE(DumpHasStream(FunctionTableStream)); | 232 EXPECT_FALSE(mini.HasStream(FunctionTableStream)); |
411 EXPECT_FALSE(DumpHasStream(MemoryInfoListStream)); | 233 EXPECT_FALSE(mini.HasStream(MemoryInfoListStream)); |
412 EXPECT_FALSE(DumpHasStream(ThreadInfoListStream)); | 234 EXPECT_FALSE(mini.HasStream(ThreadInfoListStream)); |
413 EXPECT_FALSE(DumpHasStream(HandleOperationListStream)); | 235 EXPECT_FALSE(mini.HasStream(HandleOperationListStream)); |
414 EXPECT_FALSE(DumpHasStream(TokenStream)); | 236 EXPECT_FALSE(mini.HasStream(TokenStream)); |
415 | 237 |
416 // We expect no off-stack memory in this dump. | 238 // We expect no off-stack memory in this dump. |
417 EXPECT_FALSE(DumpHasMemory(this)); | 239 EXPECT_FALSE(mini.HasMemory(this)); |
418 } | 240 } |
419 | 241 |
420 TEST_F(MinidumpTest, LargerDump) { | 242 TEST_F(MinidumpTest, LargerDump) { |
421 ASSERT_TRUE(WriteDump(kLargerDumpType)); | 243 ASSERT_TRUE(WriteDump(kLargerDumpType)); |
| 244 DumpAnalysis mini(dump_file_); |
422 | 245 |
423 // The dump should have all of these streams. | 246 // The dump should have all of these streams. |
424 EXPECT_TRUE(DumpHasStream(ThreadListStream)); | 247 EXPECT_TRUE(mini.HasStream(ThreadListStream)); |
425 EXPECT_TRUE(DumpHasStream(ModuleListStream)); | 248 EXPECT_TRUE(mini.HasStream(ModuleListStream)); |
426 EXPECT_TRUE(DumpHasStream(MemoryListStream)); | 249 EXPECT_TRUE(mini.HasStream(MemoryListStream)); |
427 EXPECT_TRUE(DumpHasStream(ExceptionStream)); | 250 EXPECT_TRUE(mini.HasStream(ExceptionStream)); |
428 EXPECT_TRUE(DumpHasStream(SystemInfoStream)); | 251 EXPECT_TRUE(mini.HasStream(SystemInfoStream)); |
429 EXPECT_TRUE(DumpHasStream(UnloadedModuleListStream)); | 252 EXPECT_TRUE(mini.HasStream(UnloadedModuleListStream)); |
430 EXPECT_TRUE(DumpHasStream(MiscInfoStream)); | 253 EXPECT_TRUE(mini.HasStream(MiscInfoStream)); |
431 | 254 |
432 // We expect memory referenced by stack in this dump. | 255 // We expect memory referenced by stack in this dump. |
433 EXPECT_TRUE(DumpHasMemory(this)); | 256 EXPECT_TRUE(mini.HasMemory(this)); |
434 | 257 |
435 // We expect PEB and TEBs in this dump. | 258 // We expect PEB and TEBs in this dump. |
436 EXPECT_TRUE(DumpHasTebs()); | 259 EXPECT_TRUE(mini.HasTebs()); |
437 EXPECT_TRUE(DumpHasPeb()); | 260 EXPECT_TRUE(mini.HasPeb()); |
438 | 261 |
439 EXPECT_FALSE(DumpHasStream(ThreadExListStream)); | 262 EXPECT_FALSE(mini.HasStream(ThreadExListStream)); |
440 EXPECT_FALSE(DumpHasStream(Memory64ListStream)); | 263 EXPECT_FALSE(mini.HasStream(Memory64ListStream)); |
441 EXPECT_FALSE(DumpHasStream(CommentStreamA)); | 264 EXPECT_FALSE(mini.HasStream(CommentStreamA)); |
442 EXPECT_FALSE(DumpHasStream(CommentStreamW)); | 265 EXPECT_FALSE(mini.HasStream(CommentStreamW)); |
443 EXPECT_FALSE(DumpHasStream(HandleDataStream)); | 266 EXPECT_FALSE(mini.HasStream(HandleDataStream)); |
444 EXPECT_FALSE(DumpHasStream(FunctionTableStream)); | 267 EXPECT_FALSE(mini.HasStream(FunctionTableStream)); |
445 EXPECT_FALSE(DumpHasStream(MemoryInfoListStream)); | 268 EXPECT_FALSE(mini.HasStream(MemoryInfoListStream)); |
446 EXPECT_FALSE(DumpHasStream(ThreadInfoListStream)); | 269 EXPECT_FALSE(mini.HasStream(ThreadInfoListStream)); |
447 EXPECT_FALSE(DumpHasStream(HandleOperationListStream)); | 270 EXPECT_FALSE(mini.HasStream(HandleOperationListStream)); |
448 EXPECT_FALSE(DumpHasStream(TokenStream)); | 271 EXPECT_FALSE(mini.HasStream(TokenStream)); |
449 } | 272 } |
450 | 273 |
451 TEST_F(MinidumpTest, FullDump) { | 274 TEST_F(MinidumpTest, FullDump) { |
452 ASSERT_TRUE(WriteDump(kFullDumpType)); | 275 ASSERT_TRUE(WriteDump(kFullDumpType)); |
| 276 ASSERT_TRUE(dump_file_ != L""); |
| 277 ASSERT_TRUE(full_dump_file_ != L""); |
| 278 DumpAnalysis mini(dump_file_); |
| 279 DumpAnalysis full(full_dump_file_); |
| 280 |
| 281 // Either dumps can contain part of the information. |
453 | 282 |
454 // The dump should have all of these streams. | 283 // The dump should have all of these streams. |
455 EXPECT_TRUE(DumpHasStream(ThreadListStream)); | 284 EXPECT_TRUE(mini.HasStream(ThreadListStream)); |
456 EXPECT_TRUE(DumpHasStream(ModuleListStream)); | 285 EXPECT_TRUE(full.HasStream(ThreadListStream)); |
457 EXPECT_TRUE(DumpHasStream(Memory64ListStream)); | 286 EXPECT_TRUE(mini.HasStream(ModuleListStream)); |
458 EXPECT_TRUE(DumpHasStream(ExceptionStream)); | 287 EXPECT_TRUE(full.HasStream(ModuleListStream)); |
459 EXPECT_TRUE(DumpHasStream(SystemInfoStream)); | 288 EXPECT_TRUE(mini.HasStream(ExceptionStream)); |
460 EXPECT_TRUE(DumpHasStream(UnloadedModuleListStream)); | 289 EXPECT_TRUE(full.HasStream(ExceptionStream)); |
461 EXPECT_TRUE(DumpHasStream(MiscInfoStream)); | 290 EXPECT_TRUE(mini.HasStream(SystemInfoStream)); |
462 EXPECT_TRUE(DumpHasStream(HandleDataStream)); | 291 EXPECT_TRUE(full.HasStream(SystemInfoStream)); |
| 292 EXPECT_TRUE(mini.HasStream(UnloadedModuleListStream)); |
| 293 EXPECT_TRUE(full.HasStream(UnloadedModuleListStream)); |
| 294 EXPECT_TRUE(mini.HasStream(MiscInfoStream)); |
| 295 EXPECT_TRUE(full.HasStream(MiscInfoStream)); |
| 296 EXPECT_TRUE(mini.HasStream(HandleDataStream)); |
| 297 EXPECT_TRUE(full.HasStream(HandleDataStream)); |
463 | 298 |
464 // We expect memory referenced by stack in this dump. | 299 // We expect memory referenced by stack in this dump. |
465 EXPECT_TRUE(DumpHasMemory(this)); | 300 EXPECT_FALSE(mini.HasMemory(this)); |
| 301 EXPECT_TRUE(full.HasMemory(this)); |
466 | 302 |
467 // We expect PEB and TEBs in this dump. | 303 // We expect PEB and TEBs in this dump. |
468 EXPECT_TRUE(DumpHasTebs()); | 304 EXPECT_TRUE(mini.HasTebs() || full.HasTebs()); |
469 EXPECT_TRUE(DumpHasPeb()); | 305 EXPECT_TRUE(mini.HasPeb() || full.HasPeb()); |
470 | 306 |
471 EXPECT_FALSE(DumpHasStream(ThreadExListStream)); | 307 EXPECT_TRUE(mini.HasStream(MemoryListStream)); |
472 EXPECT_FALSE(DumpHasStream(MemoryListStream)); | 308 EXPECT_TRUE(full.HasStream(Memory64ListStream)); |
473 EXPECT_FALSE(DumpHasStream(CommentStreamA)); | 309 EXPECT_FALSE(mini.HasStream(Memory64ListStream)); |
474 EXPECT_FALSE(DumpHasStream(CommentStreamW)); | 310 EXPECT_FALSE(full.HasStream(MemoryListStream)); |
475 EXPECT_FALSE(DumpHasStream(FunctionTableStream)); | 311 |
476 EXPECT_FALSE(DumpHasStream(MemoryInfoListStream)); | 312 // This is the only place we don't use OR because we want both not |
477 EXPECT_FALSE(DumpHasStream(ThreadInfoListStream)); | 313 // to have the streams. |
478 EXPECT_FALSE(DumpHasStream(HandleOperationListStream)); | 314 EXPECT_FALSE(mini.HasStream(ThreadExListStream)); |
479 EXPECT_FALSE(DumpHasStream(TokenStream)); | 315 EXPECT_FALSE(full.HasStream(ThreadExListStream)); |
| 316 EXPECT_FALSE(mini.HasStream(CommentStreamA)); |
| 317 EXPECT_FALSE(full.HasStream(CommentStreamA)); |
| 318 EXPECT_FALSE(mini.HasStream(CommentStreamW)); |
| 319 EXPECT_FALSE(full.HasStream(CommentStreamW)); |
| 320 EXPECT_FALSE(mini.HasStream(FunctionTableStream)); |
| 321 EXPECT_FALSE(full.HasStream(FunctionTableStream)); |
| 322 EXPECT_FALSE(mini.HasStream(MemoryInfoListStream)); |
| 323 EXPECT_FALSE(full.HasStream(MemoryInfoListStream)); |
| 324 EXPECT_FALSE(mini.HasStream(ThreadInfoListStream)); |
| 325 EXPECT_FALSE(full.HasStream(ThreadInfoListStream)); |
| 326 EXPECT_FALSE(mini.HasStream(HandleOperationListStream)); |
| 327 EXPECT_FALSE(full.HasStream(HandleOperationListStream)); |
| 328 EXPECT_FALSE(mini.HasStream(TokenStream)); |
| 329 EXPECT_FALSE(full.HasStream(TokenStream)); |
480 } | 330 } |
481 | 331 |
482 } // namespace | 332 } // namespace |
OLD | NEW |