From 5472511ddca879e6c1b63d4832d36ebb9ca1b70a Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Fri, 30 May 2008 00:48:06 +0000 Subject: [PATCH] 2008-05-30 02:48 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbvm.h * harbour/source/vm/hvm.c * harbour/source/vm/extrap.c * moved code to set exception handler from hvm.c to extrap.c + added void hb_vmSetExceptionHandler( void ) to set exception filter ! fixed problem with C++ builds caused by missing extern "C" declaration for exception handlers in extrap.c --- harbour/ChangeLog | 10 ++++++++++ harbour/include/hbvm.h | 2 ++ harbour/source/vm/extrap.c | 24 ++++++++++++++++++++++++ harbour/source/vm/hvm.c | 38 +------------------------------------- 4 files changed, 37 insertions(+), 37 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 6c0e40c0ca..856760295a 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,16 @@ 2008-12-31 13:59 UTC+0100 Foo Bar */ +2008-05-30 02:48 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbvm.h + * harbour/source/vm/hvm.c + * harbour/source/vm/extrap.c + * moved code to set exception handler from hvm.c to extrap.c + + added void hb_vmSetExceptionHandler( void ) to set exception + filter + ! fixed problem with C++ builds caused by missing extern "C" + declaration for exception handlers in extrap.c + 2008-05-30 01:54 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * contrib/make_b32_all.bat * contrib/make_vc_all.bat diff --git a/harbour/include/hbvm.h b/harbour/include/hbvm.h index 0adcb4907d..6f4fa0ee97 100644 --- a/harbour/include/hbvm.h +++ b/harbour/include/hbvm.h @@ -99,6 +99,8 @@ extern HB_EXPORT PHB_SYMB hb_vmProcessSymbolsEx( PHB_SYMB pSymbols, USHORT uiSym extern void hb_vmEnumRelease( PHB_ITEM pBase, PHB_ITEM pValue ); #endif +extern void hb_vmSetExceptionHandler( void ); + extern HB_EXPORT void hb_vmSymbolInit_RT( void ); /* initialization of runtime support symbols */ /* Harbour virtual machine escaping API */ diff --git a/harbour/source/vm/extrap.c b/harbour/source/vm/extrap.c index c651ea4a25..f9aab727f3 100644 --- a/harbour/source/vm/extrap.c +++ b/harbour/source/vm/extrap.c @@ -53,6 +53,7 @@ #define HB_OS_WIN_32_USED #include "hbapi.h" +#include "hbvm.h" #include "hbapifs.h" #include "hbdate.h" @@ -145,3 +146,26 @@ ULONG _System hb_os2ExceptionHandler( PEXCEPTIONREPORTRECORD p1, } #endif + +void hb_vmSetExceptionHandler( void ) +{ +#if defined(HB_OS_WIN_32) + { + LPTOP_LEVEL_EXCEPTION_FILTER ef = SetUnhandledExceptionFilter( hb_win32ExceptionHandler ); + HB_SYMBOL_UNUSED( ef ); + } +#elif defined(HB_OS_OS2) /* Add OS2TermHandler to this thread's chain of exception handlers */ + { + EXCEPTIONREGISTRATIONRECORD RegRec; /* Exception Registration Record */ + APIRET rc; /* Return code */ + + memset( &RegRec, 0, sizeof( RegRec ) ); + RegRec.ExceptionHandler = ( ERR ) hb_os2ExceptionHandler; + rc = DosSetExceptionHandler( &RegRec ); + if( rc != NO_ERROR ) + { + hb_errInternal( HB_EI_ERRUNRECOV, "Unable to setup exception handler (DosSetExceptionHandler())", NULL, NULL ); + } + } +#endif +} diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index 118b879d6b..8579daed97 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -66,8 +66,6 @@ * */ -#define HB_OS_WIN_32_USED /* for exception handler */ - #include #include @@ -96,22 +94,6 @@ #include "hbpp.h" #endif -HB_EXTERN_BEGIN - -#if defined(HB_OS_WIN_32) - LONG WINAPI hb_win32ExceptionHandler( struct _EXCEPTION_POINTERS * ExceptionInfo ); -#elif defined(HB_OS_OS2) - /* 21/10/00 - maurilio.longo@libero.it - This Exception Handler gets called in case of an abnormal termination of an harbour program and - displays a full stack trace at the harbour language level */ - extern ULONG _System hb_os2ExceptionHandler(PEXCEPTIONREPORTRECORD p1, - PEXCEPTIONREGISTRATIONRECORD p2, - PCONTEXTRECORD p3, - PVOID pv); -#endif - -HB_EXTERN_END - /* DEBUG only*/ /* #include */ @@ -488,25 +470,7 @@ HB_EXPORT void hb_vmInit( BOOL bStartMainProc ) #endif } -#if defined(HB_OS_WIN_32) - { - LPTOP_LEVEL_EXCEPTION_FILTER ef = SetUnhandledExceptionFilter( hb_win32ExceptionHandler ); - HB_SYMBOL_UNUSED( ef ); - } -#elif defined(HB_OS_OS2) /* Add OS2TermHandler to this thread's chain of exception handlers */ - { - EXCEPTIONREGISTRATIONRECORD RegRec; /* Exception Registration Record */ - APIRET rc; /* Return code */ - - memset( &RegRec, 0, sizeof( RegRec ) ); - RegRec.ExceptionHandler = ( ERR ) hb_os2ExceptionHandler; - rc = DosSetExceptionHandler( &RegRec ); - if( rc != NO_ERROR ) - { - hb_errInternal( HB_EI_ERRUNRECOV, "Unable to setup exception handler (DosSetExceptionHandler())", NULL, NULL ); - } - } -#endif + hb_vmSetExceptionHandler(); if( bStartMainProc && s_pSymStart ) {