From: abv Date: Sun, 21 Aug 2016 07:02:33 +0000 (+0300) Subject: Added DRAW command dsetsignal, allowing to reset OSD signal handler with either armed... X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2FCR0_CR26329_abv;p=occt-copy.git Added DRAW command dsetsignal, allowing to reset OSD signal handler with either armed or disabled FPE handler. If called without arguments, it sets FPE handler only if environment variable OSD_FPE is defined (with value different from 0). On start, DRAW calls dsetsignal to set FPE signal if CSF_FPE is defined. Test bugs fclasses bug6143 uses dsetsignal to set FPE handler unconditionally before test execution. --- diff --git a/src/Draw/Draw.cxx b/src/Draw/Draw.cxx index c09b7971bd..7394dc8f43 100644 --- a/src/Draw/Draw.cxx +++ b/src/Draw/Draw.cxx @@ -243,12 +243,7 @@ void Draw_Appli(Standard_Integer argc, char** argv,const FDraw_InitAppli Draw_In // ***************************************************************** // set signals // ***************************************************************** -#if defined(__INTEL_COMPILER) || defined(__clang__) - // FPE signals are disabled for Intel compiler (see #24589) and CLang (see #23802) OSD::SetSignal(Standard_False); -#else - OSD::SetSignal(); -#endif #ifdef _WIN32 // in interactive mode, force Windows to report dll loading problems interactively diff --git a/src/Draw/Draw_BasicCommands.cxx b/src/Draw/Draw_BasicCommands.cxx index 0fda933618..6774c8920f 100644 --- a/src/Draw/Draw_BasicCommands.cxx +++ b/src/Draw/Draw_BasicCommands.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -740,6 +741,31 @@ static int dperf (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char return 0; } +//============================================================================== +//function : dsetsignal +//purpose : +//============================================================================== + +static int dsetsignal (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec) +{ + // arm FPE handler if argument is provided and its first symbol is not '0' + // or if environment variable CSF_FPE is set and its first symbol is not '0' + bool setFPE = false; + if (theArgNb > 1 && theArgVec[1][0] != '0' && theArgVec[1][0] != '\0') + { + setFPE = true; + } + else + { + OSD_Environment aEnv ("CSF_FPE"); + TCollection_AsciiString aEnvStr = aEnv.Value(); + setFPE = (! aEnvStr.IsEmpty() && aEnvStr.Value(1) != '0'); + } + OSD::SetSignal (setFPE); + theDI << "Signal handlers are set, with FPE " << (setFPE ? "armed" : "disarmed"); + return 0; +} + //============================================================================== //function : dtracelevel //purpose : @@ -864,6 +890,8 @@ void Draw::BasicCommands(Draw_Interpretor& theCommands) __FILE__, dmeminfo, g); theCommands.Add("dperf","dperf [reset] -- show performance counters, reset if argument is provided", __FILE__,dperf,g); + theCommands.Add("dsetsignal","dsetsignal [fpe=0] -- set OSD signal handler, with FPE option if argument is given", + __FILE__,dsetsignal,g); // Logging commands; note that their names are hard-coded in the code // of Draw_Interpretor, thus should not be changed without update of that code! diff --git a/src/Draw/Draw_Window.cxx b/src/Draw/Draw_Window.cxx index 1ebb523906..1948e0aca6 100644 --- a/src/Draw/Draw_Window.cxx +++ b/src/Draw/Draw_Window.cxx @@ -2110,12 +2110,7 @@ static DWORD WINAPI tkLoop(VOID) #endif //#ifdef _TK // set signal handler in the new thread -#if defined(__INTEL_COMPILER) || defined(__clang__) - // FPE signals are disabled for Intel compiler (see #24589) and CLang (see #23802) OSD::SetSignal(Standard_False); -#else - OSD::SetSignal(); -#endif // inform the others that we have started isTkLoopStarted = true; diff --git a/src/DrawResources/DrawDefault b/src/DrawResources/DrawDefault index bb37408e5a..d5973b8283 100755 --- a/src/DrawResources/DrawDefault +++ b/src/DrawResources/DrawDefault @@ -125,5 +125,8 @@ if { $tcl_platform(platform) == "windows" && ! [catch {dgetenv PATH}] } { _update_c_env env "" "unset" } +# arm signal handler with default FPE setting +dsetsignal + # silent return from the script return diff --git a/tests/bugs/fclasses/bug6143 b/tests/bugs/fclasses/bug6143 index 4f6efef41a..a3bbb06c77 100644 --- a/tests/bugs/fclasses/bug6143 +++ b/tests/bugs/fclasses/bug6143 @@ -18,14 +18,15 @@ pload QAcommands set BugNumber OCC6143 -set OK_string "TestExcept: Successfull completion\n" +dsetsignal 1 set IsDone [catch {set aResult [OCC6143]} result] +dsetsignal if { ${IsDone} != 0 } { puts "result = ${result}" puts "Faulty ${BugNumber}" } else { - if { [string first ${OK_string} ${aResult} ] != -1 } { + if { [string first "TestExcept: Successfull completion" ${aResult} ] != -1 } { puts "OK ${BugNumber}" } else { puts "Faulty ${BugNumber}"