static ULONG _System hb_os2ExceptionHandler( PEXCEPTIONREPORTRECORD pExceptionInfo, PEXCEPTIONREGISTRATIONRECORD p2, PCONTEXTRECORD pCtx, PVOID pv ) { HB_SYMBOL_UNUSED( p2 ); HB_SYMBOL_UNUSED( pv ); /* Don't print stack trace if inside unwind, normal process termination or process killed or during debugging */ if( pExceptionInfo->ExceptionNum != XCPT_UNWIND && pExceptionInfo->ExceptionNum < XCPT_BREAKPOINT ) { char buffer[ HB_SYMBOL_NAME_LEN + HB_SYMBOL_NAME_LEN + 5 ]; char file[ HB_PATH_MAX ]; HB_USHORT uiLine; int iLevel = 0; fprintf( stderr, HB_I_("\nException %lx at address %p \n"), pExceptionInfo->ExceptionNum, pExceptionInfo->ExceptionAddress ); fprintf( stderr, "\n" " Exception Code:%08X\n" " Exception Address:%08X\n" " EAX:%08X EBX:%08X ECX:%08X EDX:%08X\n" " ESI:%08X EDI:%08X EBP:%08X\n" " CS:EIP:%04X:%08X SS:ESP:%04X:%08X\n" " DS:%04X ES:%04X FS:%04X GS:%04X\n" " Flags:%08X\n", ( HB_U32 ) pExceptionInfo->ExceptionNum, ( HB_U32 ) pExceptionInfo->ExceptionAddress, ( HB_U32 ) pCtx->ctx_RegEax, ( HB_U32 ) pCtx->ctx_RegEbx, ( HB_U32 ) pCtx->ctx_RegEcx, ( HB_U32 ) pCtx->ctx_RegEdx, ( HB_U32 ) pCtx->ctx_RegEsi, ( HB_U32 ) pCtx->ctx_RegEdi, ( HB_U32 ) pCtx->ctx_RegEbp, ( HB_U32 ) pCtx->ctx_SegCs, ( HB_U32 ) pCtx->ctx_RegEip, ( HB_U32 ) pCtx->ctx_SegSs, ( HB_U32 ) pCtx->ctx_RegEsp, ( HB_U32 ) pCtx->ctx_SegDs, ( HB_U32 ) pCtx->ctx_SegEs, ( HB_U32 ) pCtx->ctx_SegFs, ( HB_U32 ) pCtx->ctx_SegGs, ( HB_U32 ) pCtx->ctx_EFlags ); while( hb_procinfo( iLevel++, buffer, &uiLine, file ) ) fprintf( stderr, HB_I_( "Called from %s(%hu)%s%s\n" ), buffer, uiLine, *file ? HB_I_( " in " ) : "", file ); } return hb_cmdargCheck( "BATCH" ) ? XCPT_CONTINUE_STOP : XCPT_CONTINUE_SEARCH /* Exception not resolved... */; }
void hb_errInternalRaw( HB_ERRCODE errCode, const char * szText, const char * szPar1, const char * szPar2 ) { char buffer[ 8192 ]; char file[ HB_PATH_MAX ]; const char * szFile, * szInfo; HB_BOOL fStack, fLang; HB_USHORT uiLine; int iLevel; FILE * hLog; HB_TRACE( HB_TR_DEBUG, ( "hb_errInternal(%d, %s, %s, %s)", errCode, szText, szPar1, szPar2 ) ); if( szPar1 == NULL ) szPar1 = ""; if( szPar2 == NULL ) szPar2 = ""; fStack = hb_stackId() != NULL; fLang = fStack && hb_langID() != NULL; szFile = fStack ? hb_setGetCPtr( HB_SET_HBOUTLOG ) : NULL; if( ! szFile ) szFile = "hb_out.log"; hLog = hb_fopen( szFile, "a+" ); if( hLog ) { char szTime[ 9 ]; int iYear, iMonth, iDay; hb_dateToday( &iYear, &iMonth, &iDay ); hb_dateTimeStr( szTime ); fprintf( hLog, "Application Internal Error - %s\n", hb_cmdargARGVN( 0 ) ); fprintf( hLog, "Terminated at: %04d-%02d-%02d %s\n", iYear, iMonth, iDay, szTime ); szInfo = fStack ? hb_setGetCPtr( HB_SET_HBOUTLOGINFO ) : NULL; if( szInfo && *szInfo ) fprintf( hLog, "Info: %s\n", szInfo ); } hb_conOutErr( hb_conNewLine(), 0 ); if( fLang ) hb_snprintf( buffer, sizeof( buffer ), hb_langDGetItem( HB_LANG_ITEM_BASE_ERRINTR ), errCode ); else hb_snprintf( buffer, sizeof( buffer ), "Unrecoverable error %d: ", errCode ); hb_conOutErr( buffer, 0 ); if( hLog ) fprintf( hLog, "%s", buffer ); if( ! szText && fLang ) szText = hb_langDGetItem( HB_LANG_ITEM_BASE_ERRINTR + errCode - 9000 ); if( szText ) hb_snprintf( buffer, sizeof( buffer ), szText, szPar1, szPar2 ); else buffer[ 0 ] = '\0'; hb_conOutErr( buffer, 0 ); hb_conOutErr( hb_conNewLine(), 0 ); if( hLog ) fprintf( hLog, "%s\n", buffer ); if( fStack && hb_stackTotalItems() ) { iLevel = 0; while( hb_procinfo( iLevel++, buffer, &uiLine, file ) ) { char msg[ HB_SYMBOL_NAME_LEN + HB_SYMBOL_NAME_LEN + 32 ]; hb_snprintf( msg, sizeof( msg ), "Called from %s(%hu)%s%s\n", buffer, uiLine, *file ? " in " : "", file ); hb_conOutErr( msg, 0 ); if( hLog ) fprintf( hLog, "%s", msg ); } } if( hLog ) { fprintf( hLog, "------------------------------------------------------------------------\n" ); fclose( hLog ); } }