OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/app/startup_helper_win.h" |
| 6 |
| 7 #include <crtdbg.h> |
| 8 #include <new.h> |
| 9 |
| 10 #include "base/base_switches.h" |
| 11 #include "base/command_line.h" |
| 12 |
| 13 namespace { |
| 14 |
| 15 #pragma optimize("", off) |
| 16 // Handlers for invalid parameter and pure call. They generate a breakpoint to |
| 17 // tell breakpad that it needs to dump the process. |
| 18 void InvalidParameter(const wchar_t* expression, const wchar_t* function, |
| 19 const wchar_t* file, unsigned int line, |
| 20 uintptr_t reserved) { |
| 21 __debugbreak(); |
| 22 _exit(1); |
| 23 } |
| 24 |
| 25 void PureCall() { |
| 26 __debugbreak(); |
| 27 _exit(1); |
| 28 } |
| 29 #pragma optimize("", on) |
| 30 |
| 31 } // namespace |
| 32 |
| 33 namespace content { |
| 34 |
| 35 // Register the invalid param handler and pure call handler to be able to |
| 36 // notify breakpad when it happens. |
| 37 void RegisterInvalidParamHandler() { |
| 38 _set_invalid_parameter_handler(InvalidParameter); |
| 39 _set_purecall_handler(PureCall); |
| 40 // Also enable the new handler for malloc() based failures. |
| 41 _set_new_mode(1); |
| 42 } |
| 43 |
| 44 void SetupCRT(const CommandLine& command_line) { |
| 45 #if defined(_CRTDBG_MAP_ALLOC) |
| 46 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); |
| 47 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); |
| 48 #else |
| 49 if (!command_line.HasSwitch(switches::kDisableBreakpad)) { |
| 50 _CrtSetReportMode(_CRT_ASSERT, 0); |
| 51 } |
| 52 #endif |
| 53 } |
| 54 |
| 55 } // namespace content |
OLD | NEW |