Mercurial > hg > octave-lyh
annotate src/debug.cc @ 7818:5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
author | David Bateman <dbateman@free.fr> |
---|---|
date | Sun, 25 May 2008 15:04:37 +0200 |
parents | 6b521b1e3631 |
children | 73ef513855e7 |
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 ()) |
5744 | 70 dbg_fcn = octave_call_stack::caller_user_function (); |
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 |
7539
3e107d73aeb4
debug.cc: use find_function instead of find_user_function
John Swensen
parents:
7348
diff
changeset
|
75 if (fcn.is_defined ()) |
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 |
241 bp_table::do_remove_all_breakpoints_in_file (const std::string& fname) | |
7082 | 242 { |
7083 | 243 intmap retval; |
7082 | 244 |
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
|
245 octave_user_code *dbg_fcn = get_user_code (fname); |
7082 | 246 |
247 if (dbg_fcn) | |
248 { | |
249 tree_statement_list *cmds = dbg_fcn->body (); | |
7083 | 250 |
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
|
251 if (cmds) |
7082 | 252 { |
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
|
253 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
|
254 |
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 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
|
256 { |
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 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
|
258 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
|
259 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
|
260 } |
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 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
|
263 |
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 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
|
265 bp_map.erase (it); |
7082 | 266 } |
267 } | |
268 else | |
269 error ("remove_all_breakpoint_in_file: " | |
270 "unable to find the function requested\n"); | |
271 | |
272 return retval; | |
273 } | |
274 | |
275 void | |
7083 | 276 bp_table::do_remove_all_breakpoints (void) |
7082 | 277 { |
7083 | 278 for (const_breakpoint_map_iterator it = bp_map.begin (); |
279 it != bp_map.end (); it++) | |
280 remove_all_breakpoints_in_file (it->first); | |
7082 | 281 } |
282 | |
283 std::string | |
284 do_find_bkpt_list (octave_value_list slist, | |
285 std::string match) | |
286 { | |
287 std::string retval; | |
7083 | 288 |
7082 | 289 for (int i = 0; i < slist.length (); i++) |
290 { | |
291 if (slist (i).string_value () == match) | |
292 { | |
7083 | 293 retval = slist(i).string_value (); |
7082 | 294 break; |
295 } | |
296 } | |
297 return retval; | |
298 } | |
299 | |
300 | |
7083 | 301 bp_table::fname_line_map |
302 bp_table::do_get_breakpoint_list (const octave_value_list& fname_list) | |
7082 | 303 { |
7083 | 304 fname_line_map retval; |
7082 | 305 |
306 // Iterate through each of the files in the map and get the | |
7083 | 307 // name and list of breakpoints. |
308 | |
309 for (breakpoint_map_iterator it = bp_map.begin (); it != bp_map.end (); it++) | |
7082 | 310 { |
7083 | 311 if (fname_list.length () == 0 |
312 || do_find_bkpt_list (fname_list, it->first) != "") | |
7082 | 313 { |
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
|
314 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
|
315 |
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
|
316 tree_statement_list *cmds = f->body (); |
7083 | 317 |
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
|
318 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
|
319 { |
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
|
320 octave_value_list bkpts = cmds->list_breakpoints (); |
7083 | 321 |
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
|
322 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
|
323 |
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
|
324 bp_table::intmap bkpts_vec; |
7083 | 325 |
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
|
326 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
|
327 bkpts_vec[i] = bkpts (i).double_value (); |
7083 | 328 |
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
|
329 retval[it->first] = bkpts_vec; |
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
|
330 } |
7082 | 331 } |
332 } | |
7083 | 333 |
7082 | 334 return retval; |
335 } | |
336 | |
337 static octave_value | |
7083 | 338 intmap_to_ov (const bp_table::intmap& line) |
7082 | 339 { |
340 int idx = 0; | |
7083 | 341 |
342 NDArray retval (dim_vector (1, line.size ())); | |
343 | |
344 for (size_t i = 0; i < line.size (); i++) | |
7082 | 345 { |
7083 | 346 bp_table::const_intmap_iterator p = line.find (i); |
347 | |
7082 | 348 if (p != line.end ()) |
349 { | |
350 int lineno = p->second; | |
7083 | 351 retval(idx++) = lineno; |
7082 | 352 } |
353 } | |
7083 | 354 |
7082 | 355 retval.resize (dim_vector (1, idx)); |
7083 | 356 |
7082 | 357 return retval; |
358 } | |
3895 | 359 |
4208 | 360 DEFCMD (dbstop, args, , |
3805 | 361 "-*- texinfo -*-\n\ |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
362 @deftypefn {Loadable Function} {@var{rline} =} dbstop (@var{func}, @var{line}, @dots{})\n\ |
3805 | 363 Set a breakpoint in a function\n\ |
364 @table @code\n\ | |
365 @item func\n\ | |
366 String representing the function name. When already in debug\n\ | |
367 mode this should be left out and only the line should be given.\n\ | |
368 @item line\n\ | |
6646 | 369 Line you would like the breakpoint to be set on. Multiple\n\ |
7001 | 370 lines might be given as separate arguments or as a vector.\n\ |
3805 | 371 @end table\n\ |
372 \n\ | |
373 The rline returned is the real line that the breakpoint was set at.\n\ | |
5642 | 374 @seealso{dbclear, dbstatus, dbnext}\n\ |
375 @end deftypefn") | |
3805 | 376 { |
7083 | 377 bp_table::intmap retval; |
378 std::string symbol_name; | |
379 bp_table::intmap lines; | |
380 | |
7348 | 381 parse_dbfunction_params ("dbstop", args, symbol_name, lines); |
6646 | 382 |
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
|
383 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
|
384 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
|
385 |
7083 | 386 if (! error_state) |
7082 | 387 retval = bp_table::add_breakpoint (symbol_name, lines); |
3805 | 388 |
7083 | 389 return intmap_to_ov (retval); |
3805 | 390 } |
391 | |
4208 | 392 DEFCMD (dbclear, args, , |
3805 | 393 "-*- texinfo -*-\n\ |
7083 | 394 @deftypefn {Loadable Function} {} dbclear (@var{func}, @var{line}, @dots{})\n\ |
3805 | 395 Delete a breakpoint in a function\n\ |
396 @table @code\n\ | |
397 @item func\n\ | |
398 String representing the function name. When already in debug\n\ | |
399 mode this should be left out and only the line should be given.\n\ | |
400 @item line\n\ | |
6653 | 401 Line where you would like to remove the breakpoint. Multiple\n\ |
7001 | 402 lines might be given as separate arguments or as a vector.\n\ |
3805 | 403 @end table\n\ |
404 No checking is done to make sure that the line you requested is really\n\ | |
6646 | 405 a breakpoint. If you get the wrong line nothing will happen.\n\ |
5642 | 406 @seealso{dbstop, dbstatus, dbwhere}\n\ |
407 @end deftypefn") | |
3805 | 408 { |
409 octave_value retval; | |
410 std::string symbol_name = ""; | |
7083 | 411 bp_table::intmap lines; |
412 | |
7348 | 413 parse_dbfunction_params ("dbclear", args, symbol_name, lines); |
7082 | 414 |
7083 | 415 if (! error_state) |
7082 | 416 bp_table::remove_breakpoint (symbol_name, lines); |
3805 | 417 |
418 return retval; | |
419 } | |
420 | |
7082 | 421 DEFCMD (dbstatus, args, nargout, |
3805 | 422 "-*- texinfo -*-\n\ |
7083 | 423 @deftypefn {Loadable Function} {lst =} dbstatus (@var{func})\n\ |
3805 | 424 Return a vector containing the lines on which a function has \n\ |
425 breakpoints set.\n\ | |
426 @table @code\n\ | |
427 @item func\n\ | |
428 String representing the function name. When already in debug\n\ | |
429 mode this should be left out.\n\ | |
430 @end table\n\ | |
5642 | 431 @seealso{dbclear, dbwhere}\n\ |
432 @end deftypefn") | |
3805 | 433 { |
7082 | 434 Octave_map retval; |
3805 | 435 int nargin = args.length (); |
7082 | 436 octave_value_list fcn_list; |
7083 | 437 bp_table::fname_line_map bp_list; |
438 std::string symbol_name; | |
3805 | 439 |
440 if (nargin != 0 && nargin != 1) | |
441 { | |
3948 | 442 error ("dbstatus: only zero or one arguements accepted\n"); |
7082 | 443 return octave_value (); |
3805 | 444 } |
445 | |
446 if (nargin == 1) | |
447 { | |
448 if (args(0).is_string ()) | |
7082 | 449 { |
7083 | 450 symbol_name = args(0).string_value (); |
451 fcn_list(0) = symbol_name; | |
7082 | 452 bp_list = bp_table::get_breakpoint_list (fcn_list); |
453 } | |
3805 | 454 else |
7083 | 455 gripe_wrong_type_arg ("dbstatus", args(0)); |
7082 | 456 } |
457 else | |
458 { | |
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
|
459 octave_user_code *dbg_fcn = get_user_code (); |
7082 | 460 if (dbg_fcn) |
461 { | |
462 symbol_name = dbg_fcn->name (); | |
7083 | 463 fcn_list(0) = symbol_name; |
7082 | 464 } |
7083 | 465 |
7082 | 466 bp_list = bp_table::get_breakpoint_list (fcn_list); |
3805 | 467 } |
468 | |
7083 | 469 if (nargout == 0) |
3805 | 470 { |
7083 | 471 // Print out the breakpoint information. |
472 | |
473 for (bp_table::fname_line_map_iterator it = bp_list.begin (); | |
474 it != bp_list.end (); it++) | |
475 { | |
476 octave_stdout << "Breakpoint in " << it->first << " at line(s) "; | |
477 | |
478 bp_table::intmap m = it->second; | |
479 | |
480 size_t nel = m.size (); | |
481 | |
482 for (size_t j = 0; j < nel; j++) | |
483 octave_stdout << m[j] << ((j < nel - 1) ? ", " : "."); | |
484 | |
485 if (nel > 0) | |
486 octave_stdout << std::endl; | |
487 } | |
488 return octave_value (); | |
489 } | |
490 else | |
491 { | |
492 // Fill in an array for return. | |
493 | |
7082 | 494 int i = 0; |
495 Cell names (dim_vector (bp_list.size (), 1)); | |
496 Cell file (dim_vector (bp_list.size (), 1)); | |
497 Cell line (dim_vector (bp_list.size (), 1)); | |
7083 | 498 |
499 for (bp_table::const_fname_line_map_iterator it = bp_list.begin (); | |
500 it != bp_list.end (); it++) | |
3946 | 501 { |
7083 | 502 names(i) = it->first; |
503 line(i) = intmap_to_ov (it->second); | |
504 file(i) = do_which (it->first); | |
7082 | 505 i++; |
3805 | 506 } |
7083 | 507 |
7082 | 508 retval.assign ("name", names); |
509 retval.assign ("file", file); | |
510 retval.assign ("line", line); | |
7083 | 511 |
7082 | 512 return octave_value (retval); |
3805 | 513 } |
514 } | |
515 | |
4208 | 516 DEFCMD (dbwhere, , , |
3805 | 517 "-*- texinfo -*-\n\ |
3895 | 518 @deftypefn {Loadable Function} {} dbwhere ()\n\ |
3805 | 519 Show where we are in the code\n\ |
5642 | 520 @seealso{dbclear, dbstatus, dbstop}\n\ |
5645 | 521 @end deftypefn") |
3805 | 522 { |
523 octave_value retval; | |
3946 | 524 |
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
|
525 octave_user_code *dbg_fcn = get_user_code (); |
3805 | 526 |
527 if (dbg_fcn) | |
528 { | |
4748 | 529 std::string name = dbg_fcn->name (); |
3805 | 530 |
531 octave_stdout << name << ":"; | |
532 | |
533 const tree *dbg_stmt = tree::break_statement; | |
534 | |
535 if (dbg_stmt) | |
536 { | |
7083 | 537 octave_stdout << " line " << dbg_stmt->line () << ", "; |
3805 | 538 octave_stdout << "column " << dbg_stmt->column () << std::endl; |
539 } | |
540 else | |
7083 | 541 octave_stdout << " (unknown line)\n"; |
3805 | 542 } |
543 else | |
3948 | 544 error ("dbwhere: must be inside of a user function to use dbwhere\n"); |
3895 | 545 |
546 return retval; | |
547 } | |
548 | |
549 // Copied and modified from the do_type command in help.cc | |
3946 | 550 // Maybe we could share some code? |
551 void | |
3949 | 552 do_dbtype (std::ostream& os, const std::string& name, int start, int end) |
3895 | 553 { |
554 std::string ff = fcn_file_in_path (name); | |
555 | |
556 if (! ff.empty ()) | |
557 { | |
558 std::ifstream fs (ff.c_str (), std::ios::in); | |
3946 | 559 |
3895 | 560 if (fs) |
3946 | 561 { |
3895 | 562 char ch; |
563 int line = 1; | |
3946 | 564 |
3895 | 565 if (line >= start && line <= end) |
566 os << line << "\t"; | |
3946 | 567 |
3895 | 568 while (fs.get (ch)) |
569 { | |
570 if (line >= start && line <= end) | |
571 { | |
572 os << ch; | |
573 } | |
574 | |
575 if (ch == '\n') | |
576 { | |
577 line++; | |
578 if (line >= start && line <= end) | |
3946 | 579 os << line << "\t"; |
3895 | 580 } |
581 } | |
582 } | |
3946 | 583 else |
3949 | 584 os << "dbtype: unable to open `" << ff << "' for reading!\n"; |
3895 | 585 } |
586 else | |
6317 | 587 os << "dbtype: unknown function " << name << "\n"; |
3895 | 588 |
6646 | 589 os.flush (); |
3895 | 590 } |
591 | |
4208 | 592 DEFCMD (dbtype, args, , |
3895 | 593 "-*- texinfo -*-\n\ |
594 @deftypefn {Loadable Function} {} dbtype ()\n\ | |
595 List script file with line numbers.\n\ | |
5642 | 596 @seealso{dbclear, dbstatus, dbstop}\n\ |
597 @end deftypefn") | |
3895 | 598 { |
599 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
|
600 octave_user_code *dbg_fcn; |
3946 | 601 |
3895 | 602 int nargin = args.length (); |
603 string_vector argv = args.make_argv ("dbtype"); | |
3946 | 604 |
3895 | 605 if (! error_state) |
606 { | |
607 switch (nargin) | |
608 { | |
609 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
|
610 dbg_fcn = get_user_code (); |
3895 | 611 |
612 if (dbg_fcn) | |
4748 | 613 do_dbtype (octave_stdout, dbg_fcn->name (), 0, INT_MAX); |
3895 | 614 else |
3948 | 615 error ("dbtype: must be in a user function to give no arguments to dbtype\n"); |
3946 | 616 break; |
3895 | 617 |
3946 | 618 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
|
619 dbg_fcn = get_user_code (argv[1]); |
3895 | 620 |
621 if (dbg_fcn) | |
4748 | 622 do_dbtype (octave_stdout, dbg_fcn->name (), 0, INT_MAX); |
3895 | 623 else |
624 { | |
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
|
625 dbg_fcn = get_user_code (); |
3895 | 626 |
627 if (dbg_fcn) | |
628 { | |
3948 | 629 std::string arg = argv[1]; |
630 | |
631 size_t ind = arg.find (':'); | |
3895 | 632 |
3948 | 633 if (ind != NPOS) |
634 { | |
635 std::string start_str = arg.substr (0, ind); | |
636 std::string end_str = arg.substr (ind + 1); | |
637 | |
638 int start = atoi (start_str.c_str ()); | |
639 int end = atoi (end_str.c_str ()); | |
3946 | 640 |
6317 | 641 if (std::min (start, end) <= 0) |
642 error ("dbtype: start and end lines must be >= 1\n"); | |
643 | |
644 if (start <= end) | |
645 do_dbtype (octave_stdout, dbg_fcn->name (), start, end); | |
3948 | 646 else |
6317 | 647 error ("dbtype: start line must be less than end line\n"); |
3895 | 648 } |
3948 | 649 else |
6317 | 650 error ("dbtype: line specification must be `start:end'"); |
3895 | 651 } |
652 } | |
653 break; | |
3946 | 654 |
6317 | 655 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
|
656 dbg_fcn = get_user_code (argv[1]); |
3895 | 657 |
658 if (dbg_fcn) | |
659 { | |
3948 | 660 std::string arg = argv[2]; |
6317 | 661 int start = 0; |
662 int end = 0; | |
3948 | 663 size_t ind = arg.find (':'); |
3895 | 664 |
3948 | 665 if (ind != NPOS) |
3895 | 666 { |
3948 | 667 std::string start_str = arg.substr (0, ind); |
668 std::string end_str = arg.substr (ind + 1); | |
3895 | 669 |
6317 | 670 start = atoi (start_str.c_str ()); |
671 end = atoi (end_str.c_str ()); | |
672 | |
3948 | 673 } |
674 else | |
6317 | 675 { |
676 start = atoi (arg.c_str ()); | |
677 end = start; | |
678 } | |
679 | |
680 if (std::min (start, end) <= 0) | |
681 error ("dbtype: start and end lines must be >= 1\n"); | |
682 | |
683 if (start <= end) | |
684 do_dbtype (octave_stdout, dbg_fcn->name (), start, end); | |
685 else | |
686 error ("dbtype: start line must be less than end line\n"); | |
3895 | 687 } |
3946 | 688 break; |
3895 | 689 |
690 default: | |
3948 | 691 error ("dbtype: expecting zero, one, or two arguments\n"); |
3895 | 692 } |
693 } | |
3805 | 694 |
695 return retval; | |
696 } | |
697 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
698 DEFCMD (dbstack, args, nargout, |
7736 | 699 "-*- texinfo -*-\n\ |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
700 @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
|
701 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
|
702 @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
|
703 @seealso{dbclear, dbstatus, dbstop}\n\ |
7736 | 704 @end deftypefn") |
705 { | |
706 octave_value_list retval; | |
707 | |
708 int n = 0; | |
709 | |
710 if (args.length () == 1) | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
711 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
712 octave_value arg = args(0); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
713 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
714 if (arg.is_string ()) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
715 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
716 std::string s_arg = arg.string_value (); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
717 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
718 n = atoi (s_arg.c_str ()); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
719 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
720 else |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
721 n = args(0).int_value (); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
722 } |
7736 | 723 |
724 if (! error_state) | |
725 { | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
726 if (n >= 0) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
727 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
728 size_t curr_frame = octave_call_stack::current_frame (); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
729 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
730 // Skip dbstack stack frame. |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
731 if (! Vdebugging) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
732 curr_frame++; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
733 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
734 // Adjust so that this is the index of where we are in the array |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
735 // that is returned in retval(0). |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
736 size_t idx = curr_frame - n; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
737 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
738 // Add one here to skip the __dbstack__ stack frame. |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
739 Octave_map stk = octave_call_stack::backtrace (curr_frame + n); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
740 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
741 if (nargout == 0) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
742 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
743 octave_idx_type nframes = stk.numel (); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
744 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
745 if (nframes > 0) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
746 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
747 octave_stdout << "Stopped in:\n\n"; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
748 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
749 Cell names = stk.contents ("name"); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
750 Cell lines = stk.contents ("line"); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
751 Cell columns = stk.contents ("column"); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
752 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
753 for (octave_idx_type i = 0; i < nframes; i++) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
754 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
755 octave_value name = names(i); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
756 octave_value line = lines(i); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
757 octave_value column = columns(i); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
758 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
759 octave_stdout << (i == idx - 1 ? "--> " : " ") |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
760 << name.string_value () |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
761 << " at line " << line.int_value () |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
762 << " column " << column.int_value () |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
763 << std::endl; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
764 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
765 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
766 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
767 else |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
768 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
769 retval(1) = idx; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
770 retval(0) = stk; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
771 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
772 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
773 else |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
774 error ("dbstack: expecting N to be a nonnegative integer"); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
775 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
776 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
777 return retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
778 } |
7736 | 779 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
780 static void |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
781 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
|
782 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
783 int n = 1; |
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 if (args.length () == 1) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
786 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
787 octave_value arg = args(0); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
788 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
789 if (arg.is_string ()) |
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 std::string s_arg = arg.string_value (); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
792 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
793 n = atoi (s_arg.c_str ()); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
794 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
795 else |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
796 n = args(0).int_value (); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
797 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
798 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
799 if (! error_state) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
800 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
801 if (who == "dbdown") |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
802 n = -n; |
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 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
|
805 error ("%s: invalid stack frame", who.c_str ()); |
7736 | 806 } |
7752
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 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
809 DEFCMD (dbup, args, , |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
810 "-*- texinfo -*-\n\ |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
811 @deftypefn {Loadable Function} {} dbup (@var{n})\n\ |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
812 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
|
813 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
|
814 @seealso{dbstack}\n\ |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
815 @end deftypefn") |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
816 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
817 octave_value retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
818 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
819 do_dbupdown (args, "dbup"); |
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 return retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
822 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
823 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
824 DEFCMD (dbdown, args, , |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
825 "-*- texinfo -*-\n\ |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
826 @deftypefn {Loadable Function} {} dbdown (@var{n})\n\ |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
827 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
|
828 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
|
829 @seealso{dbstack}\n\ |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
830 @end deftypefn") |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
831 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
832 octave_value retval; |
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 do_dbupdown (args, "dbdown"); |
7736 | 835 |
836 return retval; | |
837 } | |
838 | |
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
|
839 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
|
840 "-*- 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
|
841 @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
|
842 @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
|
843 @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
|
844 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
|
845 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
|
846 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
|
847 \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
|
848 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
|
849 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
|
850 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
|
851 @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
|
852 @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
|
853 { |
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
|
854 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
|
855 { |
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 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
|
857 |
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 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
|
859 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
|
860 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
|
861 { |
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 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
|
863 |
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 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
|
865 { |
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 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
|
867 { |
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 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
|
869 |
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 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
|
871 |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
872 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
|
873 |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
874 tree::break_function = 0; |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
875 |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
876 tree::last_break_function = |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
877 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
|
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 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
|
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 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
|
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 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
|
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 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
|
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 // Next to skip 2 here. One for the oct-file dbstep and |
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 // another for the function we actually want to step out of. |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
889 tree::break_function = |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
890 octave_call_stack::caller_user_code (2); |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
891 |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
892 tree::last_break_function = |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
893 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
|
894 } |
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 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
|
896 { |
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 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
|
898 |
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 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
|
900 |
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 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
|
902 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
|
903 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
|
904 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
|
905 |
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
|
906 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
|
907 |
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
|
908 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
|
909 |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
910 tree::last_break_function = |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
911 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
|
912 } |
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 } |
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 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
|
916 { |
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 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
|
918 |
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 = 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
|
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 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
|
930 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
|
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 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
|
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 |
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 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
|
936 "-*- 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
|
937 @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
|
938 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
|
939 @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
|
940 @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
|
941 { |
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 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
|
943 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
|
944 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
|
945 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
|
946 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
|
947 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
|
948 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
|
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 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
|
951 } |
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 |
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 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
|
954 "-*- 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
|
955 @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
|
956 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
|
957 @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
|
958 @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
|
959 { |
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 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
|
961 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
|
962 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
|
963 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
|
964 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
|
965 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
|
966 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
|
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 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
|
969 } |
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 |
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 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
|
972 "-*- 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
|
973 @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
|
974 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
|
975 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
|
976 @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
|
977 @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
|
978 { |
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 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
|
980 { |
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 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
|
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 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
|
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 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
|
986 |
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 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
|
988 |
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 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
|
990 |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
991 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
|
992 } |
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 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
|
994 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
|
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 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
|
997 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
|
998 |
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 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
|
1000 } |
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 |
3805 | 1003 /* |
1004 ;;; Local Variables: *** | |
1005 ;;; mode: C++ *** | |
1006 ;;; End: *** | |
1007 */ |