| OLD | NEW |
| 1 | 1 |
| 2 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 2 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
| 4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
| 5 | 5 |
| 6 // crash_report.cc : Implementation crash reporting. | 6 // crash_report.cc : Implementation crash reporting. |
| 7 #include "chrome_frame/crash_reporting/crash_report.h" | 7 #include "chrome_frame/crash_reporting/crash_report.h" |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/lock.h" | 10 #include "base/lock.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 #pragma code_seg(pop) | 40 #pragma code_seg(pop) |
| 41 | 41 |
| 42 #pragma code_seg(push, ".text$vz") | 42 #pragma code_seg(push, ".text$vz") |
| 43 static void veh_segment_end() {} | 43 static void veh_segment_end() {} |
| 44 #pragma code_seg(pop) | 44 #pragma code_seg(pop) |
| 45 | 45 |
| 46 // Place code in .text$veh_m. | 46 // Place code in .text$veh_m. |
| 47 #pragma code_seg(push, ".text$vm") | 47 #pragma code_seg(push, ".text$vm") |
| 48 #include "chrome_frame/crash_reporting/vectored_handler-impl.h" | 48 #include "chrome_frame/crash_reporting/vectored_handler-impl.h" |
| 49 | 49 |
| 50 // Use Win32 API; use breakpad for dumps; checks for single (current) module. | |
| 51 class CrashHandlerTraits : public Win32VEHTraits, | |
| 52 public ModuleOfInterestWithExcludedRegion { | |
| 53 public: | |
| 54 CrashHandlerTraits() {} | |
| 55 | |
| 56 // Note that breakpad_lock must be held when this is called. | |
| 57 void Init(google_breakpad::ExceptionHandler* breakpad, Lock* breakpad_lock) { | |
| 58 DCHECK(breakpad); | |
| 59 DCHECK(breakpad_lock); | |
| 60 breakpad_lock->AssertAcquired(); | |
| 61 | |
| 62 Win32VEHTraits::InitializeIgnoredBlocks(); | |
| 63 ModuleOfInterestWithExcludedRegion::SetCurrentModule(); | |
| 64 // Pointers to static (non-extern) functions take the address of the | |
| 65 // function's first byte, as opposed to an entry in the compiler generated | |
| 66 // JMP table. In release builds /OPT:REF wipes away the JMP table, but debug | |
| 67 // builds are not so lucky. | |
| 68 ModuleOfInterestWithExcludedRegion::SetExcludedRegion(&veh_segment_start, | |
| 69 &veh_segment_end); | |
| 70 } | |
| 71 | |
| 72 void Shutdown() { | |
| 73 } | |
| 74 | |
| 75 inline bool WriteDump(EXCEPTION_POINTERS* p) { | |
| 76 return WriteMinidumpForException(p); | |
| 77 } | |
| 78 }; | |
| 79 | |
| 80 class CrashHandler { | 50 class CrashHandler { |
| 81 public: | 51 public: |
| 82 CrashHandler() : veh_id_(NULL), handler_(&crash_api_) {} | 52 CrashHandler() : veh_id_(NULL), handler_(&crash_api_) {} |
| 83 | 53 |
| 84 // Note that breakpad_lock is used to protect accesses to breakpad and must | 54 // Note that breakpad_lock is used to protect accesses to breakpad and must |
| 85 // be held when Init() is called. | 55 // be held when Init() is called. |
| 86 bool Init(google_breakpad::ExceptionHandler* breakpad, Lock* breakpad_lock); | 56 bool Init(google_breakpad::ExceptionHandler* breakpad, Lock* breakpad_lock); |
| 87 | 57 |
| 88 void Shutdown(); | 58 void Shutdown(); |
| 89 private: | 59 private: |
| (...skipping 18 matching lines...) Expand all Loading... |
| 108 | 78 |
| 109 bool CrashHandler::Init(google_breakpad::ExceptionHandler* breakpad, | 79 bool CrashHandler::Init(google_breakpad::ExceptionHandler* breakpad, |
| 110 Lock* breakpad_lock) { | 80 Lock* breakpad_lock) { |
| 111 DCHECK(breakpad); | 81 DCHECK(breakpad); |
| 112 DCHECK(breakpad_lock); | 82 DCHECK(breakpad_lock); |
| 113 breakpad_lock->AssertAcquired(); | 83 breakpad_lock->AssertAcquired(); |
| 114 | 84 |
| 115 if (veh_id_) | 85 if (veh_id_) |
| 116 return true; | 86 return true; |
| 117 | 87 |
| 88 crash_api_.Init(&veh_segment_start, &veh_segment_end, |
| 89 &WriteMinidumpForException); |
| 90 |
| 118 void* id = ::AddVectoredExceptionHandler(FALSE, &VectoredHandlerEntryPoint); | 91 void* id = ::AddVectoredExceptionHandler(FALSE, &VectoredHandlerEntryPoint); |
| 119 if (id != NULL) { | 92 if (id != NULL) { |
| 120 veh_id_ = id; | 93 veh_id_ = id; |
| 121 crash_api_.Init(breakpad, breakpad_lock); | |
| 122 return true; | 94 return true; |
| 95 } else { |
| 96 crash_api_.Shutdown(); |
| 97 return false; |
| 123 } | 98 } |
| 124 | |
| 125 return false; | |
| 126 } | 99 } |
| 127 | 100 |
| 128 void CrashHandler::Shutdown() { | 101 void CrashHandler::Shutdown() { |
| 129 if (veh_id_) { | 102 if (veh_id_) { |
| 130 ::RemoveVectoredExceptionHandler(veh_id_); | 103 ::RemoveVectoredExceptionHandler(veh_id_); |
| 131 veh_id_ = NULL; | 104 veh_id_ = NULL; |
| 132 } | 105 } |
| 133 | 106 |
| 134 crash_api_.Shutdown(); | 107 crash_api_.Shutdown(); |
| 135 } | 108 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 } | 171 } |
| 199 | 172 |
| 200 bool WriteMinidumpForException(EXCEPTION_POINTERS* p) { | 173 bool WriteMinidumpForException(EXCEPTION_POINTERS* p) { |
| 201 AutoLock lock(g_breakpad_lock); | 174 AutoLock lock(g_breakpad_lock); |
| 202 bool success = false; | 175 bool success = false; |
| 203 if (g_breakpad) { | 176 if (g_breakpad) { |
| 204 success = g_breakpad->WriteMinidumpForException(p); | 177 success = g_breakpad->WriteMinidumpForException(p); |
| 205 } | 178 } |
| 206 return success; | 179 return success; |
| 207 } | 180 } |
| OLD | NEW |