Mercurial > octave-nkf
comparison src/debug.cc @ 6646:bd0a70c3f2db
[project @ 2007-05-22 02:27:43 by jwe]
author | jwe |
---|---|
date | Tue, 22 May 2007 02:27:43 +0000 |
parents | 8c67f8be341d |
children | 673686daec87 |
comparison
equal
deleted
inserted
replaced
6645:81eb28d50cee | 6646:bd0a70c3f2db |
---|---|
85 } | 85 } |
86 | 86 |
87 | 87 |
88 DEFCMD (dbstop, args, , | 88 DEFCMD (dbstop, args, , |
89 "-*- texinfo -*-\n\ | 89 "-*- texinfo -*-\n\ |
90 @deftypefn {Loadable Function} {rline =} dbstop (func, line)\n\ | 90 @deftypefn {Loadable Function} {rline =} dbstop (func, line, @dots{})\n\ |
91 Set a breakpoint in a function\n\ | 91 Set a breakpoint in a function\n\ |
92 @table @code\n\ | 92 @table @code\n\ |
93 @item func\n\ | 93 @item func\n\ |
94 String representing the function name. When already in debug\n\ | 94 String representing the function name. When already in debug\n\ |
95 mode this should be left out and only the line should be given.\n\ | 95 mode this should be left out and only the line should be given.\n\ |
96 @item line\n\ | 96 @item line\n\ |
97 Line you would like the breakpoint to be set on\n\ | 97 Line you would like the breakpoint to be set on. Multiple\n\ |
98 lines might be given as seperate arguments or as a vector.\n\ | |
98 @end table\n\ | 99 @end table\n\ |
99 \n\ | 100 \n\ |
100 The rline returned is the real line that the breakpoint was set at.\n\ | 101 The rline returned is the real line that the breakpoint was set at.\n\ |
101 @seealso{dbclear, dbstatus, dbnext}\n\ | 102 @seealso{dbclear, dbstatus, dbnext}\n\ |
102 @end deftypefn") | 103 @end deftypefn") |
103 { | 104 { |
104 octave_value retval; | 105 octave_value retval; |
105 | |
106 int result = -1; | |
107 int nargin = args.length (); | 106 int nargin = args.length (); |
108 | 107 int idx = 0; |
109 string_vector argv = args.make_argv ("dbstop"); | 108 std::string symbol_name = ""; |
110 | 109 |
111 if (error_state) | 110 if (nargin != 1 && args(0).is_string()) |
112 return retval; | 111 { |
113 | 112 symbol_name = args(0).string_value (); |
114 if (nargin == 2) | 113 idx = 1; |
115 { | 114 } |
116 std::string symbol_name = argv[1]; | 115 |
117 | 116 octave_user_function *dbg_fcn = get_user_function (symbol_name); |
118 std::string line_number = argv[2]; | 117 |
119 | 118 if (dbg_fcn) |
120 int line = atoi (line_number.c_str ()); | 119 { |
121 | 120 octave_idx_type nsize = 10; |
122 octave_user_function *dbg_fcn = get_user_function (symbol_name); | 121 RowVector results (nsize); |
123 | 122 octave_idx_type nr = 0; |
124 if (dbg_fcn) | 123 |
125 { | 124 tree_statement_list *cmds = dbg_fcn->body (); |
126 tree_statement_list *cmds = dbg_fcn->body (); | 125 |
127 result = cmds->set_breakpoint (line); | 126 for (int i = idx; i < nargin; i++) |
128 } | 127 { |
129 else | 128 if (args(i).is_string ()) |
130 error ("dbstop: unable to find the function requested\n"); | 129 { |
131 } | 130 int line = atoi (args(i).string_value ().c_str ()); |
132 else if (nargin == 1) | 131 |
133 { | 132 if (error_state) |
134 std::string line_number = argv[1]; | 133 break; |
135 | 134 |
136 int line = atoi (line_number.c_str ()); | 135 if (nr == nsize) |
137 | 136 { |
138 octave_user_function *dbg_fcn = get_user_function (); | 137 nsize *= 2; |
139 | 138 results.resize (nsize); |
140 if (dbg_fcn) | 139 } |
141 { | 140 |
142 tree_statement_list *cmds = dbg_fcn->body (); | 141 results(nr++) = cmds->set_breakpoint (line); |
143 result = cmds->set_breakpoint (line); | 142 } |
144 } | 143 else |
145 else | 144 { |
146 error ("dbstop: unable to find the function requested\n"); | 145 const NDArray arg = args(i).array_value (); |
146 | |
147 if (error_state) | |
148 break; | |
149 | |
150 for (octave_idx_type j = 0; j < arg.nelem(); j++) | |
151 { | |
152 int line = static_cast<int> (arg.elem (j)); | |
153 | |
154 if (error_state) | |
155 break; | |
156 | |
157 if (nr == nsize) | |
158 { | |
159 nsize *= 2; | |
160 results.resize (nsize); | |
161 } | |
162 | |
163 results(nr++) = cmds->set_breakpoint (line); | |
164 } | |
165 | |
166 if (error_state) | |
167 break; | |
168 } | |
169 } | |
170 | |
171 if (! error_state) | |
172 { | |
173 results.resize (nr); | |
174 retval = results; | |
175 } | |
147 } | 176 } |
148 else | 177 else |
149 error ("dbstop: one argument when in a function and two when not\n"); | 178 error ("dbstop: unable to find the function requested\n"); |
150 | |
151 retval = result; | |
152 | 179 |
153 return retval; | 180 return retval; |
154 } | 181 } |
155 | 182 |
156 DEFCMD (dbclear, args, , | 183 DEFCMD (dbclear, args, , |
157 "-*- texinfo -*-\n\ | 184 "-*- texinfo -*-\n\ |
158 @deftypefn {Loadable Function} {} dbclear (func, line)\n\ | 185 @deftypefn {Loadable Function} {} dbclear (func, line, @dots{})\n\ |
159 Delete a breakpoint in a function\n\ | 186 Delete a breakpoint in a function\n\ |
160 @table @code\n\ | 187 @table @code\n\ |
161 @item func\n\ | 188 @item func\n\ |
162 String representing the function name. When already in debug\n\ | 189 String representing the function name. When already in debug\n\ |
163 mode this should be left out and only the line should be given.\n\ | 190 mode this should be left out and only the line should be given.\n\ |
164 @item line\n\ | 191 @item line\n\ |
165 Line where you would like to remove the the breakpoint\n\ | 192 Line where you would like to remove the the breakpoint. Multiple\n\ |
193 lines might be given as seperate arguments or as a vector.\n\ | |
166 @end table\n\ | 194 @end table\n\ |
167 No checking is done to make sure that the line you requested is really\n\ | 195 No checking is done to make sure that the line you requested is really\n\ |
168 a breakpoint. If you get the wrong line nothing will happen.\n\ | 196 a breakpoint. If you get the wrong line nothing will happen.\n\ |
169 @seealso{dbstop, dbstatus, dbwhere}\n\ | 197 @seealso{dbstop, dbstatus, dbwhere}\n\ |
170 @end deftypefn") | 198 @end deftypefn") |
171 { | 199 { |
172 octave_value retval; | 200 octave_value retval; |
173 | 201 int nargin = args.length (); |
202 int idx = 0; | |
174 std::string symbol_name = ""; | 203 std::string symbol_name = ""; |
175 std::string line_number; | 204 |
176 | 205 if (nargin != 1 && args(0).is_string()) |
177 int line = -1; | 206 { |
178 int nargin = args.length (); | 207 symbol_name = args(0).string_value (); |
179 | 208 idx = 1; |
180 string_vector argv = args.make_argv ("dbclear"); | 209 } |
181 | 210 |
182 if (error_state) | 211 octave_user_function *dbg_fcn = get_user_function (symbol_name); |
183 return retval; | 212 |
184 | 213 if (dbg_fcn) |
185 if (nargin == 1 || nargin == 2) | 214 { |
186 { | 215 tree_statement_list *cmds = dbg_fcn->body (); |
187 if (nargin == 2) | 216 |
188 { | 217 for (int i = idx; i < nargin; i++) |
189 symbol_name = argv[1]; | 218 { |
190 | 219 if (args(i).is_string ()) |
191 octave_stdout << argv[1] << std::endl; | 220 { |
192 line_number = argv[2]; | 221 int line = atoi (args(i).string_value ().c_str ()); |
193 } | 222 |
194 else if (nargin == 1) | 223 if (error_state) |
195 { | 224 break; |
196 line_number = argv[1]; | 225 |
197 } | 226 cmds->delete_breakpoint (line); |
198 | 227 } |
199 if (line_number.compare ("all") && line_number.compare ("ALL")) | 228 else |
200 line = atoi (line_number.c_str ()); | 229 { |
201 else | 230 const NDArray arg = args(i).array_value (); |
202 line = -1; | 231 |
203 | 232 if (error_state) |
204 octave_stdout << "symbol_name = " << symbol_name << std::endl; | 233 break; |
205 octave_user_function *dbg_fcn = get_user_function (symbol_name); | 234 |
206 | 235 for (octave_idx_type j = 0; j < arg.nelem (); j++) |
207 if (dbg_fcn) | 236 { |
208 { | 237 int line = static_cast<int> (arg.elem (j)); |
209 tree_statement_list *cmds = dbg_fcn->body (); | 238 |
210 cmds->delete_breakpoint (line); | 239 if (error_state) |
211 } | 240 break; |
212 else | 241 |
213 error ("dbclear: unable to find the function requested\n"); | 242 cmds->delete_breakpoint (line); |
243 } | |
244 | |
245 if (error_state) | |
246 break; | |
247 } | |
248 } | |
214 } | 249 } |
215 else | 250 else |
216 error ("dbclear: expecting one or two arguements\n"); | 251 error ("dbclear: unable to find the function requested\n"); |
217 | 252 |
218 return retval; | 253 return retval; |
219 } | 254 } |
220 | 255 |
221 DEFCMD (dbstatus, args, , | 256 DEFCMD (dbstatus, args, , |
348 os << "dbtype: unable to open `" << ff << "' for reading!\n"; | 383 os << "dbtype: unable to open `" << ff << "' for reading!\n"; |
349 } | 384 } |
350 else | 385 else |
351 os << "dbtype: unknown function " << name << "\n"; | 386 os << "dbtype: unknown function " << name << "\n"; |
352 | 387 |
353 os.flush(); | 388 os.flush (); |
354 } | 389 } |
355 | 390 |
356 DEFCMD (dbtype, args, , | 391 DEFCMD (dbtype, args, , |
357 "-*- texinfo -*-\n\ | 392 "-*- texinfo -*-\n\ |
358 @deftypefn {Loadable Function} {} dbtype ()\n\ | 393 @deftypefn {Loadable Function} {} dbtype ()\n\ |