]> OCCT Git - occt-copy.git/commitdiff
Added DRAW command dsetsignal, allowing to reset OSD signal handler with either armed... CR0_CR26329_abv
authorabv <abv@opencascade.com>
Sun, 21 Aug 2016 07:02:33 +0000 (10:02 +0300)
committerabv <abv@opencascade.com>
Sun, 21 Aug 2016 07:02:33 +0000 (10:02 +0300)
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.

src/Draw/Draw.cxx
src/Draw/Draw_BasicCommands.cxx
src/Draw/Draw_Window.cxx
src/DrawResources/DrawDefault
tests/bugs/fclasses/bug6143

index c09b7971bdbd82151c12c623f644e18938906978..7394dc8f43dc1be6c2ad8471bf118b20fed1a242 100644 (file)
@@ -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
index 0fda933618cc69100ddf50acff11ee5c318e5605..6774c8920ff5444a05186a5a902738df30e3c132 100644 (file)
@@ -25,6 +25,7 @@
 #include <Message_Messenger.hxx>
 #include <OSD.hxx>
 #include <OSD_Chronometer.hxx>
+#include <OSD_Environment.hxx>
 #include <OSD_Exception_CTRL_BREAK.hxx>
 #include <OSD_MAllocHook.hxx>
 #include <OSD_MemInfo.hxx>
@@ -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!
index 1ebb52390668beb6e5ccee9979184a249785bb36..1948e0aca62c01ef9c4e41ed8dfe8ee2bc343540 100644 (file)
@@ -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;
index bb37408e5a890f471f7ba183d9105778809cc33e..d5973b8283cc9a54f7f91c121871c9f93791dc43 100755 (executable)
@@ -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
index 4f6efef41a3e0ca5ae2cbd900bd14d2e1898fc34..a3bbb06c77f4e17480eef6b41ccf53ba79e42b6f 100644 (file)
@@ -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}"