| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #ifndef CHROME_FRAME_CRASH_REPORTING_VECTORED_HANDLER_IMPL_H_ | 5 #ifndef CHROME_FRAME_CRASH_REPORTING_VECTORED_HANDLER_IMPL_H_ |
| 6 #define CHROME_FRAME_CRASH_REPORTING_VECTORED_HANDLER_IMPL_H_ | 6 #define CHROME_FRAME_CRASH_REPORTING_VECTORED_HANDLER_IMPL_H_ |
| 7 |
| 8 #include "base/logging.h" |
| 7 #include "chrome_frame/crash_reporting/vectored_handler.h" | 9 #include "chrome_frame/crash_reporting/vectored_handler.h" |
| 8 #include "chrome_frame/crash_reporting/nt_loader.h" | 10 #include "chrome_frame/crash_reporting/nt_loader.h" |
| 9 | 11 |
| 10 #if defined(_M_IX86) | 12 #if defined(_M_IX86) |
| 11 #ifndef EXCEPTION_CHAIN_END | 13 #ifndef EXCEPTION_CHAIN_END |
| 12 #define EXCEPTION_CHAIN_END ((struct _EXCEPTION_REGISTRATION_RECORD*)-1) | 14 #define EXCEPTION_CHAIN_END ((struct _EXCEPTION_REGISTRATION_RECORD*)-1) |
| 13 typedef struct _EXCEPTION_REGISTRATION_RECORD { | 15 typedef struct _EXCEPTION_REGISTRATION_RECORD { |
| 14 struct _EXCEPTION_REGISTRATION_RECORD* Next; | 16 struct _EXCEPTION_REGISTRATION_RECORD* Next; |
| 15 PVOID Handler; | 17 PVOID Handler; |
| 16 } EXCEPTION_REGISTRATION_RECORD; | 18 } EXCEPTION_REGISTRATION_RECORD; |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 }; | 257 }; |
| 256 | 258 |
| 257 DECLSPEC_SELECTANY Win32VEHTraits::CodeBlock | 259 DECLSPEC_SELECTANY Win32VEHTraits::CodeBlock |
| 258 Win32VEHTraits::IgnoreExceptions[kIgnoreEntries] = { | 260 Win32VEHTraits::IgnoreExceptions[kIgnoreEntries] = { |
| 259 { "kernel32.dll", "IsBadReadPtr", 0, 100, NULL }, | 261 { "kernel32.dll", "IsBadReadPtr", 0, 100, NULL }, |
| 260 { "kernel32.dll", "IsBadWritePtr", 0, 100, NULL }, | 262 { "kernel32.dll", "IsBadWritePtr", 0, 100, NULL }, |
| 261 { "kernel32.dll", "IsBadStringPtrA", 0, 100, NULL }, | 263 { "kernel32.dll", "IsBadStringPtrA", 0, 100, NULL }, |
| 262 { "kernel32.dll", "IsBadStringPtrW", 0, 100, NULL }, | 264 { "kernel32.dll", "IsBadStringPtrW", 0, 100, NULL }, |
| 263 }; | 265 }; |
| 264 | 266 |
| 267 // Use Win32 API; checks for single (current) module. Will call a specified |
| 268 // CrashHandlerTraits::DumpHandler when taking a dump. |
| 269 class CrashHandlerTraits : public Win32VEHTraits, |
| 270 public ModuleOfInterestWithExcludedRegion { |
| 271 public: |
| 272 |
| 273 typedef bool (*DumpHandler)(EXCEPTION_POINTERS* p); |
| 274 |
| 275 CrashHandlerTraits() : dump_handler_(NULL) {} |
| 276 |
| 277 // Note that breakpad_lock must be held when this is called. |
| 278 void Init(const void* veh_segment_start, const void* veh_segment_end, |
| 279 DumpHandler dump_handler) { |
| 280 DCHECK(dump_handler); |
| 281 dump_handler_ = dump_handler; |
| 282 Win32VEHTraits::InitializeIgnoredBlocks(); |
| 283 ModuleOfInterestWithExcludedRegion::SetCurrentModule(); |
| 284 // Pointers to static (non-extern) functions take the address of the |
| 285 // function's first byte, as opposed to an entry in the compiler generated |
| 286 // JMP table. In release builds /OPT:REF wipes away the JMP table, but debug |
| 287 // builds are not so lucky. |
| 288 ModuleOfInterestWithExcludedRegion::SetExcludedRegion(veh_segment_start, |
| 289 veh_segment_end); |
| 290 } |
| 291 |
| 292 void Shutdown() { |
| 293 } |
| 294 |
| 295 inline bool WriteDump(EXCEPTION_POINTERS* p) { |
| 296 if (dump_handler_) { |
| 297 return dump_handler_(p); |
| 298 } else { |
| 299 return false; |
| 300 } |
| 301 } |
| 302 |
| 303 private: |
| 304 DumpHandler dump_handler_; |
| 305 }; |
| 306 |
| 265 #endif // CHROME_FRAME_CRASH_REPORTING_VECTORED_HANDLER_IMPL_H_ | 307 #endif // CHROME_FRAME_CRASH_REPORTING_VECTORED_HANDLER_IMPL_H_ |
| OLD | NEW |