| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include <windows.h> | 4 #include <windows.h> |
| 5 #include <objbase.h> | 5 #include <objbase.h> |
| 6 #include <dbghelp.h> | 6 #include <dbghelp.h> |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 ::RtlCaptureContext(&ctx_record); | 124 ::RtlCaptureContext(&ctx_record); |
| 125 | 125 |
| 126 // And write a dump | 126 // And write a dump |
| 127 BOOL result = ::MiniDumpWriteDump(::GetCurrentProcess(), | 127 BOOL result = ::MiniDumpWriteDump(::GetCurrentProcess(), |
| 128 ::GetCurrentProcessId(), | 128 ::GetCurrentProcessId(), |
| 129 dump_file_handle_.Get(), | 129 dump_file_handle_.Get(), |
| 130 static_cast<MINIDUMP_TYPE>(flags), | 130 static_cast<MINIDUMP_TYPE>(flags), |
| 131 &ex_info, | 131 &ex_info, |
| 132 NULL, | 132 NULL, |
| 133 NULL); | 133 NULL); |
| 134 LOG(INFO) << "Flags: " << flags << " mindump size: " << | 134 VLOG(1) << "Flags: " << flags << " mindump size: " |
| 135 ::GetFileSize(dump_file_handle_.Get(), NULL); | 135 << ::GetFileSize(dump_file_handle_.Get(), NULL); |
| 136 | 136 |
| 137 return result == TRUE; | 137 return result == TRUE; |
| 138 } | 138 } |
| 139 | 139 |
| 140 bool DumpHasStream(ULONG stream_number) { | 140 bool DumpHasStream(ULONG stream_number) { |
| 141 EnsureDumpMapped(); | 141 EnsureDumpMapped(); |
| 142 | 142 |
| 143 MINIDUMP_DIRECTORY* directory = NULL; | 143 MINIDUMP_DIRECTORY* directory = NULL; |
| 144 void* stream = NULL; | 144 void* stream = NULL; |
| 145 ULONG stream_size = 0; | 145 ULONG stream_size = 0; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 ScopedHandle dump_file_handle_; | 280 ScopedHandle dump_file_handle_; |
| 281 ScopedHandle dump_file_mapping_; | 281 ScopedHandle dump_file_mapping_; |
| 282 void* dump_file_view_; | 282 void* dump_file_view_; |
| 283 | 283 |
| 284 FilePath dump_file_; | 284 FilePath dump_file_; |
| 285 }; | 285 }; |
| 286 | 286 |
| 287 TEST_F(MinidumpTest, Version) { | 287 TEST_F(MinidumpTest, Version) { |
| 288 API_VERSION* version = ::ImagehlpApiVersion(); | 288 API_VERSION* version = ::ImagehlpApiVersion(); |
| 289 | 289 |
| 290 LOG(INFO) << "Imagehlp Api Version: " << version->MajorVersion << "." | 290 VLOG(1) << "Imagehlp Api Version: " << version->MajorVersion << "." |
| 291 << version->MinorVersion << "." << version->Revision; | 291 << version->MinorVersion << "." << version->Revision; |
| 292 | 292 |
| 293 HMODULE dbg_help = ::GetModuleHandle(L"dbghelp.dll"); | 293 HMODULE dbg_help = ::GetModuleHandle(L"dbghelp.dll"); |
| 294 ASSERT_TRUE(dbg_help != NULL); | 294 ASSERT_TRUE(dbg_help != NULL); |
| 295 | 295 |
| 296 wchar_t dbg_help_file[1024] = {}; | 296 wchar_t dbg_help_file[1024] = {}; |
| 297 ASSERT_TRUE(::GetModuleFileName(dbg_help, | 297 ASSERT_TRUE(::GetModuleFileName(dbg_help, |
| 298 dbg_help_file, | 298 dbg_help_file, |
| 299 arraysize(dbg_help_file))); | 299 arraysize(dbg_help_file))); |
| 300 scoped_ptr<FileVersionInfo> file_info( | 300 scoped_ptr<FileVersionInfo> file_info( |
| 301 FileVersionInfo::CreateFileVersionInfo(dbg_help_file)); | 301 FileVersionInfo::CreateFileVersionInfo(dbg_help_file)); |
| 302 ASSERT_TRUE(file_info != NULL); | 302 ASSERT_TRUE(file_info != NULL); |
| 303 | 303 |
| 304 LOG(INFO) << "DbgHelp.dll version: " << file_info->file_version(); | 304 VLOG(1) << "DbgHelp.dll version: " << file_info->file_version(); |
| 305 } | 305 } |
| 306 | 306 |
| 307 TEST_F(MinidumpTest, Normal) { | 307 TEST_F(MinidumpTest, Normal) { |
| 308 EXPECT_TRUE(WriteDump(MiniDumpNormal)); | 308 EXPECT_TRUE(WriteDump(MiniDumpNormal)); |
| 309 | 309 |
| 310 // We expect threads, modules and some memory. | 310 // We expect threads, modules and some memory. |
| 311 EXPECT_TRUE(DumpHasStream(ThreadListStream)); | 311 EXPECT_TRUE(DumpHasStream(ThreadListStream)); |
| 312 EXPECT_TRUE(DumpHasStream(ModuleListStream)); | 312 EXPECT_TRUE(DumpHasStream(ModuleListStream)); |
| 313 EXPECT_TRUE(DumpHasStream(MemoryListStream)); | 313 EXPECT_TRUE(DumpHasStream(MemoryListStream)); |
| 314 EXPECT_TRUE(DumpHasStream(ExceptionStream)); | 314 EXPECT_TRUE(DumpHasStream(ExceptionStream)); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 int main(int argc, char** argv) { | 432 int main(int argc, char** argv) { |
| 433 testing::InitGoogleTest(&argc, argv); | 433 testing::InitGoogleTest(&argc, argv); |
| 434 CommandLine::Init(argc, argv); | 434 CommandLine::Init(argc, argv); |
| 435 | 435 |
| 436 logging::InitLogging(L"CON", | 436 logging::InitLogging(L"CON", |
| 437 logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG, | 437 logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG, |
| 438 logging::DONT_LOCK_LOG_FILE, | 438 logging::DONT_LOCK_LOG_FILE, |
| 439 logging::APPEND_TO_OLD_LOG_FILE); | 439 logging::APPEND_TO_OLD_LOG_FILE); |
| 440 return RUN_ALL_TESTS(); | 440 return RUN_ALL_TESTS(); |
| 441 } | 441 } |
| OLD | NEW |