OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 // Need to include this before most other files because it defines | 7 // Need to include this before most other files because it defines |
8 // IPC_MESSAGE_LOG_ENABLED. We need to use it to define | 8 // IPC_MESSAGE_LOG_ENABLED. We need to use it to define |
9 // IPC_MESSAGE_MACROS_LOG_ENABLED so render_messages.h will generate the | 9 // IPC_MESSAGE_MACROS_LOG_ENABLED so render_messages.h will generate the |
10 // ViewMsgLog et al. functions. | 10 // ViewMsgLog et al. functions. |
(...skipping 29 matching lines...) Expand all Loading... |
40 #include "base/path_service.h" | 40 #include "base/path_service.h" |
41 #include "base/string_number_conversions.h" | 41 #include "base/string_number_conversions.h" |
42 #include "base/string_util.h" | 42 #include "base/string_util.h" |
43 #include "base/stringprintf.h" | 43 #include "base/stringprintf.h" |
44 #include "base/threading/thread_restrictions.h" | 44 #include "base/threading/thread_restrictions.h" |
45 #include "base/time.h" | 45 #include "base/time.h" |
46 #include "base/utf_string_conversions.h" | 46 #include "base/utf_string_conversions.h" |
47 #include "chrome/common/chrome_constants.h" | 47 #include "chrome/common/chrome_constants.h" |
48 #include "chrome/common/chrome_paths.h" | 48 #include "chrome/common/chrome_paths.h" |
49 #include "chrome/common/chrome_switches.h" | 49 #include "chrome/common/chrome_switches.h" |
| 50 #include "chrome/common/dump_without_crashing.h" |
50 #include "chrome/common/env_vars.h" | 51 #include "chrome/common/env_vars.h" |
51 #include "ipc/ipc_logging.h" | 52 #include "ipc/ipc_logging.h" |
52 | 53 |
53 #if defined(OS_WIN) | 54 #if defined(OS_WIN) |
54 #include "base/logging_win.h" | 55 #include "base/logging_win.h" |
55 #include <initguid.h> | 56 #include <initguid.h> |
56 #endif | 57 #endif |
57 | 58 |
58 namespace { | 59 namespace { |
59 | 60 |
(...skipping 11 matching lines...) Expand all Loading... |
71 // InitChromeLogging() and the beginning of CleanupChromeLogging(). | 72 // InitChromeLogging() and the beginning of CleanupChromeLogging(). |
72 bool chrome_logging_redirected_ = false; | 73 bool chrome_logging_redirected_ = false; |
73 | 74 |
74 #if defined(OS_WIN) | 75 #if defined(OS_WIN) |
75 // {7FE69228-633E-4f06-80C1-527FEA23E3A7} | 76 // {7FE69228-633E-4f06-80C1-527FEA23E3A7} |
76 const GUID kChromeTraceProviderName = { | 77 const GUID kChromeTraceProviderName = { |
77 0x7fe69228, 0x633e, 0x4f06, | 78 0x7fe69228, 0x633e, 0x4f06, |
78 { 0x80, 0xc1, 0x52, 0x7f, 0xea, 0x23, 0xe3, 0xa7 } }; | 79 { 0x80, 0xc1, 0x52, 0x7f, 0xea, 0x23, 0xe3, 0xa7 } }; |
79 #endif | 80 #endif |
80 | 81 |
81 #if defined(USE_LINUX_BREAKPAD) || defined(OS_MACOSX) | |
82 // Pointer to the function that's called by DumpWithoutCrashing() to dump the | |
83 // process's memory. | |
84 void (*dump_without_crashing_function_)() = NULL; | |
85 #endif | |
86 | |
87 // Assertion handler for logging errors that occur when dialogs are | 82 // Assertion handler for logging errors that occur when dialogs are |
88 // silenced. To record a new error, pass the log string associated | 83 // silenced. To record a new error, pass the log string associated |
89 // with that error in the str parameter. | 84 // with that error in the str parameter. |
90 MSVC_DISABLE_OPTIMIZE(); | 85 MSVC_DISABLE_OPTIMIZE(); |
91 void SilentRuntimeAssertHandler(const std::string& str) { | 86 void SilentRuntimeAssertHandler(const std::string& str) { |
92 base::debug::BreakDebugger(); | 87 base::debug::BreakDebugger(); |
93 } | 88 } |
94 void SilentRuntimeReportHandler(const std::string& str) { | 89 void SilentRuntimeReportHandler(const std::string& str) { |
95 } | 90 } |
96 #if defined(OS_WIN) | 91 #if defined(OS_WIN) |
97 // Handler to silently dump the current process when there is an assert in | 92 // Handler to silently dump the current process when there is an assert in |
98 // chrome. | 93 // chrome. |
99 void DumpProcessAssertHandler(const std::string& str) { | 94 void DumpProcessAssertHandler(const std::string& str) { |
100 // Get the breakpad pointer from chrome.exe | 95 logging::DumpWithoutCrashing(); |
101 typedef void (__cdecl *DumpProcessFunction)(); | |
102 DumpProcessFunction DumpProcess = reinterpret_cast<DumpProcessFunction>( | |
103 ::GetProcAddress(::GetModuleHandle(chrome::kBrowserProcessExecutableName), | |
104 "DumpProcess")); | |
105 if (DumpProcess) | |
106 DumpProcess(); | |
107 } | 96 } |
108 #endif // OS_WIN | 97 #endif // OS_WIN |
109 MSVC_ENABLE_OPTIMIZE(); | 98 MSVC_ENABLE_OPTIMIZE(); |
110 | 99 |
111 // Suppresses error/assertion dialogs and enables the logging of | 100 // Suppresses error/assertion dialogs and enables the logging of |
112 // those errors into silenced_errors_. | 101 // those errors into silenced_errors_. |
113 void SuppressDialogs() { | 102 void SuppressDialogs() { |
114 if (dialogs_are_suppressed_) | 103 if (dialogs_are_suppressed_) |
115 return; | 104 return; |
116 | 105 |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 if (assertions) | 425 if (assertions) |
437 assertions->push_back(wide_line); | 426 assertions->push_back(wide_line); |
438 ++assertion_count; | 427 ++assertion_count; |
439 } | 428 } |
440 } | 429 } |
441 log_file.close(); | 430 log_file.close(); |
442 | 431 |
443 return assertion_count; | 432 return assertion_count; |
444 } | 433 } |
445 | 434 |
446 void DumpWithoutCrashing() { | |
447 #if defined(OS_WIN) | |
448 std::string str; | |
449 DumpProcessAssertHandler(str); | |
450 #elif defined(USE_LINUX_BREAKPAD) || defined(OS_MACOSX) | |
451 if (dump_without_crashing_function_) | |
452 (*dump_without_crashing_function_)(); | |
453 #else | |
454 NOTIMPLEMENTED(); | |
455 #endif | |
456 } | |
457 | |
458 #if defined(USE_LINUX_BREAKPAD) || defined(OS_MACOSX) | |
459 void SetDumpWithoutCrashingFunction(void (*function)()) { | |
460 dump_without_crashing_function_ = function; | |
461 } | |
462 #endif | |
463 | |
464 FilePath GenerateTimestampedName(const FilePath& base_path, | 435 FilePath GenerateTimestampedName(const FilePath& base_path, |
465 base::Time timestamp) { | 436 base::Time timestamp) { |
466 base::Time::Exploded time_deets; | 437 base::Time::Exploded time_deets; |
467 timestamp.LocalExplode(&time_deets); | 438 timestamp.LocalExplode(&time_deets); |
468 std::string suffix = base::StringPrintf("_%02d%02d%02d-%02d%02d%02d", | 439 std::string suffix = base::StringPrintf("_%02d%02d%02d-%02d%02d%02d", |
469 time_deets.year, | 440 time_deets.year, |
470 time_deets.month, | 441 time_deets.month, |
471 time_deets.day_of_month, | 442 time_deets.day_of_month, |
472 time_deets.hour, | 443 time_deets.hour, |
473 time_deets.minute, | 444 time_deets.minute, |
474 time_deets.second); | 445 time_deets.second); |
475 return base_path.InsertBeforeExtensionASCII(suffix); | 446 return base_path.InsertBeforeExtensionASCII(suffix); |
476 } | 447 } |
477 | 448 |
478 } // namespace logging | 449 } // namespace logging |
OLD | NEW |