changeset 11855:eff8ac793dbf release-3-0-x

clear breakpoints is function found to be out of date
author David Bateman <dbateman@free.fr>
date Wed, 24 Sep 2008 14:08:58 +0200
parents 24d26caa095b
children ee51db2f6a6a
files src/ChangeLog src/debug.cc src/debug.h src/variables.cc
diffstat 4 files changed, 54 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -4,6 +4,21 @@
 
 2008-09-19  David Bateman  <dbateman@free.fr>
 
+	* debug.cc (static octave_user_function *get_user_function 
+	(const std::string&)):  Function lookup to force out of date check.
+	(bp_table::intmap bp_table::do_remove_all_breakpoints_in_file 
+	(const std::string&, bool)): Add flag to silence the error message 
+	from this function if a user code with breakpoints is not found.
+	(bp_table::fname_line_map bp_table::do_get_breakpoint_list (const 
+	octave_value_list&)): Do an out of date check on the function
+	before checking the breakpoints.
+	* debug.h (do_remove_all_breakpoints_in_file, 
+	remove_all_breakpoints_in_file): Add flag to silence error
+	message.
+	* variables.cc (static bool symbol_out_of_date (symbol_record*)):
+	If symbol out of date clear breakpoints.	
+	
+	
 	* data.cc (SINGLE_TYPE_CONCAT, DO_SINGLE_TYPE_CONCAT): New macros
 	(do_cat): Special case single type concatenations for speed.
 	* pt.mat.cc (std::string get_concat_class (const std::string&,
--- a/src/debug.cc
+++ b/src/debug.cc
@@ -75,6 +75,10 @@
 
       if (ptr && ptr->is_user_function ())
 	{
+	  // Do a lookup on the symbol record to force an 
+	  // out of date check on the function
+	  lookup (ptr);
+
 	  octave_value tmp = ptr->def ();
 	  dbg_fcn = dynamic_cast<octave_user_function *> (tmp.function_value ());
 	}
@@ -241,7 +245,8 @@
 
 
 bp_table::intmap
-bp_table::do_remove_all_breakpoints_in_file (const std::string& fname)
+bp_table::do_remove_all_breakpoints_in_file (const std::string& fname,
+					     bool silent)
 {
   intmap retval;
 
@@ -264,7 +269,7 @@
       if (it != bp_map.end ())
 	bp_map.erase (it);
     }
-  else
+  else if (! silent)
     error ("remove_all_breakpoint_in_file: "
 	   "unable to find the function requested\n");
 
@@ -310,16 +315,30 @@
       if (fname_list.length () == 0
 	  || do_find_bkpt_list (fname_list, it->first) != "")
 	{
-	  octave_value_list bkpts = it->second->body ()->list_breakpoints ();
+	  if (! fcn_out_of_date (it->second, it->second->fcn_file_name (), 
+				 it->second->time_parsed (). unix_time()))
+	    {
+	      octave_value_list bkpts = 
+		it->second->body ()->list_breakpoints ();
 
-	  octave_idx_type len = bkpts.length (); 
+	      octave_idx_type len = bkpts.length (); 
+
+	      if (len > 0)
+		{
+		  bp_table::intmap bkpts_vec;
 
-	  bp_table::intmap bkpts_vec;
+		  for (int i = 0; i < len; i++)
+		    bkpts_vec[i] = bkpts (i).double_value ();
 
-	  for (int i = 0; i < len; i++)
-	    bkpts_vec[i] = bkpts (i).double_value ();
-
-	  retval[it->first] = bkpts_vec;
+		  retval[it->first] = bkpts_vec;
+		}
+	    }
+	  else
+	    {
+	      symbol_record *sr = fbi_sym_tab->lookup (it->first);
+	      if (sr && sr->is_function ())
+		lookup (sr);
+	    }
 	}
     }
 
--- a/src/debug.h
+++ b/src/debug.h
@@ -85,10 +85,11 @@
   }
 
   // Remove all the breakpoints in a specified file.
-  static intmap remove_all_breakpoints_in_file (const std::string& fname)
+  static intmap remove_all_breakpoints_in_file (const std::string& fname,
+						bool silent = false)
   {
     return instance_ok ()
-      ? instance->do_remove_all_breakpoints_in_file (fname) : intmap ();
+      ? instance->do_remove_all_breakpoints_in_file (fname, silent) : intmap ();
   }
   
   // Remove all the breakpoints registered with octave.
@@ -124,7 +125,8 @@
 
   int do_remove_breakpoint (const std::string&, const intmap& lines);
 
-  intmap do_remove_all_breakpoints_in_file (const std::string& fname);
+  intmap do_remove_all_breakpoints_in_file (const std::string& fname, 
+					    bool silent);
 
   void do_remove_all_breakpoints (void);
 
--- a/src/variables.cc
+++ b/src/variables.cc
@@ -58,6 +58,7 @@
 #include "unwind-prot.h"
 #include "utils.h"
 #include "variables.h"
+#include "debug.h"
 
 // Should Octave always check to see if function files have changed
 // since they were last compiled?
@@ -1091,6 +1092,11 @@
 		      else
 			retval = true;
 		    }
+
+		  // If the function has been replaced then clear any 
+		  // breakpoints associated with it
+		  if (retval)
+		    bp_table::remove_all_breakpoints_in_file (nm, true);
 		}
 	    }
 	}