From 4e3c8d94251bb8a010e1656e824a46d4c2a14119 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Tue, 4 Mar 2014 11:56:42 +0000 Subject: [PATCH] * exception.h (exception::handler_installed): Remove. (exception::exception): Remove old code. Manually install SEH handler instead. (exception::~exception): For x86_64, define frame end label. * exceptions.cc (exception::handler_installed): Remove. --- winsup/cygwin/ChangeLog | 8 ++++++++ winsup/cygwin/exception.h | 29 +++++++++++++++++------------ winsup/cygwin/exceptions.cc | 2 -- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index c7abec5e7..74cfc9653 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,11 @@ +2014-03-04 Corinna Vinschen + + * exception.h (exception::handler_installed): Remove. + (exception::exception): Remove old code. Manually install SEH handler + instead. + (exception::~exception): For x86_64, define frame end label. + * exceptions.cc (exception::handler_installed): Remove. + 2014-03-03 Corinna Vinschen * exception.h (exception::exception): Install vectored exception diff --git a/winsup/cygwin/exception.h b/winsup/cygwin/exception.h index 95d8311fc..5b8b6da77 100644 --- a/winsup/cygwin/exception.h +++ b/winsup/cygwin/exception.h @@ -109,7 +109,6 @@ extern exception_list *_except_list asm ("%fs:0"); class exception { #ifdef __x86_64__ - static bool handler_installed; static int handle (LPEXCEPTION_POINTERS); #else exception_list el; @@ -120,16 +119,16 @@ public: exception () __attribute__ ((always_inline)) { #ifdef __x86_64__ - if (!handler_installed) - { - handler_installed = true; - /* The unhandled exception filter goes first. It won't work if the - executable is debugged, but then the vectored continue handler - kicks in. For some reason the vectored continue handler doesn't - get called if no unhandled exception filter is installed. */ - SetUnhandledExceptionFilter (handle); - AddVectoredExceptionHandler (1, handle); - } + /* Manually install SEH handler. */ + asm (".l_startframe: \n\ + .seh_handler __C_specific_handler, @except \n\ + .seh_handlerdata \n\ + .long 1 \n\ + .rva .l_startframe, \ + .l_endframe, \ + _ZN9exception6handleEP19_EXCEPTION_POINTERS, \ + .l_endframe \n\ + .text \n"); #else save = _except_list; el.handler = handle; @@ -137,7 +136,13 @@ public: _except_list = ⪙ #endif /* __x86_64__ */ }; -#ifndef __x86_64__ +#ifdef __x86_64__ + ~exception () __attribute__ ((always_inline)) { + asm (" nop \n\ + .l_endframe: \n\ + nop \n"); + } +#else ~exception () __attribute__ ((always_inline)) { _except_list = save; } #endif /* !__x86_64__ */ }; diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index ceddbbca5..4b1db9d62 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -553,8 +553,6 @@ rtl_unwind (exception_list *frame, PEXCEPTION_RECORD e) #define CYG_EXC_CONTINUE_EXECUTION EXCEPTION_CONTINUE_EXECUTION #define CYG_EXC_CONTINUE_SEARCH EXCEPTION_CONTINUE_SEARCH -bool exception::handler_installed NO_COPY; - int exception::handle (LPEXCEPTION_POINTERS ep) #else