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