From c0a5c2e18a9f7ab12db3e599653c08e22229f334 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Fri, 18 Jun 2021 08:04:01 +0200 Subject: First version of Win32 structured exception handling test * ACE/tests/Compiler_Features_39_Test.cpp: Added. * ACE/tests/run_test.lst: * ACE/tests/tests.mpc: --- ACE/tests/Compiler_Features_39_Test.cpp | 55 +++++++++++++++++++++++++++++++++ ACE/tests/run_test.lst | 1 + ACE/tests/tests.mpc | 7 +++++ 3 files changed, 63 insertions(+) create mode 100644 ACE/tests/Compiler_Features_39_Test.cpp (limited to 'ACE') diff --git a/ACE/tests/Compiler_Features_39_Test.cpp b/ACE/tests/Compiler_Features_39_Test.cpp new file mode 100644 index 00000000000..dd9d331cc54 --- /dev/null +++ b/ACE/tests/Compiler_Features_39_Test.cpp @@ -0,0 +1,55 @@ +/** + * This program checks if the compiler/RTL does have correct support + * for structured exception handling + */ + +#include "test_config.h" +#include "ace/CDR_Base.h" + +#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) +int *p = 0; + +int ExFilter(EXCEPTION_POINTERS *ep, DWORD code_arg) +{ + ACE_DEBUG ((LM_INFO,("In SEH Filter\n")); + ACE_DEBUG ((LM_INFO,("Code param=%lX\n"), code_arg)); + ACE_DEBUG ((LM_INFO,("\tep->ExceptionRecord->ExceptionCode =%lX\n"), ep->ExceptionRecord->ExceptionCode); + ACE_DEBUG ((LM_INFO,("\tep->ExceptionRecord->ExceptionAddress =%p\n"), ep->ExceptionRecord->ExceptionAddress); + if (ep->ExceptionRecord->NumberParameters >= 1) + ACE_DEBUG ((LM_INFO,("\tep->ExceptionRecord->ExceptionInformation[0]=%lX\n"), ep->ExceptionRecord->ExceptionInformation[0])); + if (ep->ExceptionRecord->NumberParameters == 2) + ACE_DEBUG ((LM_INFO,("\tep->ExceptionRecord->ExceptionInformation[1]=%lX\n"), ep->ExceptionRecord->ExceptionInformation[1])); + return 1; +} +#endif + +int +run_main (int, ACE_TCHAR *[]) +{ + ACE_START_TEST (ACE_TEXT("Compiler_Features_39_Test")); + +#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) + ACE_SEH_TRY + { + *(reinterpret_cast(&p)) = 0xFFFF0000; + ACE_DEBUG ((LM_DEBUG,("In __try, p=%p\n"), p); + ACE_DEBUG ((LM_DEBUG,("BAD_ADDR =%p\n"), &&BAD_ADDR); +BAD_ADDR: + return *p; + } + ACE_SEH_EXCEPT (ExFilter(GetExceptionInformation(), GetExceptionCode())) + { + ACE_DEBUG ((LM_DEBUG,("In SEH __except\n")); + } + + ACE_DEBUG ((LM_DEBUG,("SEH worked\n")); +#else + ACE_DEBUG ((LM_INFO, + ACE_TEXT ("Platform lacks ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS\n"))); +#endif + + ACE_END_TEST; + + return 0; +} + diff --git a/ACE/tests/run_test.lst b/ACE/tests/run_test.lst index 7277368fffb..ab5e25d91a2 100644 --- a/ACE/tests/run_test.lst +++ b/ACE/tests/run_test.lst @@ -109,6 +109,7 @@ Compiler_Features_35_Test Compiler_Features_36_Test Compiler_Features_37_Test Compiler_Features_38_Test +Compiler_Features_39_Test Config_Test: !LynxOS !VxWorks !ACE_FOR_TAO Conn_Test: !ACE_FOR_TAO DLL_Test: !STATIC Linux diff --git a/ACE/tests/tests.mpc b/ACE/tests/tests.mpc index 35feb43db0f..bce99b2dd5e 100644 --- a/ACE/tests/tests.mpc +++ b/ACE/tests/tests.mpc @@ -842,6 +842,13 @@ project(Compiler_Features_38_Test) : acetest { } } +project(Compiler_Features_39_Test) : acetest { + exename = Compiler_Features_39_Test + Source_Files { + Compiler_Features_39_Test.cpp + } +} + project(Config Test) : acetest { avoids += ace_for_tao exename = Config_Test -- cgit v1.2.1 From 7a4b933220109962afd6ed72fe4e352184536e69 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Fri, 18 Jun 2021 14:46:08 +0200 Subject: Update Compiler_Features_39_Test.cpp --- ACE/tests/Compiler_Features_39_Test.cpp | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'ACE') diff --git a/ACE/tests/Compiler_Features_39_Test.cpp b/ACE/tests/Compiler_Features_39_Test.cpp index dd9d331cc54..2050475f247 100644 --- a/ACE/tests/Compiler_Features_39_Test.cpp +++ b/ACE/tests/Compiler_Features_39_Test.cpp @@ -7,21 +7,19 @@ #include "ace/CDR_Base.h" #if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) -int *p = 0; - int ExFilter(EXCEPTION_POINTERS *ep, DWORD code_arg) { - ACE_DEBUG ((LM_INFO,("In SEH Filter\n")); - ACE_DEBUG ((LM_INFO,("Code param=%lX\n"), code_arg)); - ACE_DEBUG ((LM_INFO,("\tep->ExceptionRecord->ExceptionCode =%lX\n"), ep->ExceptionRecord->ExceptionCode); - ACE_DEBUG ((LM_INFO,("\tep->ExceptionRecord->ExceptionAddress =%p\n"), ep->ExceptionRecord->ExceptionAddress); + ACE_DEBUG ((LM_INFO,("In SEH Filter\n"))); + ACE_DEBUG ((LM_INFO,("Code param=%d\n"), code_arg)); + ACE_DEBUG ((LM_INFO,("\tep->ExceptionRecord->ExceptionCode =%d\n"), ep->ExceptionRecord->ExceptionCode)); + ACE_DEBUG ((LM_INFO,("\tep->ExceptionRecord->ExceptionAddress =%@\n"), ep->ExceptionRecord->ExceptionAddress)); if (ep->ExceptionRecord->NumberParameters >= 1) - ACE_DEBUG ((LM_INFO,("\tep->ExceptionRecord->ExceptionInformation[0]=%lX\n"), ep->ExceptionRecord->ExceptionInformation[0])); + ACE_DEBUG ((LM_INFO,("\tep->ExceptionRecord->ExceptionInformation[0]=%@\n"), ep->ExceptionRecord->ExceptionInformation[0])); if (ep->ExceptionRecord->NumberParameters == 2) - ACE_DEBUG ((LM_INFO,("\tep->ExceptionRecord->ExceptionInformation[1]=%lX\n"), ep->ExceptionRecord->ExceptionInformation[1])); + ACE_DEBUG ((LM_INFO,("\tep->ExceptionRecord->ExceptionInformation[1]=%@\n"), ep->ExceptionRecord->ExceptionInformation[1])); return 1; } -#endif +#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ int run_main (int, ACE_TCHAR *[]) @@ -31,22 +29,19 @@ run_main (int, ACE_TCHAR *[]) #if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) ACE_SEH_TRY { - *(reinterpret_cast(&p)) = 0xFFFF0000; - ACE_DEBUG ((LM_DEBUG,("In __try, p=%p\n"), p); - ACE_DEBUG ((LM_DEBUG,("BAD_ADDR =%p\n"), &&BAD_ADDR); -BAD_ADDR: - return *p; + volatile int* pInt = 0x0000000; + *pInt = 20; } ACE_SEH_EXCEPT (ExFilter(GetExceptionInformation(), GetExceptionCode())) { - ACE_DEBUG ((LM_DEBUG,("In SEH __except\n")); + ACE_DEBUG ((LM_DEBUG,("In SEH __except\n"))); } - ACE_DEBUG ((LM_DEBUG,("SEH worked\n")); + ACE_DEBUG ((LM_DEBUG,("SEH worked\n"))); #else ACE_DEBUG ((LM_INFO, ACE_TEXT ("Platform lacks ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS\n"))); -#endif +#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ ACE_END_TEST; -- cgit v1.2.1 From 2871e2a915aaec15988365222766e5f7227603d4 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Fri, 18 Jun 2021 14:49:17 +0200 Subject: No need to check for ACE_WIN32 in combination with ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS * ACE/ace/Global_Macros.h: * ACE/ace/OS_Log_Msg_Attributes.inl: * ACE/tests/Compiler_Features_39_Test.cpp: --- ACE/ace/Global_Macros.h | 6 +++--- ACE/ace/OS_Log_Msg_Attributes.inl | 4 ++-- ACE/tests/Compiler_Features_39_Test.cpp | 1 - 3 files changed, 5 insertions(+), 6 deletions(-) (limited to 'ACE') diff --git a/ACE/ace/Global_Macros.h b/ACE/ace/Global_Macros.h index 4ce34487b4f..8918947791a 100644 --- a/ACE/ace/Global_Macros.h +++ b/ACE/ace/Global_Macros.h @@ -811,15 +811,15 @@ ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (AC # define ACE_NOOP(x) -#if defined (ACE_WIN32) && defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) +#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) # define ACE_SEH_TRY __try # define ACE_SEH_EXCEPT(X) __except(X) # define ACE_SEH_FINALLY __finally -#else /* !ACE_WIN32 */ +#else /* !ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ # define ACE_SEH_TRY if (1) # define ACE_SEH_EXCEPT(X) while (0) # define ACE_SEH_FINALLY if (1) -#endif /* ACE_WIN32 */ +#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ // Handle ACE_Message_Queue. # define ACE_SYNCH_DECL typename _ACE_SYNCH diff --git a/ACE/ace/OS_Log_Msg_Attributes.inl b/ACE/ace/OS_Log_Msg_Attributes.inl index 744ac94870f..0fa53f421be 100644 --- a/ACE/ace/OS_Log_Msg_Attributes.inl +++ b/ACE/ace/OS_Log_Msg_Attributes.inl @@ -9,10 +9,10 @@ ACE_OS_Log_Msg_Attributes::ACE_OS_Log_Msg_Attributes () : tracing_enabled_ (0), restart_ (true), trace_depth_ (0) -# if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) +#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) , seh_except_selector_ (0), seh_except_handler_ (0) -# endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ +#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ { } diff --git a/ACE/tests/Compiler_Features_39_Test.cpp b/ACE/tests/Compiler_Features_39_Test.cpp index 2050475f247..7942f4d21af 100644 --- a/ACE/tests/Compiler_Features_39_Test.cpp +++ b/ACE/tests/Compiler_Features_39_Test.cpp @@ -4,7 +4,6 @@ */ #include "test_config.h" -#include "ace/CDR_Base.h" #if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) int ExFilter(EXCEPTION_POINTERS *ep, DWORD code_arg) -- cgit v1.2.1 From 2b717af399e275065bfada5f77631cd69d75eff6 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Fri, 18 Jun 2021 16:32:55 +0200 Subject: Indent changes * ACE/ace/OS_Thread_Adapter.cpp: * ACE/ace/OS_Thread_Adapter.h: * ACE/ace/Thread_Adapter.h: --- ACE/ace/OS_Thread_Adapter.cpp | 8 ++++---- ACE/ace/OS_Thread_Adapter.h | 4 ++-- ACE/ace/Thread_Adapter.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'ACE') diff --git a/ACE/ace/OS_Thread_Adapter.cpp b/ACE/ace/OS_Thread_Adapter.cpp index 6074974a232..9e869bdaea8 100644 --- a/ACE/ace/OS_Thread_Adapter.cpp +++ b/ACE/ace/OS_Thread_Adapter.cpp @@ -15,18 +15,18 @@ ACE_OS_Thread_Adapter::ACE_OS_Thread_Adapter ( ACE_THR_FUNC user_func , void *arg , ACE_THR_C_FUNC entry_point -# if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) +#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) , ACE_SEH_EXCEPT_HANDLER selector , ACE_SEH_EXCEPT_HANDLER handler -# endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ +#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ , long cancel_flags ) : ACE_Base_Thread_Adapter (user_func, arg, entry_point , 0 -# if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) +#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) , selector , handler -# endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ +#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ , cancel_flags ) { diff --git a/ACE/ace/OS_Thread_Adapter.h b/ACE/ace/OS_Thread_Adapter.h index dc994327dc8..a03c361ef4c 100644 --- a/ACE/ace/OS_Thread_Adapter.h +++ b/ACE/ace/OS_Thread_Adapter.h @@ -44,10 +44,10 @@ public: ACE_OS_Thread_Adapter (ACE_THR_FUNC user_func, void *arg, ACE_THR_C_FUNC entry_point = (ACE_THR_C_FUNC) ACE_THREAD_ADAPTER_NAME -# if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) +#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) , ACE_SEH_EXCEPT_HANDLER selector = 0 , ACE_SEH_EXCEPT_HANDLER handler = 0 -# endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ +#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ , long cancel_flags = 0 ); diff --git a/ACE/ace/Thread_Adapter.h b/ACE/ace/Thread_Adapter.h index a0e6fe6a5e4..8bcda99d7ea 100644 --- a/ACE/ace/Thread_Adapter.h +++ b/ACE/ace/Thread_Adapter.h @@ -50,10 +50,10 @@ public: ACE_THR_C_FUNC entry_point = (ACE_THR_C_FUNC) ACE_THREAD_ADAPTER_NAME, ACE_Thread_Manager *thr_mgr = 0, ACE_Thread_Descriptor *td = 0 -# if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) +#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) , ACE_SEH_EXCEPT_HANDLER selector = 0, ACE_SEH_EXCEPT_HANDLER handler = 0 -# endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ +#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ , long cancel_flags = 0 ); -- cgit v1.2.1