debugger: manual pause added 35/21635/2
Cedric Delamarre [Mon, 7 Dec 2020 13:34:21 +0000 (14:34 +0100)]
Change-Id: I7a37610d260d1911abf4f4da6744d462a60d7f12

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

index 869800b..ebef8aa 100644 (file)
@@ -67,6 +67,7 @@ private:
 
     ast::Exp* pExp;
     bool interrupted;
+    bool request_pause;
     int currentBreakPoint;
     DebugAction action;
     int level;
@@ -276,6 +277,9 @@ public:
     void show(int bp); //print the breakpoint bp or all breakpoints (bp = -1)
     void resume(); //resume execution
     void abort(); //abort execution
+    void requestPause(); //pause execution
+    bool isPauseRequested(); //get pause request status
+    void resetPauseRequest(); //reset pause request status
 };
 
 }
index 38d67da..ff1d6ec 100644 (file)
@@ -69,7 +69,8 @@ void DebuggerVisitor::visit(const SeqExp  &e)
 
         //debugger check !
         int iBreakPoint = -1;
-        if (ConfigVariable::getEnableDebug())
+        if (ConfigVariable::getEnableDebug() &&
+            manager->isInterrupted() == false) // avoid stopping execution if an execution is already paused
         {
             bool stopExecution = false;
             if (manager->isStepIn())
@@ -224,8 +225,9 @@ void DebuggerVisitor::visit(const SeqExp  &e)
                 }
             }
 
-            if(stopExecution)
+            if(stopExecution || manager->isPauseRequested())
             {
+                manager->resetPauseRequest();
                 manager->stop(exp, iBreakPoint);
                 if (manager->isAborted())
                 {
index 60f4f82..26ea968 100644 (file)
@@ -442,6 +442,24 @@ void DebuggerManager::resume() //resume execution
     }
 }
 
+void DebuggerManager::requestPause() //ask for pause
+{
+    // pause on execution only if a command is running
+    if(interrupted == false) {
+        request_pause = true;
+    }
+}
+
+bool DebuggerManager::isPauseRequested() //pause execution
+{
+    return request_pause;
+}
+
+void DebuggerManager::resetPauseRequest() //pause execution
+{
+    request_pause = false;
+}
+
 void DebuggerManager::abort() //abort execution
 {
     //inform debuggers
index a319e20..bf8ec20 100644 (file)
@@ -83,6 +83,7 @@ public:
     static void setRunner(Runner* _RunMe);
     static Runner* getRunner(void);
     static bool isRunnerAvailable(void);
+    static bool isRunning(void);
     static bool isInterruptibleCommand(void);
     static command_origin_t getCommandOrigin();
     static void execAndWait(ast::Exp* _theProgram, ast::RunVisitor *_visitor,
index 1e47105..dede1be 100644 (file)
@@ -228,6 +228,12 @@ bool StaticRunner::isRunnerAvailable(void)
     return m_RunMe.load() != nullptr;
 }
 
+// return true if a command is running or paused.
+bool StaticRunner::isRunning(void)
+{
+    return m_CurrentRunner.load() != nullptr;
+}
+
 bool StaticRunner::isInterruptibleCommand()
 {
     return m_CurrentRunner.load()->isInterruptible();