Mercurial > hg > octave-nkf
annotate src/debug.h @ 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 | 87eda1f8faaa |
children | 73c4516fae10 |
rev | line source |
---|---|
7084 | 1 /* |
2 | |
3 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 Ben Sapp | |
4 | |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
9 Free Software Foundation; either version 3 of the License, or (at your | |
10 option) any later version. | |
11 | |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with Octave; see the file COPYING. If not, see | |
19 <http://www.gnu.org/licenses/>. | |
20 | |
21 */ | |
22 | |
23 #if !defined (octave_debug_h) | |
24 #define octave_debug_h 1 | |
25 | |
26 #include <map> | |
27 #include "ov.h" | |
28 #include "dRowVector.h" | |
29 | |
30 class octave_value_list; | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7084
diff
changeset
|
31 class octave_user_code; |
7084 | 32 |
33 // Interface to breakpoints,. | |
34 | |
35 class bp_table | |
36 { | |
37 private: | |
38 | |
39 bp_table (void) { } | |
40 | |
41 ~bp_table (void) { } | |
42 | |
43 public: | |
44 | |
45 typedef std::map<int, int> intmap; | |
46 | |
47 typedef intmap::const_iterator const_intmap_iterator; | |
48 typedef intmap::iterator intmap_iterator; | |
49 | |
50 typedef std::map <std::string, intmap> fname_line_map; | |
51 | |
52 typedef fname_line_map::const_iterator const_fname_line_map_iterator; | |
53 typedef fname_line_map::iterator fname_line_map_iterator; | |
54 | |
55 static bool instance_ok (void) | |
56 { | |
57 bool retval = true; | |
58 | |
59 if (! instance) | |
60 instance = new bp_table (); | |
61 | |
62 if (! instance) | |
63 { | |
64 ::error ("unable to create breakpoint table!"); | |
65 retval = false; | |
66 } | |
67 | |
68 return retval; | |
69 } | |
70 | |
71 // Add a breakpoint at the nearest executable line. | |
72 static intmap add_breakpoint (const std::string& fname = "", | |
73 const intmap& lines = intmap ()) | |
74 { | |
75 return instance_ok () | |
76 ? instance->do_add_breakpoint (fname, lines) : intmap (); | |
77 } | |
78 | |
79 // Remove a breakpoint from a line in file. | |
80 static int remove_breakpoint (const std::string& fname = "", | |
81 const intmap& lines = intmap ()) | |
82 { | |
83 return instance_ok () | |
84 ? instance->do_remove_breakpoint (fname, lines) : 0; | |
85 } | |
86 | |
87 // Remove all the breakpoints in a specified file. | |
8123
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
7719
diff
changeset
|
88 static intmap remove_all_breakpoints_in_file (const std::string& fname, |
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
7719
diff
changeset
|
89 bool silent = false) |
7084 | 90 { |
91 return instance_ok () | |
8123
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
7719
diff
changeset
|
92 ? instance->do_remove_all_breakpoints_in_file (fname, silent) : intmap (); |
7084 | 93 } |
94 | |
95 // Remove all the breakpoints registered with octave. | |
96 static void remove_all_breakpoints (void) | |
97 { | |
98 if (instance_ok ()) | |
99 instance->do_remove_all_breakpoints (); | |
100 } | |
101 | |
102 // Return all breakpoints. Each element of the map is a vector | |
103 // containing the breakpoints corresponding to a given function name. | |
104 static fname_line_map | |
105 get_breakpoint_list (const octave_value_list& fname_list) | |
106 { | |
107 return instance_ok () | |
108 ? instance->do_get_breakpoint_list (fname_list) : fname_line_map (); | |
109 } | |
110 | |
111 private: | |
112 | |
113 // Map from function names to function objects for functions | |
114 // containing at least one breakpoint. | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7084
diff
changeset
|
115 typedef std::map<std::string, octave_user_code *> breakpoint_map; |
7084 | 116 |
117 typedef breakpoint_map::const_iterator const_breakpoint_map_iterator; | |
118 typedef breakpoint_map::iterator breakpoint_map_iterator; | |
119 | |
120 breakpoint_map bp_map; | |
121 | |
122 static bp_table *instance; | |
123 | |
124 intmap do_add_breakpoint (const std::string& fname, const intmap& lines); | |
125 | |
126 int do_remove_breakpoint (const std::string&, const intmap& lines); | |
127 | |
8123
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
7719
diff
changeset
|
128 intmap do_remove_all_breakpoints_in_file (const std::string& fname, |
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
7719
diff
changeset
|
129 bool silent); |
7084 | 130 |
131 void do_remove_all_breakpoints (void); | |
132 | |
133 fname_line_map do_get_breakpoint_list (const octave_value_list& fname_list); | |
134 | |
135 }; | |
136 | |
137 #endif | |
138 | |
139 /* | |
140 ;;; Local Variables: *** | |
141 ;;; mode: C++ *** | |
142 ;;; End: *** | |
143 */ |