00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if !defined (octave_debug_h)
00024 #define octave_debug_h 1
00025
00026 #include <map>
00027 #include <set>
00028 #include "ov.h"
00029 #include "dRowVector.h"
00030
00031 class octave_value_list;
00032 class octave_user_code;
00033
00034
00035
00036 class
00037 OCTINTERP_API
00038 bp_table
00039 {
00040 private:
00041
00042 bp_table (void) { }
00043
00044 ~bp_table (void) { }
00045
00046 public:
00047
00048 typedef std::map<int, int> intmap;
00049
00050 typedef intmap::const_iterator const_intmap_iterator;
00051 typedef intmap::iterator intmap_iterator;
00052
00053 typedef std::map <std::string, intmap> fname_line_map;
00054
00055 typedef fname_line_map::const_iterator const_fname_line_map_iterator;
00056 typedef fname_line_map::iterator fname_line_map_iterator;
00057
00058 static bool instance_ok (void)
00059 {
00060 bool retval = true;
00061
00062 if (! instance)
00063 instance = new bp_table ();
00064
00065 if (! instance)
00066 {
00067 ::error ("unable to create breakpoint table!");
00068 retval = false;
00069 }
00070
00071 return retval;
00072 }
00073
00074
00075 static intmap add_breakpoint (const std::string& fname = "",
00076 const intmap& lines = intmap ())
00077 {
00078 return instance_ok ()
00079 ? instance->do_add_breakpoint (fname, lines) : intmap ();
00080 }
00081
00082
00083 static int remove_breakpoint (const std::string& fname = "",
00084 const intmap& lines = intmap ())
00085 {
00086 return instance_ok ()
00087 ? instance->do_remove_breakpoint (fname, lines) : 0;
00088 }
00089
00090
00091 static intmap remove_all_breakpoints_in_file (const std::string& fname,
00092 bool silent = false)
00093 {
00094 return instance_ok ()
00095 ? instance->do_remove_all_breakpoints_in_file (fname, silent) : intmap ();
00096 }
00097
00098
00099 static void remove_all_breakpoints (void)
00100 {
00101 if (instance_ok ())
00102 instance->do_remove_all_breakpoints ();
00103 }
00104
00105
00106
00107 static fname_line_map
00108 get_breakpoint_list (const octave_value_list& fname_list)
00109 {
00110 return instance_ok ()
00111 ? instance->do_get_breakpoint_list (fname_list) : fname_line_map ();
00112 }
00113
00114 static bool
00115 have_breakpoints (void)
00116 {
00117 return instance_ok () ? instance->do_have_breakpoints () : 0;
00118 }
00119
00120 private:
00121
00122 typedef std::set<std::string>::const_iterator const_bp_set_iterator;
00123 typedef std::set<std::string>::iterator bp_set_iterator;
00124
00125
00126 std::set<std::string> bp_set;
00127
00128 static bp_table *instance;
00129
00130 intmap do_add_breakpoint (const std::string& fname, const intmap& lines);
00131
00132 int do_remove_breakpoint (const std::string&, const intmap& lines);
00133
00134 intmap do_remove_all_breakpoints_in_file (const std::string& fname,
00135 bool silent);
00136
00137 void do_remove_all_breakpoints (void);
00138
00139 fname_line_map do_get_breakpoint_list (const octave_value_list& fname_list);
00140
00141 bool do_have_breakpoints (void) { return (! bp_set.empty ()); }
00142 };
00143
00144 std::string get_file_line (const std::string& fname, size_t line);
00145
00146 #endif
00147
00148
00149
00150
00151
00152