# HG changeset patch # User jwe # Date 1199483370 0 # Node ID 4c9677b526b15c5feaaa1a1a6fb728dbd80bb6c3 # Parent 113fd59c0932022d55927ded75b3bc316bec9c3e [3-0-0-branch @ 2008-01-04 21:49:29 by jwe] diff -r 113fd59c0932 -r 4c9677b526b1 src/ChangeLog --- a/src/ChangeLog Fri Jan 04 20:26:33 2008 +0000 +++ b/src/ChangeLog Fri Jan 04 21:49:30 2008 +0000 @@ -1,3 +1,13 @@ +2008-01-04 John Swensen + + * debug.cc (bp_table::do_remove_all_breakpoints_in_file): + Avoid calling erase on invalid bp_map iterators. + (bp_table::do_remove_breakpoint): Only try to delete breakpoints + if some exist. Avoid calling erase on invalid bp_map iterators. + (parse_dbfunction_params): Return early if ARGS is empty. + New arg, WHO. Change all uses. + Accept but do nothing with struct args. + 2007-12-21 John W. Eaton Version 3.0.0 released. diff -r 113fd59c0932 -r 4c9677b526b1 src/debug.cc --- a/src/debug.cc Fri Jan 04 20:26:33 2008 +0000 +++ b/src/debug.cc Fri Jan 04 21:49:30 2008 +0000 @@ -1,6 +1,7 @@ /* -Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 Ben Sapp +Copyright (C) 2007, 2008 John Swensen +Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Ben Sapp This file is part of Octave. @@ -93,45 +94,50 @@ } static void -parse_dbfunction_params (const octave_value_list& args, - std::string& symbol_name, - bp_table::intmap& lines) +parse_dbfunction_params (const char *who, const octave_value_list& args, + std::string& symbol_name, bp_table::intmap& lines) { - octave_idx_type len = 0; int nargin = args.length (); int idx = 0; int list_idx = 0; symbol_name = std::string (); + lines = bp_table::intmap (); + + if (args.length () == 0) + return; // If we are already in a debugging function. if (octave_call_stack::caller_user_function ()) - idx = 0; - else + { + idx = 0; + symbol_name = get_user_function ()->name (); + } + else if (args(0).is_map ()) { - symbol_name = args (0).string_value (); + // Problem because parse_dbfunction_params() can only pass out a + // single function + } + else if (args(0).is_string()) + { + symbol_name = args(0).string_value (); if (error_state) return; idx = 1; } + else + error ("%s: invalid parameter specified", who); for (int i = idx; i < nargin; i++ ) { - if (args (i).is_string ()) - len++; - else - len += args (i).numel (); - } - - lines = bp_table::intmap (); - for (int i = idx; i < nargin; i++ ) - { - if (args (i).is_string ()) + if (args(i).is_string ()) { int line = atoi (args(i).string_value().c_str ()); if (error_state) break; lines[list_idx++] = line; } + else if (args(i).is_map ()) + octave_stdout << who << ": accepting a struct" << std::endl; else { const NDArray arg = args(i).array_value (); @@ -208,19 +214,23 @@ if (dbg_fcn) { tree_statement_list *cmds = dbg_fcn->body (); - for (int i = 0; i < len; i++) + octave_value_list results = cmds->list_breakpoints (); + if (results.length () > 0) { - const_intmap_iterator p = line.find (i); + for (int i = 0; i < len; i++) + { + const_intmap_iterator p = line.find (i); + + if (p != line.end ()) + cmds->delete_breakpoint (p->second); + } + results = cmds->list_breakpoints (); - if (p != line.end ()) - cmds->delete_breakpoint (p->second); + breakpoint_map_iterator it = bp_map.find (fname); + if (results.length () == 0 && it != bp_map.end ()) + bp_map.erase (it); } - octave_value_list results = cmds->list_breakpoints (); - - if (results.length () == 0) - bp_map.erase (bp_map.find (fname)); - retval = results.length (); } else @@ -249,8 +259,10 @@ cmds->delete_breakpoint (lineno); retval[i] = lineno; } - - bp_map.erase (bp_map.find (fname)); + + breakpoint_map_iterator it = bp_map.find (fname); + if (it != bp_map.end ()) + bp_map.erase (it); } else error ("remove_all_breakpoint_in_file: " @@ -358,7 +370,7 @@ std::string symbol_name; bp_table::intmap lines; - parse_dbfunction_params (args, symbol_name, lines); + parse_dbfunction_params ("dbstop", args, symbol_name, lines); if (! error_state) retval = bp_table::add_breakpoint (symbol_name, lines); @@ -387,7 +399,7 @@ std::string symbol_name = ""; bp_table::intmap lines; - parse_dbfunction_params (args, symbol_name, lines); + parse_dbfunction_params ("dbclear", args, symbol_name, lines); if (! error_state) bp_table::remove_breakpoint (symbol_name, lines);