Mercurial > hg > octave-jordi
changeset 16530:7ca7e7d5eb91
remove breakpoints when clearing function
* pt-stmt.h, pt-stmt.cc (tree_statement_list::add_breakpoint,
tree_statement_list::remove_all_breakpoints): New functions.
* debug.cc (bp_table::do_add_breakpoint):
Call cmds->remove_all_breakpoints.
(bp_table::do_remove_all_breakpoints_in_file):
Call cmds->remove_all_breakpoints.
* ov-usr-fcn.cc (octave_user_script::~octave_user_script,
octave_user_function::~octave_user_function):
Call cmd_list->remove_all_breakpoints.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 17 Apr 2013 02:54:40 -0400 |
parents | faccc20d5f39 |
children | f3a63fdbd725 |
files | libinterp/interpfcn/debug.cc libinterp/octave-value/ov-usr-fcn.cc libinterp/parse-tree/pt-stmt.cc libinterp/parse-tree/pt-stmt.h |
diffstat | 4 files changed, 75 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/interpfcn/debug.cc +++ b/libinterp/interpfcn/debug.cc @@ -280,38 +280,16 @@ { intmap retval; - octave_idx_type len = line.size (); - octave_user_code *dbg_fcn = get_user_code (fname); if (dbg_fcn) { tree_statement_list *cmds = dbg_fcn->body (); - if (cmds) - { - for (int i = 0; i < len; i++) - { - const_intmap_iterator p = line.find (i); - - if (p != line.end ()) - { - int lineno = p->second; - - retval[i] = cmds->set_breakpoint (lineno); + std::string file = dbg_fcn->fcn_file_name (); - if (retval[i] != 0) - { - bp_set.insert (fname); - - std::string file = dbg_fcn->fcn_file_name (); - - if (! file.empty ()) - octave_link::update_breakpoint (true, file, retval[i]); - } - } - } - } + if (cmds) + retval = cmds->add_breakpoint (file, line); } else error ("add_breakpoint: unable to find the requested function\n"); @@ -345,6 +323,8 @@ tree_statement_list *cmds = dbg_fcn->body (); + // FIXME -- move the operation on cmds to the + // tree_statement_list class? if (cmds) { octave_value_list results = cmds->list_breakpoints (); @@ -402,17 +382,7 @@ if (cmds) { - octave_value_list bkpts = cmds->list_breakpoints (); - - for (int i = 0; i < bkpts.length (); i++) - { - int lineno = static_cast<int> (bkpts(i).int_value ()); - cmds->delete_breakpoint (lineno); - retval[i] = lineno; - - if (! file.empty ()) - octave_link::update_breakpoint (false, file, lineno); - } + retval = cmds->remove_all_breakpoints (file); bp_set_iterator it = bp_set.find (fname); if (it != bp_set.end ()) @@ -473,6 +443,8 @@ { tree_statement_list *cmds = f->body (); + // FIXME -- move the operation on cmds to the + // tree_statement_list class? if (cmds) { octave_value_list bkpts = cmds->list_breakpoints ();
--- a/libinterp/octave-value/ov-usr-fcn.cc +++ b/libinterp/octave-value/ov-usr-fcn.cc @@ -97,6 +97,9 @@ octave_user_script::~octave_user_script (void) { + if (cmd_list) + cmd_list->remove_all_breakpoints (file_name); + delete cmd_list; } @@ -207,6 +210,9 @@ octave_user_function::~octave_user_function (void) { + if (cmd_list) + cmd_list->remove_all_breakpoints (file_name); + delete param_list; delete ret_list; delete cmd_list;
--- a/libinterp/parse-tree/pt-stmt.cc +++ b/libinterp/parse-tree/pt-stmt.cc @@ -32,6 +32,7 @@ #include "error.h" #include "gripes.h" #include "ov.h" +#include "octave-link.h" #include "oct-lvalue.h" #include "input.h" #include "pager.h" @@ -191,6 +192,60 @@ return tbp.get_list (); } +bp_table::intmap +tree_statement_list::add_breakpoint (const std::string& file, + const bp_table::intmap& line) +{ + bp_table::intmap retval; + + octave_idx_type len = line.size (); + + for (int i = 0; i < len; i++) + { + const_intmap_iterator p = line.find (i); + + if (p != line.end ()) + { + int lineno = p->second; + + retval[i] = set_breakpoint (lineno); + + if (retval[i] != 0) + { + bp_set.insert (fname); + + if (! file.empty ()) + octave_link::update_breakpoint (true, file, retval[i]); + } + } + } + + return retval; +} + +bp_table::intmap +tree_statement_list::remove_all_breakpoints (const std::string& file) +{ + bp_table::intmap retval; + + octave_value_list bkpts = list_breakpoints (); + + for (int i = 0; i < bkpts.length (); i++) + { + int lineno = static_cast<int> (bkpts(i).int_value ()); + + delete_breakpoint (lineno); + + retval[i] = lineno; + + if (! file.empty ()) + octave_link::update_breakpoint (false, file, lineno); + } + + return retval; +} + + tree_statement_list * tree_statement_list::dup (symbol_table::scope_id scope, symbol_table::context_id context) const
--- a/libinterp/parse-tree/pt-stmt.h +++ b/libinterp/parse-tree/pt-stmt.h @@ -34,6 +34,7 @@ #include "base-list.h" #include "comment-list.h" +#include "debug.h" #include "symtab.h" #include "pt.h" @@ -160,6 +161,11 @@ octave_value_list list_breakpoints (void); + bp_table::intmap add_breakpoint (const std::string& file, + const bp_table::intmap& line); + + bp_table::intmap remove_all_breakpoints (const std::string& file); + tree_statement_list *dup (symbol_table::scope_id scope, symbol_table::context_id context) const;