Debugger fixed about command interruption by another one 85/21285/4
Cedric Delamarre [Thu, 6 Feb 2020 09:43:32 +0000 (10:43 +0100)]
    It was not possible to execute a command if an "interrupted" one
    was already running and launched by the debugger.

Change-Id: Icfd4c9da61cf4521cc4ac3a3e67f17f6160976fa

scilab/modules/ast/src/cpp/ast/debuggervisitor.cpp
scilab/modules/ast/src/cpp/ast/run_SeqExp.hpp
scilab/modules/core/includes/runner.hxx
scilab/modules/core/src/cpp/runner.cpp

index 3a87874..d531309 100644 (file)
@@ -21,6 +21,7 @@
 #include "macrofile.hxx"
 #include "commentexp.hxx"
 #include "UTF8.hxx"
+#include "runner.hxx"
 
 extern "C"
 {
@@ -222,6 +223,17 @@ void DebuggerVisitor::visit(const SeqExp  &e)
             }
         }
 
+        // interrupt me to execute a prioritary command
+        while (StaticRunner_isInterruptibleCommand() == 1 && StaticRunner_isRunnerAvailable() == 1)
+        {
+            // save the origin of the actual running command
+            command_origin_t origin = StaticRunner_getCurrentCommandOrigin();
+            StaticRunner_launch();
+            StaticRunner_setInterruptibleCommand(1);
+            // restore the origin of the actual running command
+            StaticRunner_setCurrentCommandOrigin(origin);
+        }
+
         //copy from runvisitor::seqexp
         try
         {
index 9b1e9e9..8429c39 100644 (file)
@@ -65,8 +65,12 @@ void RunVisitorT<T>::visitprivate(const SeqExp  &e)
         // interrupt me to execute a prioritary command
         while (StaticRunner_isInterruptibleCommand() == 1 && StaticRunner_isRunnerAvailable() == 1)
         {
+            // save the origin of the actual running command
+            command_origin_t origin = StaticRunner_getCurrentCommandOrigin();
             StaticRunner_launch();
             StaticRunner_setInterruptibleCommand(1);
+            // restore the origin of the actual running command
+            StaticRunner_setCurrentCommandOrigin(origin);
         }
 
         if (file)
index 95cfc19..5da7cae 100644 (file)
@@ -58,6 +58,11 @@ public :
         return m_iCommandOrigin;
     }
 
+    void setCommandOrigin(command_origin_t _origin)
+    {
+        m_iCommandOrigin = _origin;
+    }
+
     bool isInterruptible()
     {
         return m_isInterruptible;
@@ -83,6 +88,8 @@ public:
     static bool isInterruptibleCommand(void);
     static void setInterruptibleCommand(bool _isInterruptible);
     static command_origin_t getCommandOrigin();
+    static command_origin_t getCurrentCommandOrigin();
+    static void setCurrentCommandOrigin(command_origin_t _origin);
     static void execAndWait(ast::Exp* _theProgram, ast::RunVisitor *_visitor,
                             bool _isInterruptible, bool _isPrioritary, command_origin_t _iCommandOrigin);
     static bool exec(ast::Exp* _theProgram, ast::RunVisitor *_visitor);
@@ -101,6 +108,8 @@ extern "C"
     int StaticRunner_isInterruptibleCommand(void);
     void StaticRunner_setInterruptibleCommand(int val);
     command_origin_t StaticRunner_getCommandOrigin(void);
+    command_origin_t StaticRunner_getCurrentCommandOrigin(void);
+    void StaticRunner_setCurrentCommandOrigin(command_origin_t origin);
 }
 
 #endif /* !__RUNNER_HXX__ */
index 7ba5cde..08edaaa 100644 (file)
@@ -243,6 +243,16 @@ command_origin_t StaticRunner::getCommandOrigin()
     return m_RunMe.load()->getCommandOrigin();
 }
 
+command_origin_t StaticRunner::getCurrentCommandOrigin()
+{
+    return m_CurrentRunner.load()->getCommandOrigin();
+}
+
+void StaticRunner::setCurrentCommandOrigin(command_origin_t origin)
+{
+    m_CurrentRunner.load()->setCommandOrigin(origin);
+}
+
 void StaticRunner::execAndWait(ast::Exp* _theProgram, ast::RunVisitor *_visitor,
                                bool /*_isPrioritaryThread*/, bool _isInterruptible, command_origin_t _iCommandOrigin)
 {
@@ -304,3 +314,13 @@ command_origin_t StaticRunner_getCommandOrigin(void)
 {
     return StaticRunner::getCommandOrigin();
 }
+
+command_origin_t StaticRunner_getCurrentCommandOrigin(void)
+{
+    return StaticRunner::getCurrentCommandOrigin();
+}
+
+void StaticRunner_setCurrentCommandOrigin(command_origin_t _origin)
+{
+    StaticRunner::setCurrentCommandOrigin(_origin);
+}