Mercurial > hg > octave-lyh
annotate src/debug.cc @ 9724:f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
which were causing bad entries in the function index.
author | Rik <rdrider0-list@yahoo.com> |
---|---|
date | Tue, 13 Oct 2009 21:10:37 -0700 |
parents | bbe033dcfe13 |
children | 2cd940306a06 |
rev | line source |
---|---|
3805 | 1 /* |
2 | |
8920 | 3 Copyright (C) 2007, 2008, 2009 John Swensen |
7348 | 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 |
8677
095ae5e0a831
eliminte some compiler warnings
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
156 while (eol > 0 && (buf[eol-1] == '\n' || buf[eol-1] == '\r')) |
8658
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) |
9183
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
280 { |
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
281 bp_set.insert (fname); |
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
282 } |
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
|
283 } |
7082 | 284 } |
285 } | |
286 } | |
287 else | |
288 error ("add_breakpoint: unable to find the function requested\n"); | |
289 | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
290 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
|
291 |
7082 | 292 return retval; |
293 } | |
294 | |
295 | |
296 int | |
7083 | 297 bp_table::do_remove_breakpoint (const std::string& fname, |
298 const bp_table::intmap& line) | |
7082 | 299 { |
7083 | 300 int retval = 0; |
7082 | 301 |
302 octave_idx_type len = line.size (); | |
303 | |
304 if (len == 0) | |
305 { | |
306 intmap results = remove_all_breakpoints_in_file (fname); | |
307 retval = results.size (); | |
308 } | |
309 else | |
310 { | |
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
|
311 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
|
312 |
7082 | 313 if (dbg_fcn) |
314 { | |
315 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
|
316 |
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 if (cmds) |
7082 | 318 { |
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
|
319 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
|
320 |
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 if (results.length () > 0) |
7348 | 322 { |
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
|
323 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
|
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 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
|
326 |
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 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
|
328 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
|
329 } |
7083 | 330 |
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
|
331 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
|
332 |
9183
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
333 bp_set_iterator it = bp_set.find (fname); |
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
334 if (results.length () == 0 && it != bp_set.end ()) |
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
335 bp_set.erase (it); |
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
|
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 } |
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
|
338 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
339 retval = results.length (); |
7082 | 340 } |
341 } | |
342 else | |
343 error ("remove_breakpoint: unable to find the function requested\n"); | |
344 } | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
345 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
346 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
|
347 |
7082 | 348 return retval; |
349 } | |
350 | |
351 | |
7083 | 352 bp_table::intmap |
8123
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
8114
diff
changeset
|
353 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
|
354 bool silent) |
7082 | 355 { |
7083 | 356 intmap retval; |
7082 | 357 |
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
|
358 octave_user_code *dbg_fcn = get_user_code (fname); |
7082 | 359 |
360 if (dbg_fcn) | |
361 { | |
362 tree_statement_list *cmds = dbg_fcn->body (); | |
7083 | 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 if (cmds) |
7082 | 365 { |
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
|
366 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
|
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 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
|
369 { |
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 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
|
371 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
|
372 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
|
373 } |
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 |
9183
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
375 bp_set_iterator it = bp_set.find (fname); |
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
376 if (it != bp_set.end ()) |
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
377 bp_set.erase (it); |
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
|
378 |
7082 | 379 } |
380 } | |
8123
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
8114
diff
changeset
|
381 else if (! silent) |
7082 | 382 error ("remove_all_breakpoint_in_file: " |
383 "unable to find the function requested\n"); | |
384 | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
385 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
|
386 |
7082 | 387 return retval; |
388 } | |
389 | |
390 void | |
7083 | 391 bp_table::do_remove_all_breakpoints (void) |
7082 | 392 { |
9183
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
393 for (const_bp_set_iterator it = bp_set.begin (); it != bp_set.end (); it++) |
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
394 remove_all_breakpoints_in_file (*it); |
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
395 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
396 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
397 tree_evaluator::debug_mode = bp_table::have_breakpoints (); |
7082 | 398 } |
399 | |
400 std::string | |
401 do_find_bkpt_list (octave_value_list slist, | |
402 std::string match) | |
403 { | |
404 std::string retval; | |
7083 | 405 |
7082 | 406 for (int i = 0; i < slist.length (); i++) |
407 { | |
408 if (slist (i).string_value () == match) | |
409 { | |
7083 | 410 retval = slist(i).string_value (); |
7082 | 411 break; |
412 } | |
413 } | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
414 |
7082 | 415 return retval; |
416 } | |
417 | |
418 | |
7083 | 419 bp_table::fname_line_map |
420 bp_table::do_get_breakpoint_list (const octave_value_list& fname_list) | |
7082 | 421 { |
7083 | 422 fname_line_map retval; |
7082 | 423 |
9183
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
424 for (bp_set_iterator it = bp_set.begin (); it != bp_set.end (); it++) |
7082 | 425 { |
7083 | 426 if (fname_list.length () == 0 |
9183
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
427 || do_find_bkpt_list (fname_list, *it) != "") |
7082 | 428 { |
9183
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
429 octave_user_code *f = get_user_code (*it); |
7083 | 430 |
9183
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
431 if (f) |
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
|
432 { |
9183
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
433 tree_statement_list *cmds = f->body (); |
7083 | 434 |
9183
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
435 if (cmds) |
8123
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
8114
diff
changeset
|
436 { |
9183
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
437 octave_value_list bkpts = cmds->list_breakpoints (); |
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
438 octave_idx_type len = bkpts.length (); |
7083 | 439 |
9183
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
440 if (len > 0) |
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
441 { |
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
442 bp_table::intmap bkpts_vec; |
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
443 |
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
444 for (int i = 0; i < len; i++) |
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
445 bkpts_vec[i] = bkpts (i).double_value (); |
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
446 |
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
447 std::string symbol_name = f->name (); |
7083 | 448 |
9183
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
449 retval[symbol_name] = bkpts_vec; |
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
450 } |
8123
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
8114
diff
changeset
|
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 } |
7082 | 453 } |
454 } | |
7083 | 455 |
7082 | 456 return retval; |
457 } | |
458 | |
459 static octave_value | |
7083 | 460 intmap_to_ov (const bp_table::intmap& line) |
7082 | 461 { |
462 int idx = 0; | |
7083 | 463 |
464 NDArray retval (dim_vector (1, line.size ())); | |
465 | |
466 for (size_t i = 0; i < line.size (); i++) | |
7082 | 467 { |
7083 | 468 bp_table::const_intmap_iterator p = line.find (i); |
469 | |
7082 | 470 if (p != line.end ()) |
471 { | |
472 int lineno = p->second; | |
7083 | 473 retval(idx++) = lineno; |
7082 | 474 } |
475 } | |
7083 | 476 |
7082 | 477 retval.resize (dim_vector (1, idx)); |
7083 | 478 |
7082 | 479 return retval; |
480 } | |
3895 | 481 |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
482 DEFUN (dbstop, args, , |
3805 | 483 "-*- texinfo -*-\n\ |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
484 @deftypefn {Loadable Function} {@var{rline} =} dbstop (@var{func}, @var{line}, @dots{})\n\ |
3805 | 485 Set a breakpoint in a function\n\ |
486 @table @code\n\ | |
487 @item func\n\ | |
488 String representing the function name. When already in debug\n\ | |
489 mode this should be left out and only the line should be given.\n\ | |
490 @item line\n\ | |
9039
51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
491 Line number you would like the breakpoint to be set on. Multiple\n\ |
7001 | 492 lines might be given as separate arguments or as a vector.\n\ |
3805 | 493 @end table\n\ |
494 \n\ | |
495 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
|
496 @seealso{dbclear, dbstatus, dbstep}\n\ |
5642 | 497 @end deftypefn") |
3805 | 498 { |
7083 | 499 bp_table::intmap retval; |
500 std::string symbol_name; | |
501 bp_table::intmap lines; | |
502 | |
7348 | 503 parse_dbfunction_params ("dbstop", args, symbol_name, lines); |
6646 | 504 |
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
|
505 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
|
506 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
|
507 |
7083 | 508 if (! error_state) |
7082 | 509 retval = bp_table::add_breakpoint (symbol_name, lines); |
3805 | 510 |
7083 | 511 return intmap_to_ov (retval); |
3805 | 512 } |
513 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
514 DEFUN (dbclear, args, , |
3805 | 515 "-*- texinfo -*-\n\ |
7083 | 516 @deftypefn {Loadable Function} {} dbclear (@var{func}, @var{line}, @dots{})\n\ |
3805 | 517 Delete a breakpoint in a function\n\ |
518 @table @code\n\ | |
519 @item func\n\ | |
520 String representing the function name. When already in debug\n\ | |
521 mode this should be left out and only the line should be given.\n\ | |
522 @item line\n\ | |
9039
51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
523 Line number where you would like to remove the breakpoint. Multiple\n\ |
7001 | 524 lines might be given as separate arguments or as a vector.\n\ |
3805 | 525 @end table\n\ |
526 No checking is done to make sure that the line you requested is really\n\ | |
9039
51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
527 a breakpoint. If you get the wrong line nothing will happen.\n\ |
5642 | 528 @seealso{dbstop, dbstatus, dbwhere}\n\ |
529 @end deftypefn") | |
3805 | 530 { |
531 octave_value retval; | |
532 std::string symbol_name = ""; | |
7083 | 533 bp_table::intmap lines; |
534 | |
7348 | 535 parse_dbfunction_params ("dbclear", args, symbol_name, lines); |
7082 | 536 |
7083 | 537 if (! error_state) |
7082 | 538 bp_table::remove_breakpoint (symbol_name, lines); |
3805 | 539 |
540 return retval; | |
541 } | |
542 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
543 DEFUN (dbstatus, args, nargout, |
3805 | 544 "-*- texinfo -*-\n\ |
7083 | 545 @deftypefn {Loadable Function} {lst =} dbstatus (@var{func})\n\ |
3805 | 546 Return a vector containing the lines on which a function has \n\ |
547 breakpoints set.\n\ | |
548 @table @code\n\ | |
549 @item func\n\ | |
550 String representing the function name. When already in debug\n\ | |
551 mode this should be left out.\n\ | |
552 @end table\n\ | |
5642 | 553 @seealso{dbclear, dbwhere}\n\ |
554 @end deftypefn") | |
3805 | 555 { |
7082 | 556 Octave_map retval; |
3805 | 557 int nargin = args.length (); |
7082 | 558 octave_value_list fcn_list; |
7083 | 559 bp_table::fname_line_map bp_list; |
560 std::string symbol_name; | |
3805 | 561 |
562 if (nargin != 0 && nargin != 1) | |
563 { | |
3948 | 564 error ("dbstatus: only zero or one arguements accepted\n"); |
7082 | 565 return octave_value (); |
3805 | 566 } |
567 | |
568 if (nargin == 1) | |
569 { | |
570 if (args(0).is_string ()) | |
7082 | 571 { |
7083 | 572 symbol_name = args(0).string_value (); |
573 fcn_list(0) = symbol_name; | |
7082 | 574 bp_list = bp_table::get_breakpoint_list (fcn_list); |
575 } | |
3805 | 576 else |
7083 | 577 gripe_wrong_type_arg ("dbstatus", args(0)); |
7082 | 578 } |
579 else | |
580 { | |
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
|
581 octave_user_code *dbg_fcn = get_user_code (); |
7082 | 582 if (dbg_fcn) |
583 { | |
584 symbol_name = dbg_fcn->name (); | |
7083 | 585 fcn_list(0) = symbol_name; |
7082 | 586 } |
7083 | 587 |
7082 | 588 bp_list = bp_table::get_breakpoint_list (fcn_list); |
3805 | 589 } |
590 | |
7083 | 591 if (nargout == 0) |
3805 | 592 { |
7083 | 593 // Print out the breakpoint information. |
594 | |
595 for (bp_table::fname_line_map_iterator it = bp_list.begin (); | |
596 it != bp_list.end (); it++) | |
597 { | |
598 octave_stdout << "Breakpoint in " << it->first << " at line(s) "; | |
599 | |
600 bp_table::intmap m = it->second; | |
601 | |
602 size_t nel = m.size (); | |
603 | |
604 for (size_t j = 0; j < nel; j++) | |
605 octave_stdout << m[j] << ((j < nel - 1) ? ", " : "."); | |
606 | |
607 if (nel > 0) | |
608 octave_stdout << std::endl; | |
609 } | |
610 return octave_value (); | |
611 } | |
612 else | |
613 { | |
614 // Fill in an array for return. | |
615 | |
7082 | 616 int i = 0; |
617 Cell names (dim_vector (bp_list.size (), 1)); | |
618 Cell file (dim_vector (bp_list.size (), 1)); | |
619 Cell line (dim_vector (bp_list.size (), 1)); | |
7083 | 620 |
621 for (bp_table::const_fname_line_map_iterator it = bp_list.begin (); | |
622 it != bp_list.end (); it++) | |
3946 | 623 { |
7083 | 624 names(i) = it->first; |
625 line(i) = intmap_to_ov (it->second); | |
626 file(i) = do_which (it->first); | |
7082 | 627 i++; |
3805 | 628 } |
7083 | 629 |
7082 | 630 retval.assign ("name", names); |
631 retval.assign ("file", file); | |
632 retval.assign ("line", line); | |
7083 | 633 |
7082 | 634 return octave_value (retval); |
3805 | 635 } |
636 } | |
637 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
638 DEFUN (dbwhere, , , |
3805 | 639 "-*- texinfo -*-\n\ |
3895 | 640 @deftypefn {Loadable Function} {} dbwhere ()\n\ |
3805 | 641 Show where we are in the code\n\ |
5642 | 642 @seealso{dbclear, dbstatus, dbstop}\n\ |
5645 | 643 @end deftypefn") |
3805 | 644 { |
645 octave_value retval; | |
3946 | 646 |
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
|
647 octave_user_code *dbg_fcn = get_user_code (); |
3805 | 648 |
649 if (dbg_fcn) | |
650 { | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
651 bool have_file = true; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
652 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
653 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
|
654 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
655 if (name.empty ()) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
656 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
657 have_file = false; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
658 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
659 name = dbg_fcn->name (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
660 } |
3805 | 661 |
662 octave_stdout << name << ":"; | |
663 | |
9484
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9377
diff
changeset
|
664 unwind_protect::frame_id_t uwp_frame = unwind_protect::begin_frame (); |
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9377
diff
changeset
|
665 |
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9377
diff
changeset
|
666 unwind_protect::add_fcn (octave_call_stack::restore_frame, |
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9377
diff
changeset
|
667 octave_call_stack::current_frame ()); |
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9377
diff
changeset
|
668 |
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9377
diff
changeset
|
669 // Skip the frame assigned to the dbwhere function. |
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9377
diff
changeset
|
670 octave_call_stack::goto_frame_relative (0); |
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9377
diff
changeset
|
671 |
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9377
diff
changeset
|
672 int l = octave_call_stack::current_line (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
673 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
674 if (l > 0) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
675 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
676 octave_stdout << " line " << l; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
677 |
9484
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9377
diff
changeset
|
678 int c = octave_call_stack::current_column (); |
3805 | 679 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
680 if (c > 0) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
681 octave_stdout << ", column " << c; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
682 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
683 octave_stdout << std::endl; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
684 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
685 if (have_file) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
686 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
687 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
|
688 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
689 if (! line.empty ()) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
690 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
|
691 } |
3805 | 692 } |
693 else | |
7083 | 694 octave_stdout << " (unknown line)\n"; |
9484
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9377
diff
changeset
|
695 |
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9377
diff
changeset
|
696 unwind_protect::run_frame (uwp_frame); |
3805 | 697 } |
698 else | |
3948 | 699 error ("dbwhere: must be inside of a user function to use dbwhere\n"); |
3895 | 700 |
701 return retval; | |
702 } | |
703 | |
704 // Copied and modified from the do_type command in help.cc | |
3946 | 705 // Maybe we could share some code? |
706 void | |
3949 | 707 do_dbtype (std::ostream& os, const std::string& name, int start, int end) |
3895 | 708 { |
709 std::string ff = fcn_file_in_path (name); | |
710 | |
711 if (! ff.empty ()) | |
712 { | |
713 std::ifstream fs (ff.c_str (), std::ios::in); | |
3946 | 714 |
3895 | 715 if (fs) |
3946 | 716 { |
3895 | 717 char ch; |
718 int line = 1; | |
3946 | 719 |
3895 | 720 if (line >= start && line <= end) |
721 os << line << "\t"; | |
3946 | 722 |
3895 | 723 while (fs.get (ch)) |
724 { | |
725 if (line >= start && line <= end) | |
726 { | |
727 os << ch; | |
728 } | |
729 | |
730 if (ch == '\n') | |
731 { | |
732 line++; | |
733 if (line >= start && line <= end) | |
3946 | 734 os << line << "\t"; |
3895 | 735 } |
736 } | |
737 } | |
3946 | 738 else |
3949 | 739 os << "dbtype: unable to open `" << ff << "' for reading!\n"; |
3895 | 740 } |
741 else | |
6317 | 742 os << "dbtype: unknown function " << name << "\n"; |
3895 | 743 |
6646 | 744 os.flush (); |
3895 | 745 } |
746 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
747 DEFUN (dbtype, args, , |
3895 | 748 "-*- texinfo -*-\n\ |
749 @deftypefn {Loadable Function} {} dbtype ()\n\ | |
750 List script file with line numbers.\n\ | |
5642 | 751 @seealso{dbclear, dbstatus, dbstop}\n\ |
752 @end deftypefn") | |
3895 | 753 { |
754 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
|
755 octave_user_code *dbg_fcn; |
3946 | 756 |
3895 | 757 int nargin = args.length (); |
758 string_vector argv = args.make_argv ("dbtype"); | |
3946 | 759 |
3895 | 760 if (! error_state) |
761 { | |
762 switch (nargin) | |
763 { | |
764 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
|
765 dbg_fcn = get_user_code (); |
3895 | 766 |
767 if (dbg_fcn) | |
4748 | 768 do_dbtype (octave_stdout, dbg_fcn->name (), 0, INT_MAX); |
3895 | 769 else |
3948 | 770 error ("dbtype: must be in a user function to give no arguments to dbtype\n"); |
3946 | 771 break; |
3895 | 772 |
3946 | 773 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
|
774 dbg_fcn = get_user_code (argv[1]); |
3895 | 775 |
776 if (dbg_fcn) | |
4748 | 777 do_dbtype (octave_stdout, dbg_fcn->name (), 0, INT_MAX); |
3895 | 778 else |
779 { | |
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
|
780 dbg_fcn = get_user_code (); |
3895 | 781 |
782 if (dbg_fcn) | |
783 { | |
3948 | 784 std::string arg = argv[1]; |
785 | |
786 size_t ind = arg.find (':'); | |
3895 | 787 |
8021 | 788 if (ind != std::string::npos) |
3948 | 789 { |
790 std::string start_str = arg.substr (0, ind); | |
791 std::string end_str = arg.substr (ind + 1); | |
792 | |
793 int start = atoi (start_str.c_str ()); | |
794 int end = atoi (end_str.c_str ()); | |
3946 | 795 |
6317 | 796 if (std::min (start, end) <= 0) |
797 error ("dbtype: start and end lines must be >= 1\n"); | |
798 | |
799 if (start <= end) | |
800 do_dbtype (octave_stdout, dbg_fcn->name (), start, end); | |
3948 | 801 else |
6317 | 802 error ("dbtype: start line must be less than end line\n"); |
3895 | 803 } |
3948 | 804 else |
6317 | 805 error ("dbtype: line specification must be `start:end'"); |
3895 | 806 } |
807 } | |
808 break; | |
3946 | 809 |
6317 | 810 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
|
811 dbg_fcn = get_user_code (argv[1]); |
3895 | 812 |
813 if (dbg_fcn) | |
814 { | |
3948 | 815 std::string arg = argv[2]; |
6317 | 816 int start = 0; |
817 int end = 0; | |
3948 | 818 size_t ind = arg.find (':'); |
3895 | 819 |
8021 | 820 if (ind != std::string::npos) |
3895 | 821 { |
3948 | 822 std::string start_str = arg.substr (0, ind); |
823 std::string end_str = arg.substr (ind + 1); | |
3895 | 824 |
6317 | 825 start = atoi (start_str.c_str ()); |
826 end = atoi (end_str.c_str ()); | |
827 | |
3948 | 828 } |
829 else | |
6317 | 830 { |
831 start = atoi (arg.c_str ()); | |
832 end = start; | |
833 } | |
834 | |
835 if (std::min (start, end) <= 0) | |
836 error ("dbtype: start and end lines must be >= 1\n"); | |
837 | |
838 if (start <= end) | |
839 do_dbtype (octave_stdout, dbg_fcn->name (), start, end); | |
840 else | |
841 error ("dbtype: start line must be less than end line\n"); | |
3895 | 842 } |
3946 | 843 break; |
3895 | 844 |
845 default: | |
3948 | 846 error ("dbtype: expecting zero, one, or two arguments\n"); |
3895 | 847 } |
848 } | |
3805 | 849 |
850 return retval; | |
851 } | |
852 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
853 DEFUN (dbstack, args, nargout, |
7736 | 854 "-*- texinfo -*-\n\ |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
855 @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
|
856 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
|
857 @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
|
858 @seealso{dbclear, dbstatus, dbstop}\n\ |
7736 | 859 @end deftypefn") |
860 { | |
861 octave_value_list retval; | |
862 | |
9377
610bf90fce2a
update unwind_protect usage everywhere
Jaroslav Hajek <highegg@gmail.com>
parents:
9183
diff
changeset
|
863 unwind_protect::frame_id_t uwp_frame = unwind_protect::begin_frame (); |
7890 | 864 |
7901 | 865 octave_idx_type curr_frame = -1; |
7890 | 866 |
7901 | 867 size_t nskip = 0; |
7736 | 868 |
869 if (args.length () == 1) | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
870 { |
7890 | 871 int n = 0; |
872 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
873 octave_value arg = args(0); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
874 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
875 if (arg.is_string ()) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
876 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
877 std::string s_arg = arg.string_value (); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
878 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
879 n = atoi (s_arg.c_str ()); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
880 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
881 else |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
882 n = args(0).int_value (); |
7890 | 883 |
884 if (n > 0) | |
7901 | 885 nskip = n; |
7890 | 886 else |
887 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
|
888 } |
7736 | 889 |
890 if (! error_state) | |
891 { | |
7901 | 892 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
|
893 |
7890 | 894 if (nargout == 0) |
895 { | |
7897 | 896 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
|
897 |
7897 | 898 if (nframes_to_display > 0) |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
899 { |
7890 | 900 octave_stdout << "Stopped in:\n\n"; |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
901 |
7890 | 902 Cell names = stk.contents ("name"); |
903 Cell lines = stk.contents ("line"); | |
904 Cell columns = stk.contents ("column"); | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
905 |
7897 | 906 for (octave_idx_type i = 0; i < nframes_to_display; i++) |
7890 | 907 { |
908 octave_value name = names(i); | |
909 octave_value line = lines(i); | |
910 octave_value column = columns(i); | |
911 | |
7901 | 912 octave_stdout << (i == curr_frame ? "--> " : " ") |
7890 | 913 << name.string_value () |
914 << " at line " << line.int_value () | |
915 << " column " << column.int_value () | |
916 << std::endl; | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
917 } |
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 else |
7890 | 921 { |
7901 | 922 retval(1) = curr_frame < 0 ? 1 : curr_frame + 1; |
7890 | 923 retval(0) = stk; |
924 } | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
925 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
926 |
9377
610bf90fce2a
update unwind_protect usage everywhere
Jaroslav Hajek <highegg@gmail.com>
parents:
9183
diff
changeset
|
927 unwind_protect::run_frame (uwp_frame); |
7890 | 928 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
929 return retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
930 } |
7736 | 931 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
932 static void |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
933 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
|
934 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
935 int n = 1; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
936 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
937 if (args.length () == 1) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
938 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
939 octave_value arg = args(0); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
940 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
941 if (arg.is_string ()) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
942 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
943 std::string s_arg = arg.string_value (); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
944 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
945 n = atoi (s_arg.c_str ()); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
946 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
947 else |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
948 n = args(0).int_value (); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
949 } |
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 if (! error_state) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
952 { |
7890 | 953 if (who == "dbup") |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
954 n = -n; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
955 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
956 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
|
957 error ("%s: invalid stack frame", who.c_str ()); |
7736 | 958 } |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
959 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
960 |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
961 DEFUN (dbup, args, , |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
962 "-*- texinfo -*-\n\ |
9724
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9484
diff
changeset
|
963 @deftypefn {Loadable Function} {} dbup\n\ |
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9484
diff
changeset
|
964 @deftypefnx {Loadable Function} {} dbup (@var{n})\n\ |
7752
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 |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
977 DEFUN (dbdown, args, , |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
978 "-*- texinfo -*-\n\ |
9724
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9484
diff
changeset
|
979 @deftypefn {Loadable Function} {} dbdown\n\ |
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9484
diff
changeset
|
980 @deftypefnx {Loadable Function} {} dbdown (@var{n})\n\ |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
981 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
|
982 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
|
983 @seealso{dbstack}\n\ |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
984 @end deftypefn") |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
985 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
986 octave_value retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
987 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
988 do_dbupdown (args, "dbdown"); |
7736 | 989 |
990 return retval; | |
991 } | |
992 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
993 DEFUN (dbstep, args, , |
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
|
994 "-*- texinfo -*-\n\ |
9724
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9484
diff
changeset
|
995 @deftypefn {Command} {} dbstep\n\ |
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9484
diff
changeset
|
996 @deftypefnx {Command} {} dbstep @var{n}\n\ |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
997 @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
|
998 @deftypefnx {Command} {} dbstep out\n\ |
9724
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9484
diff
changeset
|
999 In debugging mode, execute the next @var{n} lines of code.\n\ |
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9484
diff
changeset
|
1000 If @var{n} is omitted , execute the next single line of code.\n\ |
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9484
diff
changeset
|
1001 If the next line of code is itself\n\ |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1002 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
|
1003 \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 Using @code{dbstep in} will cause execution of the next line to step into\n\ |
9724
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9484
diff
changeset
|
1005 any m-files defined on the next line. Using @code{dbstep out} will cause\n\ |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1006 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
|
1007 @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
|
1008 @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
|
1009 { |
6b521b1e3631
Add 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 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
|
1011 { |
6b521b1e3631
Add 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 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
|
1013 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1014 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
|
1015 print_usage (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1016 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
|
1017 { |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1018 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
|
1019 { |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1020 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
|
1021 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1022 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
|
1023 { |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1024 if (arg == "in") |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1025 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1026 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
|
1027 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1028 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
|
1029 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1030 else if (arg == "out") |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1031 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1032 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
|
1033 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1034 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
|
1035 } |
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 else |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1037 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1038 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
|
1039 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1040 if (n > 0) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1041 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1042 Vdebugging = false; |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1043 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1044 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
|
1045 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1046 else |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1047 error ("dbstep: invalid argument"); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1048 } |
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
|
1049 } |
6b521b1e3631
Add 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 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1051 else |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1052 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
|
1053 } |
6b521b1e3631
Add 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 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
|
1055 { |
6b521b1e3631
Add 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 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
|
1057 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1058 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
|
1059 } |
6b521b1e3631
Add 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 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
|
1062 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
|
1063 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1064 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
|
1065 } |
6b521b1e3631
Add 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 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1067 DEFALIAS (dbnext, dbstep); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1068 |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
1069 DEFUN (dbcont, args, , |
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
|
1070 "-*- texinfo -*-\n\ |
9724
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9484
diff
changeset
|
1071 @deftypefn {Command} {} dbcont\n\ |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1072 In debugging mode, quit debugging mode and continue execution.\n\ |
9724
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9484
diff
changeset
|
1073 @seealso{dbstep, dbquit}\n\ |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1074 @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
|
1075 { |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1076 if (Vdebugging) |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1077 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1078 if (args.length () == 0) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1079 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1080 Vdebugging = false; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1081 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1082 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
|
1083 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1084 else |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1085 print_usage (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1086 } |
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
|
1087 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
|
1088 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
|
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 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
|
1091 } |
6b521b1e3631
Add 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 |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
1093 DEFUN (dbquit, args, , |
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
|
1094 "-*- texinfo -*-\n\ |
9724
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9484
diff
changeset
|
1095 @deftypefn {Command} {} dbquit\n\ |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1096 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
|
1097 @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
|
1098 @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
|
1099 { |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1100 if (Vdebugging) |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1101 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1102 if (args.length () == 0) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1103 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1104 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
|
1105 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1106 octave_throw_interrupt_exception (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1107 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1108 else |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1109 print_usage (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1110 } |
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
|
1111 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
|
1112 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
|
1113 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1114 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
|
1115 } |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1116 |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
1117 DEFUN (isdebugmode, args, , |
8114
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1118 "-*- texinfo -*-\n\ |
9724
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9484
diff
changeset
|
1119 @deftypefn {Loadable Function} {} isdebugmode ()\n\ |
8114
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1120 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
|
1121 @seealso{dbstack, dbclear, dbstop, dbstatus}\n\ |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1122 @end deftypefn") |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1123 { |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1124 octave_value retval; |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1125 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1126 if (args.length () == 0) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1127 retval = Vdebugging; |
8114
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1128 else |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1129 print_usage (); |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1130 |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1131 return retval; |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1132 } |
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
|
1133 |
3805 | 1134 /* |
1135 ;;; Local Variables: *** | |
1136 ;;; mode: C++ *** | |
1137 ;;; End: *** | |
1138 */ |