changeset 27222:f5b967060442

ensure debuger_stack is popped when exiting a debug level (bug #56150) * debug.cc (Fdbquit): Set debug_mode and throw interrupt exception. * pt-eval.cc (tree_evaluator::enter_debugger): Add action to unwind_protect frame to pop and delete debugger object from m_debugger_stack.
author John W. Eaton <jwe@octave.org>
date Thu, 04 Jul 2019 10:27:57 -0400
parents 0fe52ad36b24
children 1ae91e5d70cc
files libinterp/corefcn/debug.cc libinterp/parse-tree/pt-eval.cc
diffstat 2 files changed, 9 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/debug.cc	Mon Jul 01 18:05:46 2019 -0400
+++ b/libinterp/corefcn/debug.cc	Thu Jul 04 10:27:57 2019 -0400
@@ -1164,7 +1164,9 @@
   if (args.length () != 0)
     print_usage ();
 
-  tw.abort_debug_repl (true);
+  tw.debug_mode (false);
+
+  throw octave::interrupt_exception ();
 
   return ovl ();
 }
--- a/libinterp/parse-tree/pt-eval.cc	Mon Jul 01 18:05:46 2019 -0400
+++ b/libinterp/parse-tree/pt-eval.cc	Thu Jul 04 10:27:57 2019 -0400
@@ -1126,6 +1126,12 @@
 
     m_debugger_stack.push (dbgr);
 
+    frame.add ([this] (void)
+               {
+                 delete m_debugger_stack.top ();
+                 m_debugger_stack.pop ();
+               });
+
     dbgr->repl (prompt);
   }
 
@@ -4412,19 +4418,11 @@
         if (curr_debugger->exit_debug_repl ())
           {
             // This action corresponds to dbcont.
-
-            m_debugger_stack.pop ();
-            delete curr_debugger;
-
             reset_debug_state ();
           }
         else if (curr_debugger->abort_debug_repl ())
           {
             // This action corresponds to dbquit.
-
-            m_debugger_stack.pop ();
-            delete curr_debugger;
-
             debug_mode (false);
 
             throw interrupt_exception ();