Mercurial > hg > octave-lojdl
changeset 8123:eb2beef9a9ff
clear breakpoints is function found to be out of date
author | David Bateman <dbateman@free.fr> |
---|---|
date | Mon, 22 Sep 2008 13:11:32 -0400 |
parents | 99602635172a |
children | d227d096d49e |
files | src/ChangeLog src/debug.cc src/debug.h src/symtab.cc src/symtab.h |
diffstat | 5 files changed, 78 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,22 @@ +2008-09-22 David Bateman <dbateman@free.fr> + + * debug.cc (static octave_user_code * get_user_code + (const std::string&)): Only check user code as break points can't + be set in builtins or oct-files. + (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 ourt 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. + * symtab.cc (out_of_date_check_internal): Clear breakpoints in + function if out_of_date. split into two versions taking the + octave_function pointer seperately or not. + * symtab.h (bool out_of_date_check (octave_function*)): New function. + 2008-09-18 David Bateman <dbateman@free.fr> * DLD-FUNCTIONS/fftw.cc (Ffftw): Clarify the documentation.
--- a/src/debug.cc +++ b/src/debug.cc @@ -72,7 +72,7 @@ { octave_value fcn = symbol_table::find_function (fname); - if (fcn.is_defined ()) + if (fcn.is_defined () && fcn.is_user_code ()) dbg_fcn = fcn.user_code_value (); } @@ -238,7 +238,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; @@ -265,7 +266,7 @@ bp_map.erase (it); } } - else + else if (! silent) error ("remove_all_breakpoint_in_file: " "unable to find the function requested\n"); @@ -313,6 +314,9 @@ { octave_user_code *f = it->second; + // Clears the breakpoints if the function has been updated + out_of_date_check (f); + tree_statement_list *cmds = f->body (); if (cmds) @@ -321,12 +325,15 @@ octave_idx_type len = bkpts.length (); - bp_table::intmap bkpts_vec; + if (len > 0) + { + 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; + } } } }
--- 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/symtab.cc +++ b/src/symtab.cc @@ -42,6 +42,7 @@ #include "toplev.h" #include "unwind-prot.h" #include "utils.h" +#include "debug.h" symbol_table *symbol_table::instance = 0; @@ -151,13 +152,11 @@ } static inline bool -out_of_date_check_internal (octave_value& function, +out_of_date_check_internal (octave_function *fcn, octave_value& function, const std::string& dispatch_type = std::string ()) { bool retval = false; - octave_function *fcn = function.function_value (true); - if (fcn) { // FIXME -- we need to handle nested functions properly here. @@ -175,6 +174,7 @@ if (tc < Vlast_prompt_time || (relative && tc < Vlast_chdir_time)) { + bool clear_breakpoints = false; std::string nm = fcn->name (); int nm_len = nm.length (); @@ -207,6 +207,8 @@ // directory, so we should clear it. function = octave_value (); + + clear_breakpoints = true; } else if (same_file (file, ff)) { @@ -226,11 +228,19 @@ if (fs) { if (fs.is_newer (tp)) - retval = load_out_of_date_fcn (ff, dir_name, - function); + { + retval = load_out_of_date_fcn (ff, dir_name, + function); + + clear_breakpoints = true; + } } else - function = octave_value (); + { + function = octave_value (); + + clear_breakpoints = true; + } } } else @@ -239,7 +249,14 @@ // place of the old. retval = load_out_of_date_fcn (file, dir_name, function); + + clear_breakpoints = true; } + + // If the function has been replaced then clear any + // breakpoints associated with it + if (clear_breakpoints) + bp_table::remove_all_breakpoints_in_file (nm, true); } } } @@ -248,12 +265,27 @@ return retval; } +static inline bool +out_of_date_check_internal (octave_value& function, + const std::string& dispatch_type = std::string ()) +{ + return out_of_date_check_internal (function.function_value (true), + function, dispatch_type); +} + bool out_of_date_check (octave_value& function) { return out_of_date_check_internal (function); } +bool +out_of_date_check (octave_function* fcn) +{ + octave_value function; + return out_of_date_check_internal (fcn, function); +} + octave_value symbol_table::fcn_info::fcn_info_rep::load_private_function (const std::string& dir_name)