| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 #ifndef CHROME_FRAME_CRASH_REPORTING_VEH_TEST_H_ |
| 5 #define CHROME_FRAME_CRASH_REPORTING_VEH_TEST_H_ |
| 6 |
| 7 #include <windows.h> |
| 8 #include "base/logging.h" |
| 9 |
| 10 #ifndef EXCEPTION_CHAIN_END |
| 11 #define EXCEPTION_CHAIN_END ((struct _EXCEPTION_REGISTRATION_RECORD*)-1) |
| 12 typedef struct _EXCEPTION_REGISTRATION_RECORD { |
| 13 struct _EXCEPTION_REGISTRATION_RECORD* Next; |
| 14 PVOID Handler; |
| 15 } EXCEPTION_REGISTRATION_RECORD; |
| 16 #endif // EXCEPTION_CHAIN_END |
| 17 |
| 18 class ExceptionInfo : public _EXCEPTION_POINTERS { |
| 19 public: |
| 20 ExceptionInfo() { |
| 21 Clear(); |
| 22 } |
| 23 |
| 24 ExceptionInfo(DWORD code, void* address) { |
| 25 Clear(); |
| 26 Set(code, address, 0); |
| 27 } |
| 28 |
| 29 void Set(DWORD code, void* address, DWORD flags) { |
| 30 er_.ExceptionCode = code; |
| 31 er_.ExceptionAddress = address; |
| 32 er_.ExceptionFlags = flags; |
| 33 ctx_.Eip = reinterpret_cast<DWORD>(address); |
| 34 } |
| 35 |
| 36 EXCEPTION_RECORD er_; |
| 37 CONTEXT ctx_; |
| 38 private: |
| 39 void Clear() { |
| 40 ExceptionRecord = &er_; |
| 41 ContextRecord = &ctx_; |
| 42 ZeroMemory(&er_, sizeof(er_)); |
| 43 ZeroMemory(&ctx_, sizeof(ctx_)); |
| 44 } |
| 45 }; |
| 46 |
| 47 struct SEHChain { |
| 48 SEHChain(const void* p, ...) { |
| 49 va_list vl; |
| 50 va_start(vl, p); |
| 51 int i = 0; |
| 52 for (; p; ++i) { |
| 53 CHECK(i + 1 < arraysize(chain_)); |
| 54 chain_[i].Handler = const_cast<void*>(p); |
| 55 chain_[i].Next = &chain_[i + 1]; |
| 56 p = va_arg(vl, const void*); |
| 57 } |
| 58 |
| 59 chain_[i].Next = EXCEPTION_CHAIN_END; |
| 60 } |
| 61 |
| 62 EXCEPTION_REGISTRATION_RECORD chain_[25]; |
| 63 }; |
| 64 |
| 65 struct StackHelper { |
| 66 StackHelper(const void* p, ...) { |
| 67 va_list vl; |
| 68 va_start(vl, p); |
| 69 count_ = 0; |
| 70 for (; p; ++count_) { |
| 71 CHECK(count_ < arraysize(stack_)); |
| 72 stack_[count_] = p; |
| 73 p = va_arg(vl, const void*); |
| 74 } |
| 75 } |
| 76 const void* stack_[64]; |
| 77 WORD count_; |
| 78 }; |
| 79 |
| 80 #endif // CHROME_FRAME_CRASH_REPORTING_VEH_TEST_H_ |
| OLD | NEW |