# HG changeset patch # User jpswensen@compsci34-754-2010.compscidhcp.jhu.edu # Date 1241550625 14400 # Node ID 94ae487acd1bf65402d005f3a7b30127feeb0214 # Parent 23af5910e5f52174a69f2b95a427ff5fe33305f9 use set instead of map to keep track of debugger breakpoints diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2009-05-05 John Swensen + + * debug.h, debug.cc (breakpoints): Rename from bp_map, use a + std::set instead of a std::map object. Change all uses. + (bp_table::do_get_breakpoint_list): Simplify. + 2009-05-05 Robert T. Short * ov-class.h, ov-class.cc (octave_class::reconstruct_parents): diff --git a/src/debug.cc b/src/debug.cc --- a/src/debug.cc +++ b/src/debug.cc @@ -277,7 +277,9 @@ retval[i] = cmds->set_breakpoint (lineno); if (retval[i] != 0) - bp_map[fname] = dbg_fcn; + { + bp_set.insert (fname); + } } } } @@ -328,10 +330,10 @@ results = cmds->list_breakpoints (); - breakpoint_map_iterator it = bp_map.find (fname); + bp_set_iterator it = bp_set.find (fname); + if (results.length () == 0 && it != bp_set.end ()) + bp_set.erase (it); - if (results.length () == 0 && it != bp_map.end ()) - bp_map.erase (it); } retval = results.length (); @@ -370,10 +372,10 @@ retval[i] = lineno; } - breakpoint_map_iterator it = bp_map.find (fname); + bp_set_iterator it = bp_set.find (fname); + if (it != bp_set.end ()) + bp_set.erase (it); - if (it != bp_map.end ()) - bp_map.erase (it); } } else if (! silent) @@ -388,9 +390,9 @@ void bp_table::do_remove_all_breakpoints (void) { - for (const_breakpoint_map_iterator it = bp_map.begin (); - it != bp_map.end (); it++) - remove_all_breakpoints_in_file (it->first); + for (const_bp_set_iterator it = bp_set.begin (); it != bp_set.end (); it++) + remove_all_breakpoints_in_file (*it); + tree_evaluator::debug_mode = bp_table::have_breakpoints (); } @@ -419,46 +421,33 @@ { fname_line_map retval; - // Clear the breakpoints in the function if it has been updated. - // FIXME: This is a bad way of doing this, but I can't think of another. The - // problem is due to the fact that out_of_date_check(...) calls - // remove_breakpoints_in_file(...), which in turn modifies bp_map while we are - // in the middle of iterating through it. - - std::list usercode_list; - - for (breakpoint_map_iterator it = bp_map.begin (); it != bp_map.end (); it++) - usercode_list.push_back (it->second); - - for (std::list::iterator it = usercode_list.begin (); - it != usercode_list.end (); it++) - out_of_date_check (*it); - - - // Iterate through each of the files in the map and get the - // name and list of breakpoints. - for (breakpoint_map_iterator it = bp_map.begin (); it != bp_map.end (); it++) + for (bp_set_iterator it = bp_set.begin (); it != bp_set.end (); it++) { if (fname_list.length () == 0 - || do_find_bkpt_list (fname_list, it->first) != "") + || do_find_bkpt_list (fname_list, *it) != "") { - octave_user_code *f = it->second; - tree_statement_list *cmds = f->body (); + octave_user_code *f = get_user_code (*it); - if (cmds) + if (f) { - octave_value_list bkpts = cmds->list_breakpoints (); + tree_statement_list *cmds = f->body (); - octave_idx_type len = bkpts.length (); - - if (len > 0) + if (cmds) { - bp_table::intmap bkpts_vec; + octave_value_list bkpts = cmds->list_breakpoints (); + octave_idx_type len = bkpts.length (); - for (int i = 0; i < len; i++) - bkpts_vec[i] = bkpts (i).double_value (); + if (len > 0) + { + bp_table::intmap bkpts_vec; + + for (int i = 0; i < len; i++) + bkpts_vec[i] = bkpts (i).double_value (); + + std::string symbol_name = f->name (); - retval[it->first] = bkpts_vec; + retval[symbol_name] = bkpts_vec; + } } } } diff --git a/src/debug.h b/src/debug.h --- a/src/debug.h +++ b/src/debug.h @@ -24,6 +24,7 @@ #define octave_debug_h 1 #include +#include #include "ov.h" #include "dRowVector.h" @@ -116,14 +117,11 @@ private: - // Map from function names to function objects for functions - // containing at least one breakpoint. - typedef std::map breakpoint_map; + typedef std::set::const_iterator const_bp_set_iterator; + typedef std::set::iterator bp_set_iterator; - typedef breakpoint_map::const_iterator const_breakpoint_map_iterator; - typedef breakpoint_map::iterator breakpoint_map_iterator; - - breakpoint_map bp_map; + // Set of function names containing at least one breakpoint. + std::set bp_set; static bp_table *instance; @@ -138,7 +136,7 @@ fname_line_map do_get_breakpoint_list (const octave_value_list& fname_list); - bool do_have_breakpoints (void) { return (! bp_map.empty ()); } + bool do_have_breakpoints (void) { return (! bp_set.empty ()); } }; std::string get_file_line (const std::string& fname, size_t line);