changeset 27402:84d11fcb2f91

also check debugger execution mode after command editor interrupt * pt-eval.cc (debugger::quitting_debugger): New function. (debugger::repl): Use it to perform same action if the command editor has been interrupted as when we are restarting the debugger read-eval-print loop.
author John W. Eaton <jwe@octave.org>
date Fri, 13 Sep 2019 07:24:17 -0400
parents 1f595192b5a5
children 27967cb3dea5
files libinterp/parse-tree/pt-eval.cc
diffstat 1 files changed, 42 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-eval.cc	Thu Sep 12 17:13:28 2019 -0400
+++ b/libinterp/parse-tree/pt-eval.cc	Fri Sep 13 07:24:17 2019 -0400
@@ -123,6 +123,8 @@
         m_execution_mode = EX_QUIT;
     }
 
+    bool quitting_debugger (void) const;
+
   private:
 
     interpreter& m_interpreter;
@@ -256,27 +258,8 @@
         if (m_execution_mode == EX_CONTINUE || tw.dbstep_flag ())
           break;
 
-        if (m_execution_mode == EX_QUIT)
-          {
-            // If there is no enclosing debug level or the top-level
-            // repl is not active, handle dbquit the same as dbcont.
-
-            if (m_level > 0 || tw.in_top_level_repl ())
-              throw quit_debug_exception ();
-            else
-              break;
-          }
-
-        if (m_execution_mode == EX_QUIT_ALL)
-          {
-            // If the top-level repl is not active, handle "dbquit all"
-            // the same as dbcont.
-
-            if (tw.in_top_level_repl ())
-              throw quit_debug_exception (true);
-            else
-              break;
-          }
+        if (quitting_debugger ())
+          break;
 
         try
           {
@@ -289,7 +272,13 @@
             int retval = curr_parser.run ();
 
             if (command_editor::interrupt (false))
-              break;
+              {
+                // Break regardless of m_execution_mode value.
+
+                quitting_debugger ();
+
+                break;
+              }
             else
               {
                 if (retval == 0 && curr_parser.m_stmt_list)
@@ -334,6 +323,37 @@
       }
   }
 
+  bool debugger::quitting_debugger (void) const
+  {
+    if (m_execution_mode == EX_QUIT)
+      {
+        // If there is no enclosing debug level or the top-level
+        // repl is not active, handle dbquit the same as dbcont.
+
+        tree_evaluator& tw = m_interpreter.get_evaluator ();
+
+        if (m_level > 0 || tw.in_top_level_repl ())
+          throw quit_debug_exception ();
+        else
+          return true;
+      }
+
+    if (m_execution_mode == EX_QUIT_ALL)
+      {
+        // If the top-level repl is not active, handle "dbquit all"
+        // the same as dbcont.
+
+        tree_evaluator& tw = m_interpreter.get_evaluator ();
+
+        if (tw.in_top_level_repl ())
+          throw quit_debug_exception (true);
+        else
+          return true;
+      }
+
+    return false;
+  }
+
   bool tree_evaluator::at_top_level (void) const
   {
     return m_call_stack.at_top_level ();