changeset 27205:6648d1ae05fe

eliminate direct access to call stack in debug functions * debug.cc (Fdbwhere, Fdblist, do_dbstack, do_dbupdown): Eliminate direct access to call stack.
author John W. Eaton <jwe@octave.org>
date Mon, 01 Apr 2019 18:28:44 +0000
parents 9a3e92d02a03
children 4e4a9d7b436e
files libinterp/corefcn/debug.cc libinterp/parse-tree/pt-eval.cc libinterp/parse-tree/pt-eval.h
diffstat 3 files changed, 33 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/debug.cc	Mon Apr 01 18:21:27 2019 +0000
+++ b/libinterp/corefcn/debug.cc	Mon Apr 01 18:28:44 2019 +0000
@@ -36,7 +36,6 @@
 #include "dNDArray.h"
 
 #include "bp-table.h"
-#include "call-stack.h"
 #include "defun.h"
 #include "error.h"
 #include "errwarn.h"
@@ -567,11 +566,9 @@
 @seealso{dbstack, dblist, dbstatus, dbcont, dbstep, dbup, dbdown}
 @end deftypefn */)
 {
-  octave::call_stack& cs = interp.get_call_stack ();
+  octave::tree_evaluator& tw = interp.get_evaluator ();
 
-  octave::stack_frame *frm = cs.current_user_frame ();
-
-  frm->display_stopped_in_message (octave_stdout);
+  tw.debug_where (octave_stdout);
 
   return ovl ();
 }
@@ -805,9 +802,7 @@
       name = dbg_fcn->name ();
     }
 
-  octave::call_stack& cs = interp.get_call_stack ();
-
-  int l = cs.debug_user_code_line ();
+  int l = tw.debug_user_code_line ();
 
   if (l > 0)
     {
@@ -880,11 +875,11 @@
         nskip = n;
     }
 
-  octave::call_stack& cs = interp.get_call_stack ();
+  octave::tree_evaluator& tw = interp.get_evaluator ();
 
   if (nargout == 0)
     {
-      octave_map stk = cs.backtrace (curr_frame);
+      octave_map stk = tw.backtrace (curr_frame);
       octave_idx_type nframes = stk.numel ();
 
       if (nframes > 0)
@@ -924,13 +919,13 @@
                  << std::endl;
             }
 
-          if (cs.at_top_level () && show_top_level)
+          if (tw.at_top_level () && show_top_level)
             os << "  --> top level" << std::endl;
         }
     }
   else
     {
-      octave_map stk = cs.backtrace (curr_frame, false);
+      octave_map stk = tw.backtrace (curr_frame, false);
 
       // If current stack frame is not in the list curr_frame will be
       // -1 and either nskip caused us to skip it or we are at the top
--- a/libinterp/parse-tree/pt-eval.cc	Mon Apr 01 18:21:27 2019 +0000
+++ b/libinterp/parse-tree/pt-eval.cc	Mon Apr 01 18:28:44 2019 +0000
@@ -1864,18 +1864,33 @@
     return false;
   }
 
-  // Current line in current function.
   int tree_evaluator::current_line (void) const
   {
     return m_call_stack.current_line ();
   }
 
-  // Current column in current function.
   int tree_evaluator::current_column (void) const
   {
     return m_call_stack.current_column ();
   }
 
+  int tree_evaluator::debug_user_code_line (void) const
+  {
+    return m_call_stack.debug_user_code_line ();
+  }
+
+  int tree_evaluator::debug_user_code_column (void) const
+  {
+    return m_call_stack.debug_user_code_column ();
+  }
+
+  void tree_evaluator::debug_where (std::ostream& os) const
+  {
+    stack_frame *frm = m_call_stack.current_user_frame ();
+
+    frm->display_stopped_in_message (os);
+  }
+
   octave_user_code * tree_evaluator::current_user_code (void) const
   {
     return m_call_stack.current_user_code ();
--- a/libinterp/parse-tree/pt-eval.h	Mon Apr 01 18:21:27 2019 +0000
+++ b/libinterp/parse-tree/pt-eval.h	Mon Apr 01 18:28:44 2019 +0000
@@ -25,6 +25,7 @@
 
 #include "octave-config.h"
 
+#include <iosfwd>
 #include <list>
 #include <set>
 #include <stack>
@@ -486,6 +487,14 @@
     // Current column in current function.
     int current_column (void) const;
 
+    // Line number in current function that we are debugging.
+    int debug_user_code_line (void) const;
+
+    // Column number in current function that we are debugging.
+    int debug_user_code_column (void) const;
+
+    void debug_where (std::ostream& os) const;
+
     octave_user_code * current_user_code (void) const;
 
     unwind_protect * curr_fcn_unwind_protect_frame (void) const;