Mercurial > hg > octave-nkf
annotate src/debug.cc @ 8359:5798aa0f902a
[mq]: debug.patch
author | jpswensen@john-swensens-macbook-pro-15.local |
---|---|
date | Fri, 21 Nov 2008 22:53:50 -0500 |
parents | fa78cb8d8a5c |
children | 65ca196fff28 |
rev | line source |
---|---|
3805 | 1 /* |
2 | |
7348 | 3 Copyright (C) 2007, 2008 John Swensen |
4 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Ben Sapp | |
3805 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
3805 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
3805 | 21 |
22 */ | |
23 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
3895 | 27 #include <iostream> |
28 #include <fstream> | |
3948 | 29 #include <string> |
7082 | 30 #include <set> |
31 | |
3805 | 32 #include "defun.h" |
33 #include "error.h" | |
7082 | 34 #include "help.h" |
3805 | 35 #include "input.h" |
36 #include "pager.h" | |
37 #include "oct-obj.h" | |
38 #include "utils.h" | |
39 #include "parse.h" | |
40 #include "symtab.h" | |
41 #include "gripes.h" | |
42 #include "ov.h" | |
43 #include "ov-usr-fcn.h" | |
44 #include "ov-fcn.h" | |
7082 | 45 #include "ov-list.h" |
46 #include "ov-struct.h" | |
3805 | 47 #include "pt-pr-code.h" |
48 #include "pt.h" | |
49 #include "pt-bp.h" | |
50 #include "pt-stmt.h" | |
51 #include "toplev.h" | |
52 #include "unwind-prot.h" | |
53 #include "variables.h" | |
54 | |
7082 | 55 #include "debug.h" |
56 | |
57 // Initialize the singleton object | |
7083 | 58 bp_table *bp_table::instance = 0; |
7082 | 59 |
5743 | 60 // Return a pointer to the user-defined function FNAME. If FNAME is |
61 // empty, search backward for the first user-defined function in the | |
62 // current call stack. | |
7083 | 63 |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
64 static octave_user_code * |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
65 get_user_code (const std::string& fname = std::string ()) |
3805 | 66 { |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
67 octave_user_code *dbg_fcn = 0; |
3805 | 68 |
7083 | 69 if (fname.empty ()) |
7923
c3d21b9b94b6
eliminate octave_call_stack member functions caller_user_script and caller_user_function, and unused difference_type args
John W. Eaton <jwe@octave.org>
parents:
7901
diff
changeset
|
70 dbg_fcn = octave_call_stack::caller_user_code (); |
5743 | 71 else |
3805 | 72 { |
7539
3e107d73aeb4
debug.cc: use find_function instead of find_user_function
John Swensen
parents:
7348
diff
changeset
|
73 octave_value fcn = symbol_table::find_function (fname); |
3946 | 74 |
8123
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
8114
diff
changeset
|
75 if (fcn.is_defined () && fcn.is_user_code ()) |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
76 dbg_fcn = fcn.user_code_value (); |
3805 | 77 } |
78 | |
79 return dbg_fcn; | |
80 } | |
81 | |
7082 | 82 static void |
7348 | 83 parse_dbfunction_params (const char *who, const octave_value_list& args, |
84 std::string& symbol_name, bp_table::intmap& lines) | |
7082 | 85 { |
86 int nargin = args.length (); | |
87 int idx = 0; | |
88 int list_idx = 0; | |
89 symbol_name = std::string (); | |
7348 | 90 lines = bp_table::intmap (); |
91 | |
92 if (args.length () == 0) | |
93 return; | |
7082 | 94 |
7083 | 95 // If we are already in a debugging function. |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
96 if (octave_call_stack::caller_user_code ()) |
7348 | 97 { |
98 idx = 0; | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
99 symbol_name = get_user_code ()->name (); |
7348 | 100 } |
101 else if (args(0).is_map ()) | |
7082 | 102 { |
7348 | 103 // Problem because parse_dbfunction_params() can only pass out a |
104 // single function | |
105 } | |
106 else if (args(0).is_string()) | |
107 { | |
108 symbol_name = args(0).string_value (); | |
7082 | 109 if (error_state) |
110 return; | |
111 idx = 1; | |
112 } | |
7348 | 113 else |
114 error ("%s: invalid parameter specified", who); | |
7082 | 115 |
116 for (int i = idx; i < nargin; i++ ) | |
117 { | |
7348 | 118 if (args(i).is_string ()) |
7082 | 119 { |
7083 | 120 int line = atoi (args(i).string_value().c_str ()); |
7082 | 121 if (error_state) |
7083 | 122 break; |
7082 | 123 lines[list_idx++] = line; |
124 } | |
7348 | 125 else if (args(i).is_map ()) |
126 octave_stdout << who << ": accepting a struct" << std::endl; | |
7082 | 127 else |
128 { | |
7083 | 129 const NDArray arg = args(i).array_value (); |
7082 | 130 |
131 if (error_state) | |
132 break; | |
133 | |
7083 | 134 for (octave_idx_type j = 0; j < arg.nelem (); j++) |
7082 | 135 { |
136 int line = static_cast<int> (arg.elem (j)); | |
137 if (error_state) | |
138 break; | |
139 lines[list_idx++] = line; | |
140 } | |
141 | |
142 if (error_state) | |
143 break; | |
144 } | |
145 } | |
146 } | |
147 | |
7083 | 148 bp_table::intmap |
149 bp_table::do_add_breakpoint (const std::string& fname, | |
150 const bp_table::intmap& line) | |
7082 | 151 { |
7083 | 152 intmap retval; |
7082 | 153 |
154 octave_idx_type len = line.size (); | |
7083 | 155 |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
156 octave_user_code *dbg_fcn = get_user_code (fname); |
7082 | 157 |
158 if (dbg_fcn) | |
159 { | |
160 tree_statement_list *cmds = dbg_fcn->body (); | |
7083 | 161 |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
162 if (cmds) |
7082 | 163 { |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
164 for (int i = 0; i < len; i++) |
7082 | 165 { |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
166 const_intmap_iterator p = line.find (i); |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
167 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
168 if (p != line.end ()) |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
169 { |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
170 int lineno = p->second; |
7083 | 171 |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
172 retval[i] = cmds->set_breakpoint (lineno); |
7083 | 173 |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
174 if (retval[i] != 0) |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
175 bp_map[fname] = dbg_fcn; |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
176 } |
7082 | 177 } |
178 } | |
179 } | |
180 else | |
181 error ("add_breakpoint: unable to find the function requested\n"); | |
182 | |
183 return retval; | |
184 } | |
185 | |
186 | |
187 int | |
7083 | 188 bp_table::do_remove_breakpoint (const std::string& fname, |
189 const bp_table::intmap& line) | |
7082 | 190 { |
7083 | 191 int retval = 0; |
7082 | 192 |
193 octave_idx_type len = line.size (); | |
194 | |
195 if (len == 0) | |
196 { | |
197 intmap results = remove_all_breakpoints_in_file (fname); | |
198 retval = results.size (); | |
199 } | |
200 else | |
201 { | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
202 octave_user_code *dbg_fcn = get_user_code (fname); |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
203 |
7082 | 204 if (dbg_fcn) |
205 { | |
206 tree_statement_list *cmds = dbg_fcn->body (); | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
207 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
208 if (cmds) |
7082 | 209 { |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
210 octave_value_list results = cmds->list_breakpoints (); |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
211 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
212 if (results.length () > 0) |
7348 | 213 { |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
214 for (int i = 0; i < len; i++) |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
215 { |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
216 const_intmap_iterator p = line.find (i); |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
217 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
218 if (p != line.end ()) |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
219 cmds->delete_breakpoint (p->second); |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
220 } |
7083 | 221 |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
222 results = cmds->list_breakpoints (); |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
223 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
224 breakpoint_map_iterator it = bp_map.find (fname); |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
225 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
226 if (results.length () == 0 && it != bp_map.end ()) |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
227 bp_map.erase (it); |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
228 } |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
229 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
230 retval = results.length (); |
7082 | 231 } |
232 } | |
233 else | |
234 error ("remove_breakpoint: unable to find the function requested\n"); | |
235 } | |
236 return retval; | |
237 } | |
238 | |
239 | |
7083 | 240 bp_table::intmap |
8123
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
8114
diff
changeset
|
241 bp_table::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:
8114
diff
changeset
|
242 bool silent) |
7082 | 243 { |
7083 | 244 intmap retval; |
7082 | 245 |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
246 octave_user_code *dbg_fcn = get_user_code (fname); |
7082 | 247 |
248 if (dbg_fcn) | |
249 { | |
250 tree_statement_list *cmds = dbg_fcn->body (); | |
7083 | 251 |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
252 if (cmds) |
7082 | 253 { |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
254 octave_value_list bkpts = cmds->list_breakpoints (); |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
255 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
256 for (int i = 0; i < bkpts.length (); i++) |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
257 { |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
258 int lineno = static_cast<int> (bkpts(i).int_value ()); |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
259 cmds->delete_breakpoint (lineno); |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
260 retval[i] = lineno; |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
261 } |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
262 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
263 breakpoint_map_iterator it = bp_map.find (fname); |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
264 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
265 if (it != bp_map.end ()) |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
266 bp_map.erase (it); |
7082 | 267 } |
268 } | |
8123
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
8114
diff
changeset
|
269 else if (! silent) |
7082 | 270 error ("remove_all_breakpoint_in_file: " |
271 "unable to find the function requested\n"); | |
272 | |
273 return retval; | |
274 } | |
275 | |
276 void | |
7083 | 277 bp_table::do_remove_all_breakpoints (void) |
7082 | 278 { |
7083 | 279 for (const_breakpoint_map_iterator it = bp_map.begin (); |
280 it != bp_map.end (); it++) | |
281 remove_all_breakpoints_in_file (it->first); | |
7082 | 282 } |
283 | |
284 std::string | |
285 do_find_bkpt_list (octave_value_list slist, | |
286 std::string match) | |
287 { | |
288 std::string retval; | |
7083 | 289 |
7082 | 290 for (int i = 0; i < slist.length (); i++) |
291 { | |
292 if (slist (i).string_value () == match) | |
293 { | |
7083 | 294 retval = slist(i).string_value (); |
7082 | 295 break; |
296 } | |
297 } | |
298 return retval; | |
299 } | |
300 | |
301 | |
7083 | 302 bp_table::fname_line_map |
303 bp_table::do_get_breakpoint_list (const octave_value_list& fname_list) | |
7082 | 304 { |
7083 | 305 fname_line_map retval; |
7082 | 306 |
8359
5798aa0f902a
[mq]: debug.patch
jpswensen@john-swensens-macbook-pro-15.local
parents:
8347
diff
changeset
|
307 // Clear the breakpoints in the function if it has been updated. |
5798aa0f902a
[mq]: debug.patch
jpswensen@john-swensens-macbook-pro-15.local
parents:
8347
diff
changeset
|
308 // FIXME: This is a bad way of doing this, but I can't think of another. The |
5798aa0f902a
[mq]: debug.patch
jpswensen@john-swensens-macbook-pro-15.local
parents:
8347
diff
changeset
|
309 // problem is due to the fact that out_of_date_check(...) calls |
5798aa0f902a
[mq]: debug.patch
jpswensen@john-swensens-macbook-pro-15.local
parents:
8347
diff
changeset
|
310 // remove_breakpoints_in_file(...), which in turn modifies bp_map while we are |
5798aa0f902a
[mq]: debug.patch
jpswensen@john-swensens-macbook-pro-15.local
parents:
8347
diff
changeset
|
311 // in the middle of iterating through it. |
5798aa0f902a
[mq]: debug.patch
jpswensen@john-swensens-macbook-pro-15.local
parents:
8347
diff
changeset
|
312 std::list<octave_user_code*> usercode_list; |
5798aa0f902a
[mq]: debug.patch
jpswensen@john-swensens-macbook-pro-15.local
parents:
8347
diff
changeset
|
313 for (breakpoint_map_iterator it = bp_map.begin (); it != bp_map.end (); it++) |
5798aa0f902a
[mq]: debug.patch
jpswensen@john-swensens-macbook-pro-15.local
parents:
8347
diff
changeset
|
314 { |
5798aa0f902a
[mq]: debug.patch
jpswensen@john-swensens-macbook-pro-15.local
parents:
8347
diff
changeset
|
315 octave_user_code *f = it->second; |
5798aa0f902a
[mq]: debug.patch
jpswensen@john-swensens-macbook-pro-15.local
parents:
8347
diff
changeset
|
316 usercode_list.push_back(f); |
5798aa0f902a
[mq]: debug.patch
jpswensen@john-swensens-macbook-pro-15.local
parents:
8347
diff
changeset
|
317 } |
5798aa0f902a
[mq]: debug.patch
jpswensen@john-swensens-macbook-pro-15.local
parents:
8347
diff
changeset
|
318 |
5798aa0f902a
[mq]: debug.patch
jpswensen@john-swensens-macbook-pro-15.local
parents:
8347
diff
changeset
|
319 for (std::list<octave_user_code*>::iterator it = usercode_list.begin (); it != usercode_list.end (); it++) |
5798aa0f902a
[mq]: debug.patch
jpswensen@john-swensens-macbook-pro-15.local
parents:
8347
diff
changeset
|
320 { |
5798aa0f902a
[mq]: debug.patch
jpswensen@john-swensens-macbook-pro-15.local
parents:
8347
diff
changeset
|
321 out_of_date_check(*it); |
5798aa0f902a
[mq]: debug.patch
jpswensen@john-swensens-macbook-pro-15.local
parents:
8347
diff
changeset
|
322 } |
5798aa0f902a
[mq]: debug.patch
jpswensen@john-swensens-macbook-pro-15.local
parents:
8347
diff
changeset
|
323 |
5798aa0f902a
[mq]: debug.patch
jpswensen@john-swensens-macbook-pro-15.local
parents:
8347
diff
changeset
|
324 |
7082 | 325 // Iterate through each of the files in the map and get the |
7083 | 326 // name and list of breakpoints. |
327 for (breakpoint_map_iterator it = bp_map.begin (); it != bp_map.end (); it++) | |
7082 | 328 { |
7083 | 329 if (fname_list.length () == 0 |
330 || do_find_bkpt_list (fname_list, it->first) != "") | |
7082 | 331 { |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
332 octave_user_code *f = it->second; |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
333 tree_statement_list *cmds = f->body (); |
7083 | 334 |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
335 if (cmds) |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
336 { |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
337 octave_value_list bkpts = cmds->list_breakpoints (); |
7083 | 338 |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
339 octave_idx_type len = bkpts.length (); |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
340 |
8123
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
8114
diff
changeset
|
341 if (len > 0) |
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
8114
diff
changeset
|
342 { |
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
8114
diff
changeset
|
343 bp_table::intmap bkpts_vec; |
7083 | 344 |
8123
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
8114
diff
changeset
|
345 for (int i = 0; i < len; i++) |
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
8114
diff
changeset
|
346 bkpts_vec[i] = bkpts (i).double_value (); |
7083 | 347 |
8123
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
8114
diff
changeset
|
348 retval[it->first] = bkpts_vec; |
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
8114
diff
changeset
|
349 } |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
350 } |
7082 | 351 } |
352 } | |
7083 | 353 |
7082 | 354 return retval; |
355 } | |
356 | |
357 static octave_value | |
7083 | 358 intmap_to_ov (const bp_table::intmap& line) |
7082 | 359 { |
360 int idx = 0; | |
7083 | 361 |
362 NDArray retval (dim_vector (1, line.size ())); | |
363 | |
364 for (size_t i = 0; i < line.size (); i++) | |
7082 | 365 { |
7083 | 366 bp_table::const_intmap_iterator p = line.find (i); |
367 | |
7082 | 368 if (p != line.end ()) |
369 { | |
370 int lineno = p->second; | |
7083 | 371 retval(idx++) = lineno; |
7082 | 372 } |
373 } | |
7083 | 374 |
7082 | 375 retval.resize (dim_vector (1, idx)); |
7083 | 376 |
7082 | 377 return retval; |
378 } | |
3895 | 379 |
4208 | 380 DEFCMD (dbstop, args, , |
3805 | 381 "-*- texinfo -*-\n\ |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
382 @deftypefn {Loadable Function} {@var{rline} =} dbstop (@var{func}, @var{line}, @dots{})\n\ |
3805 | 383 Set a breakpoint in a function\n\ |
384 @table @code\n\ | |
385 @item func\n\ | |
386 String representing the function name. When already in debug\n\ | |
387 mode this should be left out and only the line should be given.\n\ | |
388 @item line\n\ | |
8347
fa78cb8d8a5c
corrections for typos
Brian Gough<bjg@network-theory.co.uk>
parents:
8286
diff
changeset
|
389 Line number you would like the breakpoint to be set on. Multiple\n\ |
7001 | 390 lines might be given as separate arguments or as a vector.\n\ |
3805 | 391 @end table\n\ |
392 \n\ | |
393 The rline returned is the real line that the breakpoint was set at.\n\ | |
8286
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8123
diff
changeset
|
394 @seealso{dbclear, dbstatus, dbstep}\n\ |
5642 | 395 @end deftypefn") |
3805 | 396 { |
7083 | 397 bp_table::intmap retval; |
398 std::string symbol_name; | |
399 bp_table::intmap lines; | |
400 | |
7348 | 401 parse_dbfunction_params ("dbstop", args, symbol_name, lines); |
6646 | 402 |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
403 if (lines.size () == 0) |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
404 lines[0] = 1; |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
405 |
7083 | 406 if (! error_state) |
7082 | 407 retval = bp_table::add_breakpoint (symbol_name, lines); |
3805 | 408 |
7083 | 409 return intmap_to_ov (retval); |
3805 | 410 } |
411 | |
4208 | 412 DEFCMD (dbclear, args, , |
3805 | 413 "-*- texinfo -*-\n\ |
7083 | 414 @deftypefn {Loadable Function} {} dbclear (@var{func}, @var{line}, @dots{})\n\ |
3805 | 415 Delete a breakpoint in a function\n\ |
416 @table @code\n\ | |
417 @item func\n\ | |
418 String representing the function name. When already in debug\n\ | |
419 mode this should be left out and only the line should be given.\n\ | |
420 @item line\n\ | |
8347
fa78cb8d8a5c
corrections for typos
Brian Gough<bjg@network-theory.co.uk>
parents:
8286
diff
changeset
|
421 Line number where you would like to remove the breakpoint. Multiple\n\ |
7001 | 422 lines might be given as separate arguments or as a vector.\n\ |
3805 | 423 @end table\n\ |
424 No checking is done to make sure that the line you requested is really\n\ | |
6646 | 425 a breakpoint. If you get the wrong line nothing will happen.\n\ |
5642 | 426 @seealso{dbstop, dbstatus, dbwhere}\n\ |
427 @end deftypefn") | |
3805 | 428 { |
429 octave_value retval; | |
430 std::string symbol_name = ""; | |
7083 | 431 bp_table::intmap lines; |
432 | |
7348 | 433 parse_dbfunction_params ("dbclear", args, symbol_name, lines); |
7082 | 434 |
7083 | 435 if (! error_state) |
7082 | 436 bp_table::remove_breakpoint (symbol_name, lines); |
3805 | 437 |
438 return retval; | |
439 } | |
440 | |
7082 | 441 DEFCMD (dbstatus, args, nargout, |
3805 | 442 "-*- texinfo -*-\n\ |
7083 | 443 @deftypefn {Loadable Function} {lst =} dbstatus (@var{func})\n\ |
3805 | 444 Return a vector containing the lines on which a function has \n\ |
445 breakpoints set.\n\ | |
446 @table @code\n\ | |
447 @item func\n\ | |
448 String representing the function name. When already in debug\n\ | |
449 mode this should be left out.\n\ | |
450 @end table\n\ | |
5642 | 451 @seealso{dbclear, dbwhere}\n\ |
452 @end deftypefn") | |
3805 | 453 { |
7082 | 454 Octave_map retval; |
3805 | 455 int nargin = args.length (); |
7082 | 456 octave_value_list fcn_list; |
7083 | 457 bp_table::fname_line_map bp_list; |
458 std::string symbol_name; | |
3805 | 459 |
460 if (nargin != 0 && nargin != 1) | |
461 { | |
3948 | 462 error ("dbstatus: only zero or one arguements accepted\n"); |
7082 | 463 return octave_value (); |
3805 | 464 } |
465 | |
466 if (nargin == 1) | |
467 { | |
468 if (args(0).is_string ()) | |
7082 | 469 { |
7083 | 470 symbol_name = args(0).string_value (); |
471 fcn_list(0) = symbol_name; | |
7082 | 472 bp_list = bp_table::get_breakpoint_list (fcn_list); |
473 } | |
3805 | 474 else |
7083 | 475 gripe_wrong_type_arg ("dbstatus", args(0)); |
7082 | 476 } |
477 else | |
478 { | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
479 octave_user_code *dbg_fcn = get_user_code (); |
7082 | 480 if (dbg_fcn) |
481 { | |
482 symbol_name = dbg_fcn->name (); | |
7083 | 483 fcn_list(0) = symbol_name; |
7082 | 484 } |
7083 | 485 |
7082 | 486 bp_list = bp_table::get_breakpoint_list (fcn_list); |
3805 | 487 } |
488 | |
7083 | 489 if (nargout == 0) |
3805 | 490 { |
7083 | 491 // Print out the breakpoint information. |
492 | |
493 for (bp_table::fname_line_map_iterator it = bp_list.begin (); | |
494 it != bp_list.end (); it++) | |
495 { | |
496 octave_stdout << "Breakpoint in " << it->first << " at line(s) "; | |
497 | |
498 bp_table::intmap m = it->second; | |
499 | |
500 size_t nel = m.size (); | |
501 | |
502 for (size_t j = 0; j < nel; j++) | |
503 octave_stdout << m[j] << ((j < nel - 1) ? ", " : "."); | |
504 | |
505 if (nel > 0) | |
506 octave_stdout << std::endl; | |
507 } | |
508 return octave_value (); | |
509 } | |
510 else | |
511 { | |
512 // Fill in an array for return. | |
513 | |
7082 | 514 int i = 0; |
515 Cell names (dim_vector (bp_list.size (), 1)); | |
516 Cell file (dim_vector (bp_list.size (), 1)); | |
517 Cell line (dim_vector (bp_list.size (), 1)); | |
7083 | 518 |
519 for (bp_table::const_fname_line_map_iterator it = bp_list.begin (); | |
520 it != bp_list.end (); it++) | |
3946 | 521 { |
7083 | 522 names(i) = it->first; |
523 line(i) = intmap_to_ov (it->second); | |
524 file(i) = do_which (it->first); | |
7082 | 525 i++; |
3805 | 526 } |
7083 | 527 |
7082 | 528 retval.assign ("name", names); |
529 retval.assign ("file", file); | |
530 retval.assign ("line", line); | |
7083 | 531 |
7082 | 532 return octave_value (retval); |
3805 | 533 } |
534 } | |
535 | |
4208 | 536 DEFCMD (dbwhere, , , |
3805 | 537 "-*- texinfo -*-\n\ |
3895 | 538 @deftypefn {Loadable Function} {} dbwhere ()\n\ |
3805 | 539 Show where we are in the code\n\ |
5642 | 540 @seealso{dbclear, dbstatus, dbstop}\n\ |
5645 | 541 @end deftypefn") |
3805 | 542 { |
543 octave_value retval; | |
3946 | 544 |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
545 octave_user_code *dbg_fcn = get_user_code (); |
3805 | 546 |
547 if (dbg_fcn) | |
548 { | |
4748 | 549 std::string name = dbg_fcn->name (); |
3805 | 550 |
551 octave_stdout << name << ":"; | |
552 | |
553 const tree *dbg_stmt = tree::break_statement; | |
554 | |
555 if (dbg_stmt) | |
556 { | |
7083 | 557 octave_stdout << " line " << dbg_stmt->line () << ", "; |
3805 | 558 octave_stdout << "column " << dbg_stmt->column () << std::endl; |
559 } | |
560 else | |
7083 | 561 octave_stdout << " (unknown line)\n"; |
3805 | 562 } |
563 else | |
3948 | 564 error ("dbwhere: must be inside of a user function to use dbwhere\n"); |
3895 | 565 |
566 return retval; | |
567 } | |
568 | |
569 // Copied and modified from the do_type command in help.cc | |
3946 | 570 // Maybe we could share some code? |
571 void | |
3949 | 572 do_dbtype (std::ostream& os, const std::string& name, int start, int end) |
3895 | 573 { |
574 std::string ff = fcn_file_in_path (name); | |
575 | |
576 if (! ff.empty ()) | |
577 { | |
578 std::ifstream fs (ff.c_str (), std::ios::in); | |
3946 | 579 |
3895 | 580 if (fs) |
3946 | 581 { |
3895 | 582 char ch; |
583 int line = 1; | |
3946 | 584 |
3895 | 585 if (line >= start && line <= end) |
586 os << line << "\t"; | |
3946 | 587 |
3895 | 588 while (fs.get (ch)) |
589 { | |
590 if (line >= start && line <= end) | |
591 { | |
592 os << ch; | |
593 } | |
594 | |
595 if (ch == '\n') | |
596 { | |
597 line++; | |
598 if (line >= start && line <= end) | |
3946 | 599 os << line << "\t"; |
3895 | 600 } |
601 } | |
602 } | |
3946 | 603 else |
3949 | 604 os << "dbtype: unable to open `" << ff << "' for reading!\n"; |
3895 | 605 } |
606 else | |
6317 | 607 os << "dbtype: unknown function " << name << "\n"; |
3895 | 608 |
6646 | 609 os.flush (); |
3895 | 610 } |
611 | |
4208 | 612 DEFCMD (dbtype, args, , |
3895 | 613 "-*- texinfo -*-\n\ |
614 @deftypefn {Loadable Function} {} dbtype ()\n\ | |
615 List script file with line numbers.\n\ | |
5642 | 616 @seealso{dbclear, dbstatus, dbstop}\n\ |
617 @end deftypefn") | |
3895 | 618 { |
619 octave_value retval; | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
620 octave_user_code *dbg_fcn; |
3946 | 621 |
3895 | 622 int nargin = args.length (); |
623 string_vector argv = args.make_argv ("dbtype"); | |
3946 | 624 |
3895 | 625 if (! error_state) |
626 { | |
627 switch (nargin) | |
628 { | |
629 case 0: // dbtype | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
630 dbg_fcn = get_user_code (); |
3895 | 631 |
632 if (dbg_fcn) | |
4748 | 633 do_dbtype (octave_stdout, dbg_fcn->name (), 0, INT_MAX); |
3895 | 634 else |
3948 | 635 error ("dbtype: must be in a user function to give no arguments to dbtype\n"); |
3946 | 636 break; |
3895 | 637 |
3946 | 638 case 1: // (dbtype func) || (dbtype start:end) |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
639 dbg_fcn = get_user_code (argv[1]); |
3895 | 640 |
641 if (dbg_fcn) | |
4748 | 642 do_dbtype (octave_stdout, dbg_fcn->name (), 0, INT_MAX); |
3895 | 643 else |
644 { | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
645 dbg_fcn = get_user_code (); |
3895 | 646 |
647 if (dbg_fcn) | |
648 { | |
3948 | 649 std::string arg = argv[1]; |
650 | |
651 size_t ind = arg.find (':'); | |
3895 | 652 |
8021 | 653 if (ind != std::string::npos) |
3948 | 654 { |
655 std::string start_str = arg.substr (0, ind); | |
656 std::string end_str = arg.substr (ind + 1); | |
657 | |
658 int start = atoi (start_str.c_str ()); | |
659 int end = atoi (end_str.c_str ()); | |
3946 | 660 |
6317 | 661 if (std::min (start, end) <= 0) |
662 error ("dbtype: start and end lines must be >= 1\n"); | |
663 | |
664 if (start <= end) | |
665 do_dbtype (octave_stdout, dbg_fcn->name (), start, end); | |
3948 | 666 else |
6317 | 667 error ("dbtype: start line must be less than end line\n"); |
3895 | 668 } |
3948 | 669 else |
6317 | 670 error ("dbtype: line specification must be `start:end'"); |
3895 | 671 } |
672 } | |
673 break; | |
3946 | 674 |
6317 | 675 case 2: // (dbtype func start:end) , (dbtype func start) |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
676 dbg_fcn = get_user_code (argv[1]); |
3895 | 677 |
678 if (dbg_fcn) | |
679 { | |
3948 | 680 std::string arg = argv[2]; |
6317 | 681 int start = 0; |
682 int end = 0; | |
3948 | 683 size_t ind = arg.find (':'); |
3895 | 684 |
8021 | 685 if (ind != std::string::npos) |
3895 | 686 { |
3948 | 687 std::string start_str = arg.substr (0, ind); |
688 std::string end_str = arg.substr (ind + 1); | |
3895 | 689 |
6317 | 690 start = atoi (start_str.c_str ()); |
691 end = atoi (end_str.c_str ()); | |
692 | |
3948 | 693 } |
694 else | |
6317 | 695 { |
696 start = atoi (arg.c_str ()); | |
697 end = start; | |
698 } | |
699 | |
700 if (std::min (start, end) <= 0) | |
701 error ("dbtype: start and end lines must be >= 1\n"); | |
702 | |
703 if (start <= end) | |
704 do_dbtype (octave_stdout, dbg_fcn->name (), start, end); | |
705 else | |
706 error ("dbtype: start line must be less than end line\n"); | |
3895 | 707 } |
3946 | 708 break; |
3895 | 709 |
710 default: | |
3948 | 711 error ("dbtype: expecting zero, one, or two arguments\n"); |
3895 | 712 } |
713 } | |
3805 | 714 |
715 return retval; | |
716 } | |
717 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
718 DEFCMD (dbstack, args, nargout, |
7736 | 719 "-*- texinfo -*-\n\ |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
720 @deftypefn {Loadable Function} {[@var{stack}, @var{idx}]} dbstack (@var{n})\n\ |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
721 Print or return current stack information. With optional argument\n\ |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
722 @var{n}, omit the @var{n} innermost stack frames.\n\ |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
723 @seealso{dbclear, dbstatus, dbstop}\n\ |
7736 | 724 @end deftypefn") |
725 { | |
726 octave_value_list retval; | |
727 | |
7890 | 728 unwind_protect::begin_frame ("Fdbstack"); |
729 | |
7901 | 730 octave_idx_type curr_frame = -1; |
7890 | 731 |
7901 | 732 size_t nskip = 0; |
7736 | 733 |
734 if (args.length () == 1) | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
735 { |
7890 | 736 int n = 0; |
737 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
738 octave_value arg = args(0); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
739 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
740 if (arg.is_string ()) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
741 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
742 std::string s_arg = arg.string_value (); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
743 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
744 n = atoi (s_arg.c_str ()); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
745 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
746 else |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
747 n = args(0).int_value (); |
7890 | 748 |
749 if (n > 0) | |
7901 | 750 nskip = n; |
7890 | 751 else |
752 error ("dbstack: expecting N to be a nonnegative integer"); | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
753 } |
7736 | 754 |
755 if (! error_state) | |
756 { | |
7901 | 757 Octave_map stk = octave_call_stack::backtrace (nskip, curr_frame); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
758 |
7890 | 759 if (nargout == 0) |
760 { | |
7897 | 761 octave_idx_type nframes_to_display = stk.numel (); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
762 |
7897 | 763 if (nframes_to_display > 0) |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
764 { |
7890 | 765 octave_stdout << "Stopped in:\n\n"; |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
766 |
7890 | 767 Cell names = stk.contents ("name"); |
768 Cell lines = stk.contents ("line"); | |
769 Cell columns = stk.contents ("column"); | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
770 |
7897 | 771 for (octave_idx_type i = 0; i < nframes_to_display; i++) |
7890 | 772 { |
773 octave_value name = names(i); | |
774 octave_value line = lines(i); | |
775 octave_value column = columns(i); | |
776 | |
7901 | 777 octave_stdout << (i == curr_frame ? "--> " : " ") |
7890 | 778 << name.string_value () |
779 << " at line " << line.int_value () | |
780 << " column " << column.int_value () | |
781 << std::endl; | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
782 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
783 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
784 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
785 else |
7890 | 786 { |
7901 | 787 retval(1) = curr_frame < 0 ? 1 : curr_frame + 1; |
7890 | 788 retval(0) = stk; |
789 } | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
790 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
791 |
7890 | 792 unwind_protect::run_frame ("Fdbstack"); |
793 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
794 return retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
795 } |
7736 | 796 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
797 static void |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
798 do_dbupdown (const octave_value_list& args, const std::string& who) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
799 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
800 int n = 1; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
801 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
802 if (args.length () == 1) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
803 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
804 octave_value arg = args(0); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
805 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
806 if (arg.is_string ()) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
807 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
808 std::string s_arg = arg.string_value (); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
809 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
810 n = atoi (s_arg.c_str ()); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
811 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
812 else |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
813 n = args(0).int_value (); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
814 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
815 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
816 if (! error_state) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
817 { |
7890 | 818 if (who == "dbup") |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
819 n = -n; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
820 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
821 if (! octave_call_stack::goto_frame_relative (n, true)) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
822 error ("%s: invalid stack frame", who.c_str ()); |
7736 | 823 } |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
824 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
825 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
826 DEFCMD (dbup, args, , |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
827 "-*- texinfo -*-\n\ |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
828 @deftypefn {Loadable Function} {} dbup (@var{n})\n\ |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
829 In debugging mode, move up the execution stack @var{n} frames.\n\ |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
830 If @var{n} is omitted, move up one frame.\n\ |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
831 @seealso{dbstack}\n\ |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
832 @end deftypefn") |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
833 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
834 octave_value retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
835 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
836 do_dbupdown (args, "dbup"); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
837 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
838 return retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
839 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
840 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
841 DEFCMD (dbdown, args, , |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
842 "-*- texinfo -*-\n\ |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
843 @deftypefn {Loadable Function} {} dbdown (@var{n})\n\ |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
844 In debugging mode, move down the execution stack @var{n} frames.\n\ |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
845 If @var{n} is omitted, move down one frame.\n\ |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
846 @seealso{dbstack}\n\ |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
847 @end deftypefn") |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
848 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
849 octave_value retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
850 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
851 do_dbupdown (args, "dbdown"); |
7736 | 852 |
853 return retval; | |
854 } | |
855 | |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
856 DEFCMD (dbstep, args, , |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
857 "-*- texinfo -*-\n\ |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
858 @deftypefn {Command} {} dbstep @var{n}\n\ |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
859 @deftypefnx {Command} {} dbstep in\n\ |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
860 @deftypefnx {Command} {} dbstep out\n\ |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
861 In debugging mode, execute the next @var{n} lines of code. If @var{n} is\n\ |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
862 omitted execute the next line of code. If the next line of code is itself\n\ |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
863 defined in terms of an m-file remain in the existing function.\n\ |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
864 \n\ |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
865 Using @code{dbstep in} will cause execution of the next line to step into\n\ |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
866 any m-files defined on the next line. Using @code{dbstep out} with cause\n\ |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
867 execution to continue until the current function returns.\n\ |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
868 @seealso{dbcont, dbquit}\n\ |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
869 @end deftypefn") |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
870 { |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
871 if (Vdebugging) |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
872 { |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
873 int nargin = args.length (); |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
874 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
875 if (nargin > 1) |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
876 print_usage (); |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
877 else if (nargin == 1 && args(0).is_string ()) |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
878 { |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
879 std::string arg = args(0).string_value (); |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
880 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
881 if (! error_state) |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
882 { |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
883 if (arg == "in") |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
884 { |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
885 Vdebugging = false; |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
886 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
887 tree::break_next = 0; |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
888 |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
889 tree::last_line = Vdebugging_current_line; |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
890 |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
891 tree::break_function = 0; |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
892 |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
893 tree::last_break_function = |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
894 octave_call_stack::caller_user_code (); |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
895 } |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
896 else if (arg == "out") |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
897 { |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
898 Vdebugging = false; |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
899 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
900 tree::break_next = 0; |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
901 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
902 tree::last_line = -1; |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
903 |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
904 tree::break_function = |
7923
c3d21b9b94b6
eliminate octave_call_stack member functions caller_user_script and caller_user_function, and unused difference_type args
John W. Eaton <jwe@octave.org>
parents:
7901
diff
changeset
|
905 octave_call_stack::caller_user_code (1); |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
906 |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
907 tree::last_break_function = |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
908 octave_call_stack::caller_user_code (); |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
909 } |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
910 else |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
911 { |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
912 int n = atoi (arg.c_str ()); |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
913 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
914 Vdebugging = false; |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
915 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
916 if (n < 0) |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
917 tree::break_next = 0; |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
918 else |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
919 tree::break_next = n; |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
920 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
921 tree::last_line = Vdebugging_current_line; |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
922 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
923 tree::break_function = octave_call_stack::caller_user_code (); |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
924 |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
925 tree::last_break_function = |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
926 octave_call_stack::caller_user_code (); |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
927 } |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
928 } |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
929 } |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
930 else |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
931 { |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
932 Vdebugging = false; |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
933 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
934 tree::break_next = 0; |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
935 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
936 tree::last_line = Vdebugging_current_line; |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
937 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
938 tree::break_function = octave_call_stack::caller_user_code (); |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
939 |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
940 tree::last_break_function = |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
941 octave_call_stack::caller_user_code (); |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
942 } |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
943 } |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
944 else |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
945 error ("dbstep: can only be called in debug mode"); |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
946 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
947 return octave_value_list (); |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
948 } |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
949 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
950 DEFCMD (dbcont, args, , |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
951 "-*- texinfo -*-\n\ |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
952 @deftypefn {Command} {} dbcont ()\n\ |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
953 In debugging mode, quit debugging mode and continue execution.\n\ |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
954 @seealso{dbstep, dbstep}\n\ |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
955 @end deftypefn") |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
956 { |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
957 if (Vdebugging) |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
958 if (args.length() == 0) |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
959 Vdebugging = false; |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
960 else |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
961 print_usage (); |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
962 else |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
963 error ("dbcont: can only be called in debug mode"); |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
964 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
965 return octave_value_list (); |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
966 } |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
967 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
968 DEFCMD (dbquit, args, , |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
969 "-*- texinfo -*-\n\ |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
970 @deftypefn {Command} {} dbquit ()\n\ |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
971 In debugging mode, quit debugging mode and return to the top level.\n\ |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
972 @seealso{dbstep, dbcont}\n\ |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
973 @end deftypefn") |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
974 { |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
975 if (Vdebugging) |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
976 if (args.length() == 0) |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
977 octave_throw_interrupt_exception (); |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
978 else |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
979 print_usage (); |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
980 else |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
981 error ("dbquit: can only be called in debug mode"); |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
982 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
983 return octave_value_list (); |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
984 } |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
985 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
986 DEFCMD (dbnext, args, , |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
987 "-*- texinfo -*-\n\ |
8286
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8123
diff
changeset
|
988 @deftypefn {Command} {} dbnext ()\n\ |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
989 In debugging mode, execute the next line of code without stepping in to\n\ |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
990 functions. This is synonymous with @code{dbstep}.\n\ |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
991 @seealso{dbstep, dbcont, dbquit}\n\ |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
992 @end deftypefn") |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
993 { |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
994 if (Vdebugging) |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
995 { |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
996 if (args.length() == 0) |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
997 { |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
998 Vdebugging = false; |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
999 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1000 tree::break_next = 0; |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1001 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1002 tree::last_line = Vdebugging_current_line; |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1003 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1004 tree::break_function = octave_call_stack::caller_user_code (); |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1005 |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1006 tree::last_break_function = octave_call_stack::caller_user_code (); |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1007 } |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1008 else |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1009 print_usage (); |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1010 } |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1011 else |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1012 error ("dbnext: can only be called in debug mode"); |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1013 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1014 return octave_value_list (); |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1015 } |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1016 |
8114
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1017 DEFCMD (isdebugmode, args, , |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1018 "-*- texinfo -*-\n\ |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1019 @deftypefn {Command} {} isdebugmode ()\n\ |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1020 Return true if debug mode is on, otherwise false.\n\ |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1021 @seealso{dbstack, dbclear, dbstop, dbstatus}\n\ |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1022 @end deftypefn") |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1023 { |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1024 octave_value retval; |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1025 |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1026 if (args.length() == 0) |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1027 retval = Vdebugging; |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1028 else |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1029 print_usage (); |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1030 |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1031 return retval; |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1032 } |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1033 |
3805 | 1034 /* |
1035 ;;; Local Variables: *** | |
1036 ;;; mode: C++ *** | |
1037 ;;; End: *** | |
1038 */ |