diff options
author | Frank Schoenheit [fs] <frank.schoenheit@oracle.com> | 2011-02-20 23:09:26 +0100 |
---|---|---|
committer | Frank Schoenheit [fs] <frank.schoenheit@oracle.com> | 2011-02-20 23:09:26 +0100 |
commit | b9d0151272d0d7653e8bf307295b6696ea7ea491 (patch) | |
tree | 7a64be52b62b28dcc533da3717bed09402ca8f78 /sal/osl | |
parent | 9188c6bcb042e676cc230cec9c0e637dae46b344 (diff) |
debuglevels: #i116845# on assertions, don't/call osl_osl_breakDebug depending on an environemnt variable SAL_DIAGNOSE_ABORT.
On Unix, osl_breakDebug was previously implemented as exit(0), but never called (since osl_assertFailedLine always
returned sal_False). It is now implemented as "abort".
On Windows, osl_debugBreak was implemented as DebugBreak, which fits our intention of always aborting on an assertion,
given that SAL_DIAGNOSE_ABORT is set.
On OS/2 (is this an active port?), osl_debugBreak is implemented as calling "int 3" - which is quite old-fashioned,
but should also do what we want.
Diffstat (limited to 'sal/osl')
-rw-r--r-- | sal/osl/os2/diagnose.c | 3 | ||||
-rw-r--r-- | sal/osl/unx/diagnose.c | 14 | ||||
-rwxr-xr-x | sal/osl/w32/diagnose.c | 66 |
3 files changed, 48 insertions, 35 deletions
diff --git a/sal/osl/os2/diagnose.c b/sal/osl/os2/diagnose.c index eabb3eae5..8d63e2daa 100644 --- a/sal/osl/os2/diagnose.c +++ b/sal/osl/os2/diagnose.c @@ -124,7 +124,8 @@ sal_Bool SAL_CALL osl_assertFailedLine( const sal_Char* pszFileName, sal_Int32 n fputs(szMessage, stderr); - return sal_True; /* abort */ + char const * env = getenv( "SAL_DIAGNOSE_ABORT" ); + return ( ( env != NULL ) && ( *env != '\0' ) ); } /*----------------------------------------------------------------------------*/ diff --git a/sal/osl/unx/diagnose.c b/sal/osl/unx/diagnose.c index 07341e1ec..b4baf647f 100644 --- a/sal/osl/unx/diagnose.c +++ b/sal/osl/unx/diagnose.c @@ -218,6 +218,11 @@ sal_Bool SAL_CALL osl_assertFailedLine ( oslDebugMessageFunc f = g_pDebugMessageFunc; char szMessage[1024]; + // after reporting the assertion, abort if told so by SAL_DIAGNOSE_ABORT, but *not* if + // assertions are routed to some external instance + char const * env = getenv( "SAL_DIAGNOSE_ABORT" ); + sal_Bool const doAbort = ( ( env != NULL ) && ( *env != '\0' ) && ( f == NULL ) ); + /* If there's a callback for detailed messages, use it */ if ( g_pDetailedDebugMessageFunc != NULL ) { @@ -227,7 +232,7 @@ sal_Bool SAL_CALL osl_assertFailedLine ( /* if SAL assertions are disabled in general, stop here */ if ( getenv("DISABLE_SAL_DBGBOX") ) - return sal_False; + return doAbort; /* format message into buffer */ if (pszMessage != 0) @@ -252,9 +257,10 @@ sal_Bool SAL_CALL osl_assertFailedLine ( /* output backtrace */ osl_diagnose_backtrace_Impl(f); - /* release lock and leave, w/o calling osl_breakDebug() */ + /* release lock and leave */ pthread_mutex_unlock(&g_mutex); - return sal_False; + + return doAbort; } /************************************************************************/ @@ -262,7 +268,7 @@ sal_Bool SAL_CALL osl_assertFailedLine ( /************************************************************************/ void SAL_CALL osl_breakDebug() { - exit(0); + abort(); } /************************************************************************/ diff --git a/sal/osl/w32/diagnose.c b/sal/osl/w32/diagnose.c index 97fe8d275..0e1f1d864 100755 --- a/sal/osl/w32/diagnose.c +++ b/sal/osl/w32/diagnose.c @@ -93,6 +93,7 @@ sal_Bool SAL_CALL osl_assertFailedLine(const sal_Char* pszFileName, sal_Int32 nL /* get app name or NULL if unknown (don't call assert) */ LPCSTR lpszAppName = "Error"; sal_Char szMessage[512]; + char const * env = getenv( "SAL_DIAGNOSE_ABORT" ); /* format message into buffer */ szMessage[sizeof(szMessage)-1] = '\0'; /* zero terminate always */ @@ -105,39 +106,44 @@ sal_Bool SAL_CALL osl_assertFailedLine(const sal_Char* pszFileName, sal_Int32 nL _pPrintDetailedDebugMessage( pszFileName, nLine, pszMessage ); else if ( _pPrintDebugMessage ) _pPrintDebugMessage( szMessage ); - else if ( !getenv( "DISABLE_SAL_DBGBOX" ) ) + else { - TCHAR szBoxMessage[1024]; - - /* active popup window for the current thread */ - hWndParent = GetActiveWindow(); - if (hWndParent != NULL) - hWndParent = GetLastActivePopup(hWndParent); - - /* set message box flags */ - nFlags = MB_TASKMODAL | MB_ICONWARNING | MB_YESNOCANCEL | MB_DEFBUTTON2 | MB_SETFOREGROUND; - if (hWndParent == NULL) - nFlags |= MB_SERVICE_NOTIFICATION; - - /* display the assert */ - - szBoxMessage[sizeof(szBoxMessage)-1] = 0; - _snprintf(szBoxMessage, sizeof(szBoxMessage)-1, "%s\n( Yes=Abort / No=Ignore / Cancel=Debugger )", - szMessage); - - nCode = MessageBox(hWndParent, szBoxMessage, "Assertion Failed!", nFlags); - - if (nCode == IDYES) - FatalExit(-1); - - if (nCode == IDNO) - return sal_False; /* ignore */ - - if (nCode == IDCANCEL) - return sal_True; /* will cause oslDebugBreak */ + if ( !getenv( "DISABLE_SAL_DBGBOX" ) ) + { + TCHAR szBoxMessage[1024]; + + /* active popup window for the current thread */ + hWndParent = GetActiveWindow(); + if (hWndParent != NULL) + hWndParent = GetLastActivePopup(hWndParent); + + /* set message box flags */ + nFlags = MB_TASKMODAL | MB_ICONWARNING | MB_YESNOCANCEL | MB_DEFBUTTON2 | MB_SETFOREGROUND; + if (hWndParent == NULL) + nFlags |= MB_SERVICE_NOTIFICATION; + + /* display the assert */ + + szBoxMessage[sizeof(szBoxMessage)-1] = 0; + _snprintf(szBoxMessage, sizeof(szBoxMessage)-1, "%s\n( Yes=Abort / No=Ignore / Cancel=Debugger )", + szMessage); + + nCode = MessageBox(hWndParent, szBoxMessage, "Assertion Failed!", nFlags); + + if (nCode == IDYES) + FatalExit(-1); + + if (nCode == IDNO) + return sal_False; /* ignore */ + + if (nCode == IDCANCEL) + return sal_True; /* will cause oslDebugBreak */ + } + return ( ( env != NULL ) && ( *env != '\0' ) ); } + + return sal_False; #endif /* NO_DEBUG_CRT */ - return sal_False; /* not shure, not care */ } sal_Int32 SAL_CALL osl_reportError(sal_uInt32 nType, const sal_Char* pszMessage) |