changeset 3770:bf6116ca10eb

[project @ 2001-02-02 02:21:40 by jwe]
author jwe
date Fri, 02 Feb 2001 02:21:42 +0000
parents 7c8e3c42ed04
children 0486ba746bc1
files src/ChangeLog src/Makefile.in src/input.h src/ov-usr-fcn.h src/pt-all.h src/pt-assign.cc src/pt-binop.cc src/pt-cell.cc src/pt-cmd.h src/pt-colon.cc src/pt-const.h src/pt-except.cc src/pt-id.cc src/pt-indir.cc src/pt-jump.cc src/pt-loop.cc src/pt-mat.cc src/pt-stmt.cc src/pt-stmt.h src/pt-unop.cc src/pt.h
diffstat 21 files changed, 162 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Wed Jan 31 22:15:55 2001 +0000
+++ b/src/ChangeLog	Fri Feb 02 02:21:42 2001 +0000
@@ -1,3 +1,38 @@
+2001-02-01  Ben Sapp  <bsapp@lanl.gov>
+
+        * DLD-FUNCTIONS/debug.cc: New file.
+        * pt-bp.h, pt-bp.cc: New files, for breakpoints.
+	* Makefile.in: Add them to the appropriate lists.
+
+        * pt-stmt.cc (tree_statement_list::set_breakpoint,
+	tree_statement_list::delete_breakpoint,
+	tree_statement_list::list_breakpoints): New functions.
+
+	* pt.h (tree::break_point): New data member.
+	(tree::set_breakpoint, tree::delete_breakpoint, tree::is_breakpoint):
+	New virtual functions.
+
+	* pt-mat.cc (tree_matrix::rvalue): Check for breakpoint here.
+	* pt-unop.cc (tree_prefix_expression::rvalue): Likewise.
+	(tree_postfix_expression::rvalue): Likewise.
+	* pt-loop.cc (tree_do_until_command::eval): Likewise.
+	(DO_LOOP): Likewise.
+	(tree_simple_for_command::eval): Likewise.
+	(tree_complex_for_command::eval): Likewise.
+	* pt-assign.cc (tree_simple_assignment::rvalue): Likewise.
+	* pt-binop.cc (tree_binary_expression::rvalue): Likewise.
+	(tree_boolean_expression::rvalue): Likewise.
+	* pt-cell.cc (tree_cell::rvalue): Likewise.
+	* pt-colon.cc (tree_colon_expression::rvalue): Likewise.
+	* pt-except.cc (tree_try_catch_command::eval): Likewise.
+	(tree_unwind_protect_command::eval): Likewise.
+	* pt-id.cc (tree_identifier::rvalue): Likewise.
+	(tree_identifier::lvalue): Likewise.
+	* pt-indir.cc (tree_indirect_ref::rvalue): Likewise.
+	* pt-jump.cc (tree_break_command::eval): Likewise.
+	(tree_continue_command::eval): Likewise.
+	(tree_return_command::eval): Likewise.
+
 2001-01-29  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* Map.h, Map.cc (CHMap<C>::operator = (const CHMap&)): New function.
@@ -541,7 +576,7 @@
 
 2000-03-21  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
-	* src/Makefile.in (LIBRARIES): Conditionally define.
+	* Makefile.in (LIBRARIES): Conditionally define.
 	(libraries): Depend on $(LIBRARIES).
 	(octave): Depend on $(LIBRARIES), not libraries.  Also depend on
 	stamp-prereq and stamp-oct-links.
@@ -551,7 +586,7 @@
 
 2000-03-21  Ben Sapp <bsapp@nua.lampf.lanl.gov>:
 
-	* src/Makefile.in (libraries): Depend only on library targets, not
+	* Makefile.in (libraries): Depend only on library targets, not
 	archive members.
 
 2000-03-17  John W. Eaton  <jwe@bevo.che.wisc.edu>
@@ -1391,7 +1426,7 @@
 
 	* variables.cc (Fclear): Look for dld functions too.
 
-	* ov-dld-fcn.cc, src/ov-dld-fcn.h: New files.
+	* ov-dld-fcn.cc, ov-dld-fcn.h: New files.
 	* Makefile.in (OV_INCLUDES, OV_SRC): Add them to the lists.
 
 	* Makefile.in (DEFVAR_PATTERN): Also match DEFCONSTX.
--- a/src/Makefile.in	Wed Jan 31 22:15:55 2001 +0000
+++ b/src/Makefile.in	Fri Feb 02 02:21:42 2001 +0000
@@ -40,7 +40,7 @@
 endif
 
 DLD_XSRC := balance.cc besselj.cc betainc.cc chol.cc colloc.cc dassl.cc \
-	det.cc eig.cc expm.cc fft.cc fft2.cc filter.cc find.cc \
+	debug.cc det.cc eig.cc expm.cc fft.cc fft2.cc filter.cc find.cc \
 	fsolve.cc gammainc.cc getgrent.cc getpwent.cc getrusage.cc \
 	givens.cc hess.cc ifft.cc ifft2.cc inv.cc log.cc lpsolve.cc \
 	lsode.cc lu.cc minmax.cc pinv.cc qr.cc quad.cc qz.cc rand.cc \
@@ -72,10 +72,10 @@
 	ov-base-nd-array.h ov-re-nd-array.h ov-typeinfo.h
 
 PT_INCLUDES := pt.h pt-all.h pt-arg-list.h pt-assign.h pt-binop.h \
-	pt-cell.h pt-check.h pt-cmd.h pt-colon.h pt-const.h pt-decl.h \
-	pt-except.h pt-exp.h pt-id.h pt-idx.h pt-indir.h \
+        pt-bp.h	pt-cell.h pt-check.h pt-cmd.h pt-colon.h pt-const.h \
+	pt-decl.h pt-except.h pt-exp.h pt-id.h pt-idx.h pt-indir.h \
 	pt-jump.h pt-loop.h pt-mat.h pt-misc.h pt-plot.h \
-	pt-pr-code.h pt-select.h pt-stmt.h pt-unop.h pt-walk.h
+	pt-pr-code.h pt-select.h pt-stmt.h pt-unop.h pt-walk.h \
 
 INCLUDES := BaseSLList.h Cell.h DLList.h Map.h Pix.h SLList.h \
 	SLStack.h Stack.h c-file-ptr-stream.h comment-list.h defun-dld.h \
@@ -114,7 +114,7 @@
 	ov-usr-fcn.cc ov-base-nd-array.cc ov-re-nd-array.cc \
 	ov-typeinfo.cc
 
-PT_SRC := pt.cc pt-arg-list.cc pt-assign.cc pt-binop.cc pt-cell.cc \
+PT_SRC := pt.cc pt-arg-list.cc pt-assign.cc pt-bp.cc pt-binop.cc pt-cell.cc \
 	pt-check.cc pt-cmd.cc pt-colon.cc pt-const.cc pt-decl.cc \
 	pt-except.cc pt-exp.cc pt-id.cc pt-idx.cc pt-indir.cc pt-jump.cc \
 	pt-loop.cc pt-mat.cc pt-misc.cc pt-plot.cc pt-pr-code.cc \
--- a/src/input.h	Wed Jan 31 22:15:55 2001 +0000
+++ b/src/input.h	Fri Feb 02 02:21:42 2001 +0000
@@ -30,9 +30,10 @@
 #include <string>
 
 #include "oct-time.h"
+#include "ov-list.h"
+#include "pager.h"
 
 class octave_value;
-class octave_value_list;
 
 extern int octave_read (char *buf, unsigned max_size);
 extern FILE *get_input_from_file (const std::string& name, int warn = 1);
@@ -78,7 +79,7 @@
 
 extern void initialize_command_input (void);
 
-extern octave_value do_keyboard (const octave_value_list& args);
+extern octave_value do_keyboard (const octave_value_list& args = octave_value_list ());
 
 extern std::string Vps4;
 
--- a/src/ov-usr-fcn.h	Wed Jan 31 22:15:55 2001 +0000
+++ b/src/ov-usr-fcn.h	Fri Feb 02 02:21:42 2001 +0000
@@ -133,6 +133,8 @@
 
   octave_comment_list *trailing_comment (void) { return trail_comm; }
 
+  symbol_table *sym_table (void) { return sym_tab; }
+
   void accept (tree_walker& tw);
 
 private:
--- a/src/pt-all.h	Wed Jan 31 22:15:55 2001 +0000
+++ b/src/pt-all.h	Fri Feb 02 02:21:42 2001 +0000
@@ -26,6 +26,7 @@
 #include "pt.h"
 #include "pt-arg-list.h"
 #include "pt-assign.h"
+#include "pt-bp.h"
 #include "pt-binop.h"
 #include "pt-check.h"
 #include "pt-cmd.h"
--- a/src/pt-assign.cc	Wed Jan 31 22:15:55 2001 +0000
+++ b/src/pt-assign.cc	Fri Feb 02 02:21:42 2001 +0000
@@ -39,6 +39,7 @@
 #include "pager.h"
 #include "ov.h"
 #include "pt-arg-list.h"
+#include "pt-bp.h"
 #include "pt-assign.h"
 #include "pt-walk.h"
 #include "utils.h"
@@ -62,6 +63,8 @@
 {
   octave_value_list retval;
 
+  MAYBE_DO_BREAKPOINT;
+
   if (nargout > 1)
     error ("invalid number of output arguments for expression X = RHS");
   else
--- a/src/pt-binop.cc	Wed Jan 31 22:15:55 2001 +0000
+++ b/src/pt-binop.cc	Fri Feb 02 02:21:42 2001 +0000
@@ -32,6 +32,7 @@
 #include "oct-obj.h"
 #include "ov.h"
 #include "pt-binop.h"
+#include "pt-bp.h"
 #include "pt-walk.h"
 
 // Binary expressions.
@@ -55,6 +56,8 @@
 {
   octave_value retval;
 
+  MAYBE_DO_BREAKPOINT;
+
   if (error_state)
     return retval;
 
@@ -119,6 +122,8 @@
 {
   octave_value_list retval;
 
+  MAYBE_DO_BREAKPOINT;
+
   if (nargout > 1)
     error ("binary operator `%s': invalid number of output arguments",
 	   oper () . c_str ());
--- a/src/pt-cell.cc	Wed Jan 31 22:15:55 2001 +0000
+++ b/src/pt-cell.cc	Fri Feb 02 02:21:42 2001 +0000
@@ -36,6 +36,7 @@
 #include "error.h"
 #include "oct-obj.h"
 #include "pt-arg-list.h"
+#include "pt-bp.h"
 #include "pt-exp.h"
 #include "pt-cell.h"
 #include "pt-walk.h"
@@ -48,6 +49,8 @@
 {
   octave_value retval;
 
+  MAYBE_DO_BREAKPOINT;
+
   int nr = length ();
   int nc = -1;
 
--- a/src/pt-cmd.h	Wed Jan 31 22:15:55 2001 +0000
+++ b/src/pt-cmd.h	Fri Feb 02 02:21:42 2001 +0000
@@ -32,6 +32,7 @@
 class tree_walker;
 
 #include "pt.h"
+#include "pt-bp.h"
 
 // A base class for commands.
 
@@ -68,7 +69,7 @@
 
   ~tree_no_op_command (void) { }
 
-  void eval (void) { }
+  void eval (void) { MAYBE_DO_BREAKPOINT; }
 
   void accept (tree_walker& tw);
 
--- a/src/pt-colon.cc	Wed Jan 31 22:15:55 2001 +0000
+++ b/src/pt-colon.cc	Fri Feb 02 02:21:42 2001 +0000
@@ -32,6 +32,7 @@
 #include "oct-obj.h"
 #include "pager.h"
 #include "ov.h"
+#include "pt-bp.h"
 #include "pt-colon.h"
 #include "pt-walk.h"
 
@@ -88,6 +89,8 @@
 {
   octave_value retval;
 
+  MAYBE_DO_BREAKPOINT;
+  
   if (error_state || ! op_base || ! op_limit)
     return retval;
 
--- a/src/pt-const.h	Wed Jan 31 22:15:55 2001 +0000
+++ b/src/pt-const.h	Fri Feb 02 02:21:42 2001 +0000
@@ -32,6 +32,7 @@
 
 #include "oct-alloc.h"
 
+#include "pt-bp.h"
 #include "pt-exp.h"
 
 class octave_value_list;
@@ -77,7 +78,10 @@
     { return true; }
 
   octave_value rvalue (void)
-    { return val; }
+    {
+      MAYBE_DO_BREAKPOINT;
+      return val;
+    }
 
   octave_value_list rvalue (int nargout);
 
--- a/src/pt-except.cc	Wed Jan 31 22:15:55 2001 +0000
+++ b/src/pt-except.cc	Fri Feb 02 02:21:42 2001 +0000
@@ -31,6 +31,7 @@
 #include "error.h"
 #include "oct-lvalue.h"
 #include "ov.h"
+#include "pt-bp.h"
 #include "pt-cmd.h"
 #include "pt-except.h"
 #include "pt-exp.h"
@@ -78,6 +79,8 @@
 tree_try_catch_command::eval (void)
 {
   unwind_protect::begin_frame ("tree_try_catch::eval");
+  
+  MAYBE_DO_BREAKPOINT;
 
   if (catch_code)
     {
@@ -208,6 +211,8 @@
 {
   unwind_protect::add (do_unwind_protect_cleanup_code, cleanup_code);
 
+  MAYBE_DO_BREAKPOINT;
+
   if (unwind_protect_code)
     unwind_protect_code->eval ();
 
--- a/src/pt-id.cc	Wed Jan 31 22:15:55 2001 +0000
+++ b/src/pt-id.cc	Fri Feb 02 02:21:42 2001 +0000
@@ -32,6 +32,7 @@
 #include "oct-obj.h"
 #include "oct-lvalue.h"
 #include "pager.h"
+#include "pt-bp.h"
 #include "pt-const.h"
 #include "pt-id.h"
 #include "pt-walk.h"
@@ -140,6 +141,8 @@
 {
   octave_value_list retval;
 
+  MAYBE_DO_BREAKPOINT;
+
   if (error_state)
     return retval;
 
@@ -199,6 +202,8 @@
 octave_lvalue
 tree_identifier::lvalue (void)
 {
+  MAYBE_DO_BREAKPOINT;
+
   return sym->variable_reference ();
 }
 
--- a/src/pt-indir.cc	Wed Jan 31 22:15:55 2001 +0000
+++ b/src/pt-indir.cc	Fri Feb 02 02:21:42 2001 +0000
@@ -34,6 +34,7 @@
 #include "oct-lvalue.h"
 #include "ov.h"
 #include "pager.h"
+#include "pt-bp.h"
 #include "pt-indir.h"
 #include "pt-walk.h"
 #include "utils.h"
@@ -60,6 +61,8 @@
 {
   octave_value_list retval;
 
+  MAYBE_DO_BREAKPOINT;
+
   if (nargout > 1)
     error ("invalid number of output arguments for structure reference");
   else
--- a/src/pt-jump.cc	Wed Jan 31 22:15:55 2001 +0000
+++ b/src/pt-jump.cc	Fri Feb 02 02:21:42 2001 +0000
@@ -29,9 +29,13 @@
 #endif
 
 #include "error.h"
+#include "oct-obj.h"
+#include "pt-bp.h"
 #include "pt-jump.h"
 #include "pt-walk.h"
 
+class octave_value_list;
+
 // Break.
 
 // Nonzero means we're breaking out of a loop or function body.
@@ -40,6 +44,9 @@
 void
 tree_break_command::eval (void)
 {
+  // Even if we have an error we should still enter debug mode.
+  MAYBE_DO_BREAKPOINT;
+
   if (! error_state)
     breaking = 1;
 }
@@ -58,6 +65,8 @@
 void
 tree_continue_command::eval (void)
 {
+  MAYBE_DO_BREAKPOINT;
+
   if (! error_state)
     continuing = 1;
 }
@@ -77,6 +86,8 @@
 void
 tree_return_command::eval (void)
 {
+  MAYBE_DO_BREAKPOINT;
+
   if (! error_state)
     returning = 1;
 }
--- a/src/pt-loop.cc	Wed Jan 31 22:15:55 2001 +0000
+++ b/src/pt-loop.cc	Fri Feb 02 02:21:42 2001 +0000
@@ -34,6 +34,7 @@
 #include "oct-lvalue.h"
 #include "ov.h"
 #include "pt-arg-list.h"
+#include "pt-bp.h"
 #include "pt-cmd.h"
 #include "pt-exp.h"
 #include "pt-jump.h"
@@ -130,6 +131,8 @@
 
   for (;;)
     {
+      MAYBE_DO_BREAKPOINT;
+
       if (list)
 	{
 	  list->eval ();
@@ -200,6 +203,8 @@
     { \
       for (int i = 0; i < steps; i++) \
 	{ \
+	  MAYBE_DO_BREAKPOINT; \
+ \
 	  octave_value val (arg); \
  \
 	  bool quit = false; \
@@ -244,6 +249,8 @@
 
       for (int i = 0; i < steps; i++)
 	{
+	  MAYBE_DO_BREAKPOINT;
+
 	  double tmp_val = b + i * increment;
 
 	  octave_value val (tmp_val);
@@ -259,6 +266,8 @@
   else if (rhs.is_scalar_type ())
     {
       bool quit = false;
+      
+      MAYBE_DO_BREAKPOINT;
 
       do_for_loop_once (ult, rhs, quit);
     }
@@ -277,6 +286,8 @@
 	{
 	  for (int i = 0; i < steps; i++)
 	    {
+	      MAYBE_DO_BREAKPOINT;
+
 	      octave_value val (chm_tmp.extract (0, i, nr-1, i), true);
 
 	      bool quit = false;
@@ -333,6 +344,8 @@
 
       for (Pix p = tmp_val.first (); p != 0; tmp_val.next (p))
 	{
+	  MAYBE_DO_BREAKPOINT;
+
 	  octave_value val = tmp_val.contents (p);
 
 	  bool quit = false;
@@ -435,6 +448,8 @@
 	  octave_value key = tmp_val.key (p);
 	  octave_value val = tmp_val.contents (p);
 
+	  MAYBE_DO_BREAKPOINT;
+
 	  bool quit = false;
 
 	  do_for_loop_once (key_ref, val_ref, key, val, quit);
--- a/src/pt-mat.cc	Wed Jan 31 22:15:55 2001 +0000
+++ b/src/pt-mat.cc	Fri Feb 02 02:21:42 2001 +0000
@@ -35,6 +35,7 @@
 #include "error.h"
 #include "oct-obj.h"
 #include "pt-arg-list.h"
+#include "pt-bp.h"
 #include "pt-exp.h"
 #include "pt-mat.h"
 #include "pt-walk.h"
@@ -436,6 +437,8 @@
 {
   octave_value_list retval;
 
+  MAYBE_DO_BREAKPOINT;
+
   if (nargout > 1)
     error ("invalid number of output arguments for matrix list");
   else
--- a/src/pt-stmt.cc	Wed Jan 31 22:15:55 2001 +0000
+++ b/src/pt-stmt.cc	Fri Feb 02 02:21:42 2001 +0000
@@ -36,6 +36,7 @@
 #include "oct-lvalue.h"
 #include "input.h"
 #include "pager.h"
+#include "pt-bp.h"
 #include "pt-cmd.h"
 #include "pt-id.h"
 #include "pt-idx.h"
@@ -184,6 +185,31 @@
   return retval;
 }
 
+int
+tree_statement_list::set_breakpoint (int line)
+{
+  tree_breakpoint tbp (line, tree_breakpoint::set);
+  accept (tbp);
+  
+  return tbp.get_line ();
+}
+
+void
+tree_statement_list::delete_breakpoint (int line)
+{
+  tree_breakpoint tbp (line, tree_breakpoint::clear); 
+  accept(tbp);
+}
+
+octave_value_list
+tree_statement_list::list_breakpoints (void)
+{
+  tree_breakpoint tbp (0, tree_breakpoint::list);
+  accept (tbp);
+
+  return tbp.get_list ();
+}
+
 void
 tree_statement_list::accept (tree_walker& tw)
 {
--- a/src/pt-stmt.h	Wed Jan 31 22:15:55 2001 +0000
+++ b/src/pt-stmt.h	Fri Feb 02 02:21:42 2001 +0000
@@ -100,7 +100,6 @@
   bool print_flag;
 
   // No copying!
-
   tree_statement (const tree_statement&);
 
   tree_statement& operator = (const tree_statement&);
@@ -132,6 +131,12 @@
 
   octave_value_list eval (bool silent = false, int nargout = 0);
 
+  int set_breakpoint (int line);
+
+  void delete_breakpoint (int line);
+
+  octave_value_list list_breakpoints (void);
+
   void accept (tree_walker& tw);
 
 private:
--- a/src/pt-unop.cc	Wed Jan 31 22:15:55 2001 +0000
+++ b/src/pt-unop.cc	Fri Feb 02 02:21:42 2001 +0000
@@ -32,6 +32,7 @@
 #include "oct-obj.h"
 #include "oct-lvalue.h"
 #include "ov.h"
+#include "pt-bp.h"
 #include "pt-unop.h"
 #include "pt-walk.h"
 
@@ -64,6 +65,8 @@
 {
   octave_value retval;
 
+  MAYBE_DO_BREAKPOINT;
+
   if (error_state)
     return retval;
 
@@ -143,6 +146,8 @@
 {
   octave_value retval;
 
+  MAYBE_DO_BREAKPOINT;
+
   if (error_state)
     return retval;
 
--- a/src/pt.h	Wed Jan 31 22:15:55 2001 +0000
+++ b/src/pt.h	Fri Feb 02 02:21:42 2001 +0000
@@ -40,7 +40,7 @@
 {
 public:
 
-  tree (int l = -1, int c = -1)
+  tree (int l = -1, int c = -1) : break_point(false)
     {
       line_num = l;
       column_num = c;
@@ -58,6 +58,15 @@
 
   std::string str_print_code (void);
 
+  virtual void set_breakpoint (void)
+    { break_point = true; }
+  
+  virtual void delete_breakpoint (void)
+    { break_point = false; }
+
+  virtual bool is_breakpoint (void) const 
+    { return break_point; }
+
 private:
 
   // The input line and column where we found the text that was
@@ -65,6 +74,9 @@
   int line_num;
   int column_num;
 
+  // Stop before executing this tree node
+  bool break_point;
+
   // No copying!
 
   tree (const tree&);