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 // A class to make it easy to tag exception propagation boundaries and | 5 // A class to make it easy to tag exception propagation boundaries and |
6 // get crash reports of exceptions that pass over same. | 6 // get crash reports of exceptions that pass over same. |
7 #include "chrome_frame/exception_barrier.h" | 7 #include "chrome_frame/exception_barrier.h" |
8 | 8 |
9 enum { | 9 enum { |
10 // Flag set by exception handling machinery when unwinding | 10 // Flag set by exception handling machinery when unwinding |
11 EH_UNWINDING = 0x00000002 | 11 EH_UNWINDING = 0x00000002 |
12 }; | 12 }; |
13 | 13 |
14 ExceptionBarrier::ExceptionHandler ExceptionBarrier::s_handler_ = NULL; | 14 ExceptionBarrier::ExceptionHandler ExceptionBarrier::s_handler_ = NULL; |
15 | 15 |
16 // This function must be extern "C" to match up with the SAFESEH | 16 // This function must be extern "C" to match up with the SAFESEH |
17 // declaration in our corresponding ASM file | 17 // declaration in our corresponding ASM file |
18 extern "C" EXCEPTION_DISPOSITION __cdecl | 18 extern "C" EXCEPTION_DISPOSITION __cdecl |
19 ExceptionBarrierHandler(struct _EXCEPTION_RECORD *exception_record, | 19 ExceptionBarrierHandler(struct _EXCEPTION_RECORD* exception_record, |
20 void * establisher_frame, | 20 void* establisher_frame, |
21 struct _CONTEXT *context, | 21 struct _CONTEXT* context, |
22 void * reserved) { | 22 void* reserved) { |
23 establisher_frame; // unreferenced formal parameter | 23 establisher_frame; // unreferenced formal parameter |
24 reserved; | 24 reserved; |
25 if (!(exception_record->ExceptionFlags & EH_UNWINDING)) { | 25 if (!(exception_record->ExceptionFlags & EH_UNWINDING)) { |
26 // When the exception is really propagating through us, we'd like to be | 26 // When the exception is really propagating through us, we'd like to be |
27 // called before the state of the program has been modified by the stack | 27 // called before the state of the program has been modified by the stack |
28 // unwinding. In the absence of an exception handler, the unhandled | 28 // unwinding. In the absence of an exception handler, the unhandled |
29 // exception filter gets called between the first chance and the second | 29 // exception filter gets called between the first chance and the second |
30 // chance exceptions, so Windows pops either the JIT debugger or WER UI. | 30 // chance exceptions, so Windows pops either the JIT debugger or WER UI. |
31 // This is not desirable in most of the cases. | 31 // This is not desirable in most of the cases. |
32 ExceptionBarrier::ExceptionHandler handler = ExceptionBarrier::handler(); | 32 ExceptionBarrier::ExceptionHandler handler = ExceptionBarrier::handler(); |
33 if (handler) { | 33 if (handler) { |
34 EXCEPTION_POINTERS ptrs = { exception_record, context }; | 34 EXCEPTION_POINTERS ptrs = { exception_record, context }; |
35 | 35 |
36 handler(&ptrs); | 36 handler(&ptrs); |
37 } | 37 } |
38 } | 38 } |
39 | 39 |
40 return ExceptionContinueSearch; | 40 return ExceptionContinueSearch; |
41 } | 41 } |
OLD | NEW |