Mercurial > octave
annotate libinterp/corefcn/debug.cc @ 21628:37a44d8af461
Allow dbstop @class/method with forward slash on Windows (bug #47575).
* debug.cc (get_user_code): Explicitly translate '/' to file_sep_char
for '@' classes.
author | Lachlan Andrew <lachlanbis@gmail.com> |
---|---|
date | Sun, 10 Apr 2016 10:22:18 +1000 |
parents | 555b6c78d677 |
children | 9810e483b42f |
rev | line source |
---|---|
3805 | 1 /* |
2 | |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19597
diff
changeset
|
3 Copyright (C) 2001-2015 Ben Sapp |
11523 | 4 Copyright (C) 2007-2009 John Swensen |
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 | |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21259
diff
changeset
|
24 # include "config.h" |
3805 | 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> |
10839 | 29 #include <iomanip> |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
30 #include <iostream> |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
31 #include <set> |
3948 | 32 #include <string> |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
33 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
34 #include "file-stat.h" |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
35 #include "singleton-cleanup.h" |
7082 | 36 |
3805 | 37 #include "defun.h" |
38 #include "error.h" | |
21258
b248c28d9a7b
Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
39 #include "file-ops.h" |
7082 | 40 #include "help.h" |
3805 | 41 #include "input.h" |
42 #include "pager.h" | |
16418
e1d92db3a715
use octave-link instead of hooks for breakpoint set/clear functions
John W. Eaton <jwe@octave.org>
parents:
16386
diff
changeset
|
43 #include "octave-link.h" |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20925
diff
changeset
|
44 #include "ovl.h" |
3805 | 45 #include "utils.h" |
46 #include "parse.h" | |
47 #include "symtab.h" | |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21094
diff
changeset
|
48 #include "errwarn.h" |
20925
667861ffffab
Extracted header class octave-preserve-stream-state from utils.{cc/h}.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20918
diff
changeset
|
49 #include "octave-preserve-stream-state.h" |
3805 | 50 #include "ov.h" |
51 #include "ov-usr-fcn.h" | |
52 #include "ov-fcn.h" | |
7082 | 53 #include "ov-struct.h" |
3805 | 54 #include "pt-pr-code.h" |
55 #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
|
56 #include "pt-eval.h" |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
57 #include "pt-exp.h" |
3805 | 58 #include "pt-stmt.h" |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
59 #include "sighandlers.h" |
3805 | 60 #include "toplev.h" |
61 #include "unwind-prot.h" | |
17818
f1b59ef34eda
attempt to avoid setting persistent state on i/o streams (bug #40396)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
62 #include "utils.h" |
3805 | 63 #include "variables.h" |
64 | |
7082 | 65 #include "debug.h" |
66 | |
67 // Initialize the singleton object | |
7083 | 68 bp_table *bp_table::instance = 0; |
7082 | 69 |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
70 std::set<std::string> bp_table::errors_that_stop; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
71 std::set<std::string> bp_table::caught_that_stop; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
72 std::set<std::string> bp_table::warnings_that_stop; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
73 |
21562
6c2fd62db1f7
maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents:
21547
diff
changeset
|
74 // Read entire file called fname and return the contents as a string |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
75 static std::string |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
76 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
|
77 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
78 std::string retval; |
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_stat fs (fname); |
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 (fs) |
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 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
|
85 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
86 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
|
87 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
88 if (file) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
89 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
90 std::string buf (sz+1, 0); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
91 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
92 file.read (&buf[0], sz+1); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
93 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
94 if (! file.eof ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
95 error ("error reading file %s", fname.c_str ()); |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
96 |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
97 // Expected to read the entire file. |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
98 retval = buf; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
99 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
100 } |
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 return retval; |
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 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
105 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
|
106 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
|
107 { |
21259 | 108 // FIXME: This could maybe be smarter. Is deque the right thing to use here? |
8658
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 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
|
111 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
112 offsets.push_back (0); |
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 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
|
115 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
116 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
|
117 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
118 char c = buf[i]; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
119 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
120 if (c == '\r' && ++i < len) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
121 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
122 c = buf[i]; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
123 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
124 if (c == '\n') |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
125 offsets.push_back (i+1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
126 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
127 offsets.push_back (i); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
128 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
129 else if (c == '\n') |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
130 offsets.push_back (i+1); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
131 } |
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 offsets.push_back (len); |
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 return offsets; |
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 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
138 std::string |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
139 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
|
140 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
141 std::string retval; |
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 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
|
144 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
145 static std::string 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 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
|
148 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
149 if (fname != last_fname) |
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 buf = snarf_file (fname); |
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 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
|
154 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
155 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
156 if (line > 0) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
157 line--; |
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 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
|
160 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
161 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
|
162 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
|
163 |
10839 | 164 while (eol > 0 && eol > bol && (buf[eol-1] == '\n' || buf[eol-1] == '\r')) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
165 eol--; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
166 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
167 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
|
168 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
169 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
170 return retval; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
171 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
172 |
5743 | 173 // Return a pointer to the user-defined function FNAME. If FNAME is |
174 // empty, search backward for the first user-defined function in the | |
175 // current call stack. | |
7083 | 176 |
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
|
177 static octave_user_code * |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20980
diff
changeset
|
178 get_user_code (const std::string& fname = "") |
3805 | 179 { |
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
|
180 octave_user_code *dbg_fcn = 0; |
3805 | 181 |
7083 | 182 if (fname.empty ()) |
21322
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21318
diff
changeset
|
183 dbg_fcn = octave_call_stack::debug_user_code (); |
5743 | 184 else |
3805 | 185 { |
18236
0806c9e75e08
strip .m when setting or clearing breakpoints (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
17818
diff
changeset
|
186 std::string name = fname; |
0806c9e75e08
strip .m when setting or clearing breakpoints (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
17818
diff
changeset
|
187 |
21628
37a44d8af461
Allow dbstop @class/method with forward slash on Windows (bug #47575).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21623
diff
changeset
|
188 if (file_ops::dir_sep_char () != '/' && name[0] == '@') |
37a44d8af461
Allow dbstop @class/method with forward slash on Windows (bug #47575).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21623
diff
changeset
|
189 { |
37a44d8af461
Allow dbstop @class/method with forward slash on Windows (bug #47575).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21623
diff
changeset
|
190 int len = name.length () - 1; // -1: can't have trailing '/' |
37a44d8af461
Allow dbstop @class/method with forward slash on Windows (bug #47575).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21623
diff
changeset
|
191 for (int i = 2; i < len; i++) // 2: can't have @/method |
37a44d8af461
Allow dbstop @class/method with forward slash on Windows (bug #47575).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21623
diff
changeset
|
192 if (name[i] == '/') |
37a44d8af461
Allow dbstop @class/method with forward slash on Windows (bug #47575).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21623
diff
changeset
|
193 name[i] = file_ops::dir_sep_char (); |
37a44d8af461
Allow dbstop @class/method with forward slash on Windows (bug #47575).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21623
diff
changeset
|
194 } |
37a44d8af461
Allow dbstop @class/method with forward slash on Windows (bug #47575).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21623
diff
changeset
|
195 |
18236
0806c9e75e08
strip .m when setting or clearing breakpoints (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
17818
diff
changeset
|
196 size_t name_len = name.length (); |
0806c9e75e08
strip .m when setting or clearing breakpoints (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
17818
diff
changeset
|
197 |
0806c9e75e08
strip .m when setting or clearing breakpoints (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
17818
diff
changeset
|
198 if (! name.empty () && name_len > 2 && name.substr (name_len-2) == ".m") |
0806c9e75e08
strip .m when setting or clearing breakpoints (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
17818
diff
changeset
|
199 name = name.substr (0, name_len-2); |
0806c9e75e08
strip .m when setting or clearing breakpoints (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
17818
diff
changeset
|
200 |
0806c9e75e08
strip .m when setting or clearing breakpoints (bug #41126)
John W. Eaton <jwe@octave.org>
parents:
17818
diff
changeset
|
201 octave_value fcn = symbol_table::find_function (name); |
3946 | 202 |
8123
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
8114
diff
changeset
|
203 if (fcn.is_defined () && fcn.is_user_code ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
204 dbg_fcn = fcn.user_code_value (); |
3805 | 205 } |
206 | |
207 return dbg_fcn; | |
208 } | |
209 | |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
210 #ifdef DBSTOP_NANINF |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21157
diff
changeset
|
211 # include "sigfpe.cc" |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
212 #endif |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
213 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
214 enum |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
215 dbstop_args {dbstop_in, dbstop_at, dbstop_if, dbstop_none}; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
216 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
217 // Parse parameters (args) of dbstop and dbclear commands. |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
218 // For dbstop, who=="dbstop"; for dbclear, who=="dbclear". |
21562
6c2fd62db1f7
maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents:
21547
diff
changeset
|
219 // The syntax is: dbstop [[in] symbol] [[at] line [line [...]]] [if condition] |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
220 // where the form of condition depends on whether or not a file or line has |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
221 // been seen. |
21562
6c2fd62db1f7
maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents:
21547
diff
changeset
|
222 // Also execute "if [error|warning|interrupt|naninf]" clauses. |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
223 void |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
224 parse_dbfunction_params (const char *who, const octave_value_list& args, |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
225 std::string& symbol_name, bp_table::intmap& lines, |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
226 std::string& cond) |
7082 | 227 { |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
228 int nargin = args.length (); |
7082 | 229 int list_idx = 0; |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20980
diff
changeset
|
230 symbol_name = ""; |
7348 | 231 lines = bp_table::intmap (); |
232 | |
21259 | 233 if (nargin == 0 || ! args(0).is_string ()) |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
234 print_usage (who); |
21259 | 235 |
236 // elements already processed | |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
237 bool seen_in = false, seen_at = false, seen_if = false; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
238 int pos = 0; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
239 dbstop_args token = dbstop_none; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
240 while (pos < nargin) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19855
diff
changeset
|
241 { |
21259 | 242 // allow "in" and "at" to be implicit |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
243 if (args(pos).is_string ()) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19855
diff
changeset
|
244 { |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
245 std::string arg = args(pos).string_value (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
246 if (arg == "in") |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
247 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
248 token = dbstop_in; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
249 pos++; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
250 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
251 else if (arg == "at") |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
252 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
253 token = dbstop_at; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
254 pos++; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
255 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
256 else if (arg == "if") |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
257 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
258 token = dbstop_if; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
259 pos++; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
260 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
261 else if (atoi (args(pos).string_value ().c_str ()) > 0) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
262 token = dbstop_at; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
263 else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
264 token = dbstop_in; |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19855
diff
changeset
|
265 } |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19855
diff
changeset
|
266 else |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
267 token = dbstop_at; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
268 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
269 if (pos >= nargin) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
270 error ("%s: '%s' missing argument", who, |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
271 ( token == dbstop_in ? "in" : |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
272 (token == dbstop_at ? "at" : "if"))); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
273 |
21259 | 274 // process the actual arguments |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
275 switch (token) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19855
diff
changeset
|
276 { |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
277 case dbstop_in: |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
278 symbol_name = args(pos).string_value (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
279 if (seen_in) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
280 error ("%s: Too many function names specified -- %s", |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
281 who, symbol_name.c_str ()); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
282 else if (seen_at || seen_if) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
283 error ("%s: function name must come before line number and 'if'", |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
284 who); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
285 seen_in = true; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
286 pos++; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
287 break; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
288 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
289 case dbstop_at: |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
290 if (seen_at) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
291 error ("%s: Only one 'at' clause is allowed -- %s", |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
292 who, args(pos).string_value ().c_str ()); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
293 else if (seen_if) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
294 error ("%s: line number must come before 'if' clause\n"); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
295 seen_at = true; |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
296 |
21259 | 297 if (! seen_in) |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
298 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
299 // It was a line number. Get function name from debugger. |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
300 if (Vdebugging) |
21623
555b6c78d677
Fix regression preventing "dbstop <line>" in debug mode (bug #47621)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21580
diff
changeset
|
301 symbol_name = get_user_code ()->profiler_name (); |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
302 else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
303 error ("%s: function name must come before line number " |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
304 "and 'if'", who); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
305 seen_in = true; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
306 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
307 else if (seen_if) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
308 error ("%s: line number must come before 'if' clause\n"); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
309 |
21259 | 310 // Read a list of line numbers (or arrays thereof) |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
311 for ( ; pos < nargin; pos++) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
312 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
313 if (args(pos).is_string ()) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
314 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
315 int line = atoi (args(pos).string_value ().c_str ()); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
316 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
317 if (line > 0) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
318 lines[list_idx++] = line; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
319 else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
320 break; // may be "if" |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
321 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
322 else if (args(pos).is_numeric_type ()) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
323 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
324 const NDArray arg = args(pos).array_value (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
325 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
326 for (octave_idx_type j = 0; j < arg.numel (); j++) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
327 lines[list_idx++] = static_cast<int> (arg.elem (j)); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
328 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
329 else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
330 error ("%s: Invalid argument type %s", |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
331 args(pos).type_name ().c_str ()); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
332 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
333 break; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
334 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
335 case dbstop_if: |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
336 if (seen_in) // conditional breakpoint |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
337 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
338 cond = ""; // remaining arguments form condition |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
339 for (; pos < nargin; pos++) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
340 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
341 if (args(pos).is_string ()) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
342 cond = cond + " " + args(pos).string_value (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
343 else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
344 error ("%s: arguments to 'if' must all be strings", who); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
345 } |
7082 | 346 |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
347 cond = cond.substr (1); // omit initial space |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
348 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
349 else // stop on event (error, warning, interrupt, NaN/inf) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
350 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
351 std::string condition = args(pos).string_value (); |
21259 | 352 int on_off = ! strcmp(who, "dbstop"); |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
353 |
21259 | 354 // list of error/warning IDs to update |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
355 std::set<std::string> *id_list = NULL; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
356 bool *stop_flag = NULL; // Vdebug_on_... flag |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
357 |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
358 if (condition == "error") |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
359 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
360 id_list = &bp_table::errors_that_stop; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
361 stop_flag = &Vdebug_on_error; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
362 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
363 else if (condition == "warning") |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
364 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
365 id_list = &bp_table::warnings_that_stop; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
366 stop_flag = &Vdebug_on_warning; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
367 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
368 else if (condition == "caught" && nargin > pos+1 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
369 && args(pos+1).string_value () == "error") |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
370 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
371 id_list = &bp_table::caught_that_stop; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
372 stop_flag = &Vdebug_on_caught; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
373 pos++; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
374 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
375 else if (condition == "interrupt") |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
376 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
377 Vdebug_on_interrupt = on_off; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
378 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
379 else if (condition == "naninf") |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
380 #ifdef DBSTOP_NANINF |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
381 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
382 Vdebug_on_naninf = on_off; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
383 enable_fpe (on_off); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
384 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
385 #else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
386 warning ("%s: condition '%s' not yet supported", |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
387 who, condition.c_str ()); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
388 #endif |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
389 else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
390 error ("%s: invalid condition %s", |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
391 who, condition.c_str ()); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
392 |
21259 | 393 // process ID list for "dbstop if error <error_ID>" etc |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
394 if (id_list != NULL) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
395 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
396 pos++; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
397 if (pos < nargin) // only affect a single error ID |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
398 { |
21259 | 399 if (! args(pos).is_string () || nargin > pos+1) |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
400 error ("%s: ID must be a single string", who); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
401 else if (on_off == 1) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
402 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
403 id_list->insert (args(pos).string_value ()); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
404 *stop_flag = 1; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
405 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
406 else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
407 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
408 id_list->erase (args(pos).string_value ()); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
409 if (id_list->empty ()) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
410 *stop_flag = 0; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
411 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
412 } |
21259 | 413 else // unqualified. Turn all on or off |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
414 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
415 id_list->clear (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
416 *stop_flag = on_off; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
417 if (stop_flag == &Vdebug_on_error) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
418 Vdebug_on_interrupt = on_off; // Matlabs stops on both |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
419 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
420 } |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
421 |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
422 pos = nargin; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
423 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
424 break; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
425 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
426 default: // dbstop_none should never occur |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
427 break; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
428 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
429 } |
7082 | 430 } |
431 | |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
432 /* |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
433 %!test |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
434 %! dbstop help; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
435 %! dbstop in ls; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
436 %! dbstop help at 100; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
437 %! dbstop in ls 100; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
438 %! dbstop help 200 if a==5; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
439 %! dbstop if error Octave:undefined-function |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
440 %! s = dbstatus; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
441 %! dbclear all |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
442 %! assert ({s.bkpt(:).name}, {"help", "help", "help>do_contents", "ls", "ls"}); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
443 %! assert ([s.bkpt(:).line], [48, 100, 200, 58, 100]); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
444 %! assert (s.errs, {"Octave:undefined-function"}); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
445 */ |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
446 |
21562
6c2fd62db1f7
maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents:
21547
diff
changeset
|
447 // Return true if there is a valid breakpoint table, false otherwise. |
6c2fd62db1f7
maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents:
21547
diff
changeset
|
448 // If no table exists, one is created; false is only returned if this fails. |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
449 bool |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
450 bp_table::instance_ok (void) |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
451 { |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
452 if (! instance) |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
453 { |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
454 instance = new bp_table (); |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
455 |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
456 if (instance) |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
457 singleton_cleanup_list::add (cleanup_instance); |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
458 } |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
459 |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
460 if (! instance) |
20831
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20819
diff
changeset
|
461 error ("unable to create breakpoint table!"); |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
462 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
463 return true; |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
464 } |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
465 |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
466 // Clear all reasons to stop, other than breakpoints |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
467 void |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
468 bp_table::dbclear_all_signals (void) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
469 { |
21568
3d60ed163b70
maint: Eliminate bad spacing around '='.
Rik <rik@octave.org>
parents:
21562
diff
changeset
|
470 Vdebug_on_error = false; bp_table::errors_that_stop.clear (); |
3d60ed163b70
maint: Eliminate bad spacing around '='.
Rik <rik@octave.org>
parents:
21562
diff
changeset
|
471 Vdebug_on_caught = false; bp_table::caught_that_stop.clear (); |
3d60ed163b70
maint: Eliminate bad spacing around '='.
Rik <rik@octave.org>
parents:
21562
diff
changeset
|
472 Vdebug_on_warning = false; bp_table::warnings_that_stop.clear (); |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
473 Vdebug_on_interrupt = false; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
474 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
475 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
476 // Process the "warn", "errs", "caught" and "intr" fields for a call of |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
477 // "dbstop (p)". |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
478 void |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
479 bp_table::dbstop_process_map_args (const octave_map& mv) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
480 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
481 // process errs |
21259 | 482 // why so many levels of indirection needed? |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
483 bool fail = false; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
484 Cell U = mv.contents ("errs"); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
485 if (U.numel () != 1) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
486 fail = (U.numel () > 1); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
487 else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
488 { |
21358
f2ae78f5827f
Resolve compile time issues, when octave_idx_type is long.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
21329
diff
changeset
|
489 Array<octave_value> W = U.index (static_cast<octave_idx_type> (0)); |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
490 if (W.numel () == 0 || W(0).length () == 0) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
491 Vdebug_on_error = 1; // like "dbstop if error" with no identifier |
21259 | 492 else if (! W(0).is_cell ()) |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
493 fail = true; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
494 else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
495 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
496 Cell V = W(0).cell_value (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
497 for (int i = 0; i < V.numel (); i++) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
498 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
499 errors_that_stop.insert (V(i).string_value ()); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
500 Vdebug_on_error = 1; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
501 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
502 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
503 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
504 if (fail) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
505 error ("dbstop: invalid 'errs' field"); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
506 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
507 // process caught |
21259 | 508 // why so many levels of indirection needed? |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
509 fail = false; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
510 U = mv.contents ("caught"); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
511 if (U.numel () != 1) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
512 fail = (U.numel () > 1); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
513 else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
514 { |
21358
f2ae78f5827f
Resolve compile time issues, when octave_idx_type is long.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
21329
diff
changeset
|
515 Array<octave_value> W = U.index (static_cast<octave_idx_type> (0)); |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
516 if (W.numel () == 0 || W(0).length () == 0) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
517 Vdebug_on_caught = 1; // like "dbstop if caught error" with no ID |
21259 | 518 else if (! W(0).is_cell ()) |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
519 fail = true; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
520 else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
521 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
522 Cell V = W(0).cell_value (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
523 for (int i = 0; i < V.numel (); i++) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
524 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
525 caught_that_stop.insert (V(i).string_value ()); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
526 Vdebug_on_caught = 1; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
527 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
528 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
529 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
530 if (fail) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
531 error ("dbstop: invalid 'caught' field"); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
532 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
533 // process warn |
21259 | 534 // why so many levels of indirection needed? |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
535 fail = false; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
536 U = mv.contents ("warn"); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
537 if (U.numel () != 1) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
538 fail = (U.numel () > 1); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
539 else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
540 { |
21358
f2ae78f5827f
Resolve compile time issues, when octave_idx_type is long.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
21329
diff
changeset
|
541 Array<octave_value> W = U.index (static_cast<octave_idx_type> (0)); |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
542 if (W.numel () == 0 || W(0).length () == 0) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
543 Vdebug_on_warning = 1; // like "dbstop if warning" with no identifier |
21259 | 544 else if (! W(0).is_cell ()) |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
545 fail = true; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
546 else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
547 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
548 Cell V = W(0).cell_value (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
549 for (int i = 0; i < V.numel (); i++) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
550 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
551 warnings_that_stop.insert (V(i).string_value ()); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
552 Vdebug_on_warning = 1; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
553 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
554 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
555 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
556 if (fail) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
557 error ("dbstop: invalid 'warn' field"); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
558 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
559 // process interrupt |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
560 if (mv.isfield ("intr")) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
561 Vdebug_on_interrupt = 1; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
562 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
563 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
564 |
21259 | 565 // Insert a breakpoint in function fcn at line within file fname, |
21562
6c2fd62db1f7
maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents:
21547
diff
changeset
|
566 // to stop only when condition is true. |
21259 | 567 // Record in bp_set that fname contains a breakpoint. |
16596
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16531
diff
changeset
|
568 bool |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16531
diff
changeset
|
569 bp_table::do_add_breakpoint_1 (octave_user_code *fcn, |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16531
diff
changeset
|
570 const std::string& fname, |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16531
diff
changeset
|
571 const bp_table::intmap& line, |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
572 const std::string& condition, |
16596
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16531
diff
changeset
|
573 bp_table::intmap& retval) |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16531
diff
changeset
|
574 { |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16531
diff
changeset
|
575 bool found = false; |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16531
diff
changeset
|
576 |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16531
diff
changeset
|
577 tree_statement_list *cmds = fcn->body (); |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16531
diff
changeset
|
578 |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16531
diff
changeset
|
579 std::string file = fcn->fcn_file_name (); |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16531
diff
changeset
|
580 |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16531
diff
changeset
|
581 if (cmds) |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16531
diff
changeset
|
582 { |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
583 retval = cmds->add_breakpoint (file, line, condition); |
16596
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16531
diff
changeset
|
584 |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16531
diff
changeset
|
585 for (intmap_iterator p = retval.begin (); p != retval.end (); p++) |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16531
diff
changeset
|
586 { |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16531
diff
changeset
|
587 if (p->second != 0) |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16531
diff
changeset
|
588 { |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
589 // normalise to store only the file name. |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
590 // otherwise, there can be an entry for both file>subfunction and |
21259 | 591 // file, which causes a crash on dbclear all |
21258
b248c28d9a7b
Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
592 const char *s = strchr (fname.c_str (), Vfilemarker); |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
593 if (s) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
594 bp_set.insert (fname.substr (0, s - fname.c_str ())); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
595 else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
596 bp_set.insert (fname); |
16596
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16531
diff
changeset
|
597 found = true; |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16531
diff
changeset
|
598 break; |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16531
diff
changeset
|
599 } |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16531
diff
changeset
|
600 } |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16531
diff
changeset
|
601 } |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16531
diff
changeset
|
602 |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16531
diff
changeset
|
603 return found; |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16531
diff
changeset
|
604 } |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16531
diff
changeset
|
605 |
21562
6c2fd62db1f7
maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents:
21547
diff
changeset
|
606 // Cursory check that cond is a valid condition to use for a breakpoint. |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
607 // Currently allows conditions with side-effects, like 'y+=10' and 'y++'; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
608 // it is odd that the former is not flagged by "is_assignment_expression". |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
609 // Throws an exception if not valid. |
21311
718332a58d35
Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21301
diff
changeset
|
610 bool |
718332a58d35
Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21301
diff
changeset
|
611 bp_table::condition_valid (const std::string& cond) |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
612 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
613 if (cond.length () > 0) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
614 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
615 octave_parser parser (cond + " ;"); // ; to reject partial expr like "y==" |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
616 parser.reset (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
617 int parse_status = parser.run (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
618 if (parse_status) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
619 error ("dbstop: Cannot parse condition '%s'", cond.c_str ()); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
620 else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
621 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
622 tree_statement *stmt = 0; |
21259 | 623 if (! parser.stmt_list) |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
624 error ("dbstop: " |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
625 "condition is not empty, but has nothing to evaluate"); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
626 else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
627 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
628 if (parser.stmt_list->length () == 1 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
629 && (stmt = parser.stmt_list->front ()) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
630 && stmt->is_expression ()) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
631 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
632 tree_expression *expr = stmt->expression (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
633 if (expr->is_assignment_expression ()) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
634 error ("dbstop: condition cannot be an assignment. " |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
635 "Did you mean '=='?"); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
636 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
637 else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
638 error ("dbstop: condition must be an expression"); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
639 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
640 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
641 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
642 return true; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
643 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
644 |
21562
6c2fd62db1f7
maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents:
21547
diff
changeset
|
645 // Given file name fname, find the subfunction at line and create |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
646 // a breakpoint there. Put the system into debug_mode. |
21562
6c2fd62db1f7
maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents:
21547
diff
changeset
|
647 // (FIXME: If line is multiple lines, what happens if they are in different |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
648 // functions?) |
7083 | 649 bp_table::intmap |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
650 bp_table::do_add_breakpoint (const std::string& fname, |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
651 const bp_table::intmap& line, |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
652 const std::string& condition) |
7082 | 653 { |
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
|
654 octave_user_code *dbg_fcn = get_user_code (fname); |
7082 | 655 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
656 if (! dbg_fcn) |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
657 error ("add_breakpoint: unable to find function '%s'\n", fname.c_str ()); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
658 |
21311
718332a58d35
Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21301
diff
changeset
|
659 condition_valid (condition); // Throw error if condition not valid. |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
660 |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
661 intmap retval; |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
662 |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
663 if (! do_add_breakpoint_1 (dbg_fcn, fname, line, condition, retval)) |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
664 { |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
665 // Search subfunctions in the order they appear in the file. |
7083 | 666 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
667 const std::list<std::string> subfcn_names |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
668 = dbg_fcn->subfunction_names (); |
16531
f3a63fdbd725
finish botched changeset 7ca7e7d5eb91
John W. Eaton <jwe@octave.org>
parents:
16530
diff
changeset
|
669 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
670 std::map<std::string, octave_value> subfcns |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
671 = dbg_fcn->subfunctions (); |
16596
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16531
diff
changeset
|
672 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
673 for (std::list<std::string>::const_iterator p = subfcn_names.begin (); |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
674 p != subfcn_names.end (); p++) |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
675 { |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
676 std::map<std::string, octave_value>::const_iterator |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
677 q = subfcns.find (*p); |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
678 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
679 if (q != subfcns.end ()) |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
680 { |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
681 octave_user_code *dbg_subfcn = q->second.user_code_value (); |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
682 |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
683 if (do_add_breakpoint_1 (dbg_subfcn, fname, line, condition, |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
684 retval)) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
685 break; |
16531
f3a63fdbd725
finish botched changeset 7ca7e7d5eb91
John W. Eaton <jwe@octave.org>
parents:
16530
diff
changeset
|
686 } |
f3a63fdbd725
finish botched changeset 7ca7e7d5eb91
John W. Eaton <jwe@octave.org>
parents:
16530
diff
changeset
|
687 } |
7082 | 688 } |
689 | |
10194 | 690 tree_evaluator::debug_mode = bp_table::have_breakpoints () || Vdebugging; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
691 |
7082 | 692 return retval; |
693 } | |
694 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
695 int |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
696 bp_table::do_remove_breakpoint_1 (octave_user_code *fcn, |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
697 const std::string& fname, |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
698 const bp_table::intmap& line) |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
699 { |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
700 int retval = 0; |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
701 |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
702 std::string file = fcn->fcn_file_name (); |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
703 |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
704 tree_statement_list *cmds = fcn->body (); |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
705 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17753
diff
changeset
|
706 // FIXME: move the operation on cmds to the tree_statement_list class? |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
707 |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
708 if (cmds) |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
709 { |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
710 octave_value_list results = cmds->list_breakpoints (); |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
711 |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
712 if (results.length () > 0) |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
713 { |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
714 octave_idx_type len = line.size (); |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
715 |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
716 for (int i = 0; i < len; i++) |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
717 { |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
718 const_intmap_iterator p = line.find (i); |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
719 |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
720 if (p != line.end ()) |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
721 { |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
722 int lineno = p->second; |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
723 |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
724 cmds->delete_breakpoint (lineno); |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
725 |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
726 if (! file.empty ()) |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
727 octave_link::update_breakpoint (false, file, lineno); |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
728 } |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
729 } |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
730 |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
731 results = cmds->list_breakpoints (); |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
732 |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
733 bp_set_iterator it = bp_set.find (fname); |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
734 if (results.length () == 0 && it != bp_set.end ()) |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
735 bp_set.erase (it); |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
736 } |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
737 |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
738 retval = results.length (); |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
739 } |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
740 |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
741 return retval; |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
742 } |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
743 |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
744 int |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
745 bp_table::do_remove_breakpoint (const std::string& fname, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
746 const bp_table::intmap& line) |
7082 | 747 { |
7083 | 748 int retval = 0; |
7082 | 749 |
750 octave_idx_type len = line.size (); | |
751 | |
752 if (len == 0) | |
753 { | |
754 intmap results = remove_all_breakpoints_in_file (fname); | |
755 retval = results.size (); | |
756 } | |
757 else | |
758 { | |
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
|
759 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
|
760 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
761 if (! dbg_fcn) |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
762 error ("remove_breakpoint: unable to find function %s\n", |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
763 fname.c_str ()); |
16386
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
764 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
765 retval = do_remove_breakpoint_1 (dbg_fcn, fname, line); |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
766 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
767 // Search subfunctions in the order they appear in the file. |
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
|
768 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
769 const std::list<std::string> subfcn_names |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
770 = dbg_fcn->subfunction_names (); |
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
|
771 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
772 std::map<std::string, octave_value> subfcns |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
773 = dbg_fcn->subfunctions (); |
16386
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
774 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
775 for (std::list<std::string>::const_iterator p = subfcn_names.begin (); |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
776 p != subfcn_names.end (); p++) |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
777 { |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
778 std::map<std::string, octave_value>::const_iterator |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
779 q = subfcns.find (*p); |
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 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
781 if (q != subfcns.end ()) |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
782 { |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
783 octave_user_code *dbg_subfcn = q->second.user_code_value (); |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
784 |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
785 retval += do_remove_breakpoint_1 (dbg_subfcn, fname, line); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
786 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
787 } |
7082 | 788 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
789 |
10194 | 790 tree_evaluator::debug_mode = bp_table::have_breakpoints () || Vdebugging; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
791 |
7082 | 792 return retval; |
793 } | |
794 | |
20674
78b3e9868b67
Fix segfault with 'dbclear all' (bug #41843).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20172
diff
changeset
|
795 // Remove all breakpoints from a file, including those in subfunctions |
7083 | 796 bp_table::intmap |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
797 bp_table::do_remove_all_breakpoints_in_file (const std::string& fname, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
798 bool silent) |
7082 | 799 { |
7083 | 800 intmap retval; |
7082 | 801 |
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
|
802 octave_user_code *dbg_fcn = get_user_code (fname); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
803 |
7082 | 804 if (dbg_fcn) |
805 { | |
20674
78b3e9868b67
Fix segfault with 'dbclear all' (bug #41843).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20172
diff
changeset
|
806 std::string file = dbg_fcn->fcn_file_name (); |
16386
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
807 |
20674
78b3e9868b67
Fix segfault with 'dbclear all' (bug #41843).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20172
diff
changeset
|
808 tree_statement_list *cmds = dbg_fcn->body (); |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
809 |
20674
78b3e9868b67
Fix segfault with 'dbclear all' (bug #41843).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20172
diff
changeset
|
810 if (cmds) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
811 { |
20674
78b3e9868b67
Fix segfault with 'dbclear all' (bug #41843).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20172
diff
changeset
|
812 retval = cmds->remove_all_breakpoints (file); |
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
|
813 |
20674
78b3e9868b67
Fix segfault with 'dbclear all' (bug #41843).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20172
diff
changeset
|
814 bp_set_iterator it = bp_set.find (fname); |
78b3e9868b67
Fix segfault with 'dbclear all' (bug #41843).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20172
diff
changeset
|
815 if (it != bp_set.end ()) |
78b3e9868b67
Fix segfault with 'dbclear all' (bug #41843).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20172
diff
changeset
|
816 bp_set.erase (it); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
817 } |
7082 | 818 } |
8123
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
8114
diff
changeset
|
819 else if (! silent) |
7082 | 820 error ("remove_all_breakpoint_in_file: " |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
821 "unable to find function %s\n", fname.c_str ()); |
7082 | 822 |
10194 | 823 tree_evaluator::debug_mode = bp_table::have_breakpoints () || Vdebugging; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
824 |
7082 | 825 return retval; |
826 } | |
827 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
828 void |
7083 | 829 bp_table::do_remove_all_breakpoints (void) |
7082 | 830 { |
18379
80d39575fd44
Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents:
18377
diff
changeset
|
831 // Odd loop structure required because delete will invalidate bp_set iterators |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19855
diff
changeset
|
832 for (const_bp_set_iterator it=bp_set.begin (), it_next=it; |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19855
diff
changeset
|
833 it != bp_set.end (); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19855
diff
changeset
|
834 it=it_next) |
18379
80d39575fd44
Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents:
18377
diff
changeset
|
835 { |
80d39575fd44
Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents:
18377
diff
changeset
|
836 ++it_next; |
80d39575fd44
Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents:
18377
diff
changeset
|
837 remove_all_breakpoints_in_file (*it); |
80d39575fd44
Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents:
18377
diff
changeset
|
838 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
839 |
10194 | 840 tree_evaluator::debug_mode = bp_table::have_breakpoints () || Vdebugging; |
7082 | 841 } |
842 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
843 std::string |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
844 do_find_bkpt_list (octave_value_list slist, std::string match) |
7082 | 845 { |
846 std::string retval; | |
7083 | 847 |
7082 | 848 for (int i = 0; i < slist.length (); i++) |
849 { | |
18379
80d39575fd44
Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents:
18377
diff
changeset
|
850 if (slist(i).string_value () == match) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
851 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
852 retval = slist(i).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
853 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
854 } |
7082 | 855 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
856 |
7082 | 857 return retval; |
858 } | |
859 | |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
860 bp_table::fname_bp_map |
7083 | 861 bp_table::do_get_breakpoint_list (const octave_value_list& fname_list) |
7082 | 862 { |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
863 fname_bp_map retval; |
7082 | 864 |
21094
622e34f6ede3
Fix segfault with dbstatus (bug #44195)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21077
diff
changeset
|
865 // make copy since changes may invalidate iters of bp_set. |
622e34f6ede3
Fix segfault with dbstatus (bug #44195)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21077
diff
changeset
|
866 std::set<std::string> tmp_bp_set = bp_set; |
622e34f6ede3
Fix segfault with dbstatus (bug #44195)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21077
diff
changeset
|
867 |
622e34f6ede3
Fix segfault with dbstatus (bug #44195)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21077
diff
changeset
|
868 for (bp_set_iterator it = tmp_bp_set.begin (); it != tmp_bp_set.end (); it++) |
7082 | 869 { |
7083 | 870 if (fname_list.length () == 0 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
871 || do_find_bkpt_list (fname_list, *it) != "") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
872 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
873 octave_user_code *f = get_user_code (*it); |
7083 | 874 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
875 if (f) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
876 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
877 tree_statement_list *cmds = f->body (); |
7083 | 878 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17753
diff
changeset
|
879 // FIXME: move the operation on cmds to the |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17753
diff
changeset
|
880 // tree_statement_list class? |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
881 if (cmds) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
882 { |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
883 std::list<bp_type> bkpts = cmds->breakpoints_and_conds (); |
7083 | 884 |
21259 | 885 if (! bkpts.empty ()) |
21258
b248c28d9a7b
Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
886 retval[*it] = bkpts; |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
887 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
888 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
889 // look for breakpoints in subfunctions |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
890 const std::list<std::string> subf_nm = f->subfunction_names (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
891 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
892 std::map<std::string, octave_value> subf = f->subfunctions (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
893 |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
894 for (std::list<std::string>::const_iterator p = subf_nm.begin (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
895 p != subf_nm.end (); p++) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
896 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
897 std::map<std::string, octave_value>::const_iterator |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
898 q = subf.find (*p); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
899 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
900 if (q != subf.end ()) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
901 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
902 octave_user_code *ff = q->second.user_code_value (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
903 |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
904 cmds = ff->body (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
905 if (cmds) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
906 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
907 std::list<bp_type> bkpts |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
908 = cmds->breakpoints_and_conds (); |
7083 | 909 |
21259 | 910 if (! bkpts.empty ()) |
21258
b248c28d9a7b
Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
911 retval[*it + Vfilemarker + ff->name ()] = bkpts; |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
912 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
913 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
914 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
915 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
916 } |
7082 | 917 } |
7083 | 918 |
7082 | 919 return retval; |
920 } | |
921 | |
922 static octave_value | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
923 intmap_to_ov (const bp_table::intmap& line) |
7082 | 924 { |
925 int idx = 0; | |
7083 | 926 |
927 NDArray retval (dim_vector (1, line.size ())); | |
928 | |
929 for (size_t i = 0; i < line.size (); i++) | |
7082 | 930 { |
7083 | 931 bp_table::const_intmap_iterator p = line.find (i); |
932 | |
7082 | 933 if (p != line.end ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
934 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
935 int lineno = p->second; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
936 retval(idx++) = lineno; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
937 } |
7082 | 938 } |
7083 | 939 |
7082 | 940 retval.resize (dim_vector (1, idx)); |
7083 | 941 |
7082 | 942 return retval; |
943 } | |
3895 | 944 |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
945 DEFUN (dbstop, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17753
diff
changeset
|
946 "-*- texinfo -*-\n\ |
21259 | 947 @deftypefn {} {} dbstop @var{func}\n\ |
948 @deftypefnx {} {} dbstop @var{func} @var{line}\n\ | |
949 @deftypefnx {} {} dbstop @var{func} @var{line1} @var{line2} @dots{}\n\ | |
950 @deftypefnx {} {} dbstop @var{line1} @dots{}\n\ | |
951 @deftypefnx {} {} dbstop in @var{func}\n\ | |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
952 @deftypefnx {} {} dbstop in @var{func} at @var{line}\n\ |
21259 | 953 @deftypefnx {} {} dbstop in @var{func} at @var{line} if \"@var{condition}\"\n\ |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
954 @deftypefnx {} {} dbstop if @var{event}\n\ |
21259 | 955 @deftypefnx {} {} dbstop if @var{event} @var{ID}\n\ |
956 @deftypefnx {} {} dbstop (@var{bp_struct})\n\ | |
957 @deftypefnx {} {@var{rline} =} dbstop @dots{}\n\ | |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
958 \n\ |
21259 | 959 Set breakpoints for the built-in debugger.\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
960 \n\ |
21259 | 961 @var{func} is the name of a function on the current @code{path}. When\n\ |
962 already in debug mode the @var{func} argument can be omitted and the current\n\ | |
963 function will be used. Breakpoints at subfunctions are set with the scope\n\ | |
964 operator @samp{>}. For example, If @file{file.m} has a subfunction\n\ | |
965 @code{func2}, then a breakpoint in @code{func2} can be specified by\n\ | |
966 @code{file>func2}.\n\ | |
967 \n\ | |
968 @var{line} is the line number at which to break. If @var{line} is not\n\ | |
969 specified, it defaults to the first executable line in the file\n\ | |
970 @file{func.m}. Multiple lines can be specified in a single command; when\n\ | |
971 function syntax is used, the lines may also be passed as a single vector\n\ | |
21318
280ea93d48dd
* debug.cc (Fdbstop): Fix error in docstring from cset 4ee768b71a0e (bug #47213)
Mike Miller <mtmiller@octave.org>
parents:
21311
diff
changeset
|
972 argument (@code{[@var{line1}, @var{line2}, @dots{}]}).\n\ |
10840 | 973 \n\ |
21259 | 974 @var{condition} is any Octave expression that can be evaluated in the code\n\ |
975 context that exists at the breakpoint. When the breakpoint is encountered,\n\ | |
976 @var{condition} will be evaluated, and execution will stop if\n\ | |
977 @var{condition} is true. If @var{condition} cannot be evaluated, for\n\ | |
978 example because it refers to an undefined variable, an error will be thrown.\n\ | |
979 Expressions with side effects (such as @code{y++ > 1}) will alter\n\ | |
980 variables, and should generally be avoided. Conditions containing quotes\n\ | |
981 (@samp{\"}, @samp{'}) or comment characters (@samp{#}, @samp{%}) must be\n\ | |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
982 enclosed in quotes. (This does not apply to conditions entered from the\n\ |
21547
ad0599a0acc6
doc: Wrap C++ docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents:
21358
diff
changeset
|
983 editor's context menu.) For example:\n\ |
21259 | 984 \n\ |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
985 @example\n\ |
21259 | 986 dbstop in strread at 209 if 'any (format == \"%f\")'\n\ |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
987 @end example\n\ |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
988 \n\ |
21259 | 989 The form specifying @var{event} does not cause a specific breakpoint at a\n\ |
990 given function and line number. Instead it causes debug mode to be entered\n\ | |
991 when certain unexpected events are encountered. Possible values are\n\ | |
992 \n\ | |
993 @table @code\n\ | |
994 @item error\n\ | |
995 Stop when an error is reported. This is equivalent to specifying\n\ | |
996 both @code{debug_on_error (true)} and @code{debug_on_interrupt (true)}.\n\ | |
997 \n\ | |
998 @item caught error\n\ | |
999 Stop when an error is caught by a try-catch block (not yet implemented).\n\ | |
1000 \n\ | |
1001 @item interrupt\n\ | |
1002 Stop when an interrupt (@kbd{Ctrl-C}) occurs.\n\ | |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1003 \n\ |
21259 | 1004 @item naninf\n\ |
1005 Stop when code returns a non-finite value (not yet implemented).\n\ | |
1006 \n\ | |
1007 @item warning\n\ | |
1008 Stop when a warning is reported. This is equivalent to specifying\n\ | |
1009 @code{debug_on_warning (true)}.\n\ | |
3805 | 1010 @end table\n\ |
1011 \n\ | |
21259 | 1012 The events @code{error}, @code{caught error}, and @code{warning} can all be\n\ |
1013 followed by a string specifying an error ID or warning ID@. If that is\n\ | |
1014 done, only errors with the specified ID will cause execution to stop. To\n\ | |
1015 stop on one of a set of IDs, multiple @code{dbstop} commands must be\n\ | |
1016 issued.\n\ | |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1017 \n\ |
21259 | 1018 Breakpoints and events can be removed using the @code{dbclear} command with\n\ |
1019 the same syntax.\n\ | |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1020 \n\ |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1021 It is possible to save all breakpoints and restore them at once by issuing\n\ |
21259 | 1022 the commands @code{bp_state = dbstatus; @dots{}; dbstop (bp_state)}.\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1023 \n\ |
18380
b48391da83fc
doc: Improve docstrings for dbstop, dbup, dbdown.
Rik <rik@octave.org>
parents:
18379
diff
changeset
|
1024 The optional output @var{rline} is the real line number where the breakpoint\n\ |
b48391da83fc
doc: Improve docstrings for dbstop, dbup, dbdown.
Rik <rik@octave.org>
parents:
18379
diff
changeset
|
1025 was set. This can differ from the specified line if the line is not\n\ |
b48391da83fc
doc: Improve docstrings for dbstop, dbup, dbdown.
Rik <rik@octave.org>
parents:
18379
diff
changeset
|
1026 executable. For example, if a breakpoint attempted on a blank line then\n\ |
b48391da83fc
doc: Improve docstrings for dbstop, dbup, dbdown.
Rik <rik@octave.org>
parents:
18379
diff
changeset
|
1027 Octave will set the real breakpoint at the next executable line.\n\ |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1028 \n\ |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1029 When a file is re-parsed, such as when it is modified outside the GUI,\n\ |
21259 | 1030 all breakpoints within the file are cleared.\n\ |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1031 \n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1032 @seealso{dbclear, dbstatus, dbstep, debug_on_error, debug_on_warning, debug_on_interrupt}\n\ |
5642 | 1033 @end deftypefn") |
3805 | 1034 { |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1035 bp_table::intmap retmap; |
21259 | 1036 std::string symbol_name = ""; // stays empty for "dbstop if error" etc |
7083 | 1037 bp_table::intmap lines; |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1038 std::string condition = ""; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1039 octave_value retval; |
7083 | 1040 |
21259 | 1041 if (args.length() >= 1 && ! args(0).is_map ()) |
1042 { | |
1043 // explicit function / line / condition | |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1044 parse_dbfunction_params ("dbstop", args, symbol_name, lines, condition); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1045 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1046 if (lines.size () == 0) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1047 lines[0] = 1; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1048 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1049 if (symbol_name != "") |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1050 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1051 retmap = bp_table::add_breakpoint (symbol_name, lines, condition); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1052 retval = intmap_to_ov (retmap); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1053 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1054 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1055 else if (args.length () != 1) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1056 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1057 print_usage (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1058 } |
21259 | 1059 else // structure of the form output by dbstatus |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1060 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1061 octave_map mv = args(0).map_value (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1062 if (mv.isfield ("bkpt") || mv.isfield ("errs") || mv.isfield ("warn") |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1063 || mv.isfield ("intr")) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1064 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1065 bp_table::dbstop_process_map_args (mv); |
6646 | 1066 |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1067 // Replace mv by "bkpt", to use the processing below. |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1068 octave_value bkpt = mv.getfield ("bkpt"); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1069 if (bkpt.is_empty ()) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1070 mv = octave_map (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1071 else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1072 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1073 if (bkpt.is_cell () && bkpt.cell_value ().numel () > 0 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1074 && bkpt.cell_value () (0).is_map ()) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1075 mv = bkpt.cell_value () (0).map_value (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1076 else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1077 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1078 error ("dbstop: invalid 'bkpt' field"); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1079 mv = octave_map (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1080 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1081 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1082 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1083 if (mv.numel () == 0) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1084 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1085 // no changes requested. Occurs if "errs" non-empty but "bkpt" empty |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1086 } |
21259 | 1087 else if (! mv.isfield ("name") || ! mv.isfield ("line")) |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1088 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1089 error ("dbstop: Cell array must contain fields 'name' and 'line'"); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1090 retval = octave_value (0); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1091 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1092 else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1093 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1094 bool use_cond = mv.isfield ("cond"); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1095 Cell name = mv.getfield ("name"); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1096 Cell line = mv.getfield ("line"); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1097 Cell cond = (use_cond ? mv.getfield ("cond") : Cell ()); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1098 std::string unconditional = ""; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1099 for (octave_idx_type i = 0; i < line.numel (); i++) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1100 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1101 lines [0] = line(i).double_value (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1102 bp_table::add_breakpoint (name(i).string_value (), lines, |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1103 use_cond ? cond(i).string_value () |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1104 : unconditional ); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1105 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1106 retval = octave_value (line.numel ()); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1107 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1108 } |
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
|
1109 |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1110 return retval; |
3805 | 1111 } |
1112 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
1113 DEFUN (dbclear, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17753
diff
changeset
|
1114 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
1115 @deftypefn {} {} dbclear @var{func}\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
1116 @deftypefnx {} {} dbclear @var{func} @var{line}\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
1117 @deftypefnx {} {} dbclear @var{func} @var{line1} @var{line2} @dots{}\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
1118 @deftypefnx {} {} dbclear @var{line} @dots{}\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
1119 @deftypefnx {} {} dbclear all\n\ |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1120 @deftypefnx {} {} dbclear in @var{func}\n\ |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1121 @deftypefnx {} {} dbclear in @var{func} at @var{line}\n\ |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1122 @deftypefnx {} {} dbclear if @var{event}\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
1123 @deftypefnx {} {} dbclear (\"@var{func}\")\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
1124 @deftypefnx {} {} dbclear (\"@var{func}\", @var{line})\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
1125 @deftypefnx {} {} dbclear (\"@var{func}\", @var{line1}, @var{line2}, @dots{})\n\ |
21259 | 1126 @deftypefnx {} {} dbclear (\"@var{func}\", @var{line1}, @dots{})\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
1127 @deftypefnx {} {} dbclear (@var{line}, @dots{})\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
1128 @deftypefnx {} {} dbclear (\"all\")\n\ |
18379
80d39575fd44
Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents:
18377
diff
changeset
|
1129 Delete a breakpoint at line number @var{line} in the function @var{func}.\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1130 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1131 Arguments are\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1132 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1133 @table @var\n\ |
3805 | 1134 @item func\n\ |
21547
ad0599a0acc6
doc: Wrap C++ docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents:
21358
diff
changeset
|
1135 Function name as a string variable. When already in debug mode this\n\ |
ad0599a0acc6
doc: Wrap C++ docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents:
21358
diff
changeset
|
1136 argument can be omitted and the current function will be used.\n\ |
10840 | 1137 \n\ |
3805 | 1138 @item line\n\ |
18379
80d39575fd44
Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents:
18377
diff
changeset
|
1139 Line number from which to remove a breakpoint. Multiple lines may be given\n\ |
80d39575fd44
Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents:
18377
diff
changeset
|
1140 as separate arguments or as a vector.\n\ |
21259 | 1141 \n\ |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1142 @item event\n\ |
21259 | 1143 An event such as @code{error}, @code{interrupt}, or @code{warning}\n\ |
1144 (@pxref{XREFdbstop,,dbstop} for details).\n\ | |
3805 | 1145 @end table\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1146 \n\ |
18379
80d39575fd44
Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents:
18377
diff
changeset
|
1147 When called without a line number specification all breakpoints in the named\n\ |
80d39575fd44
Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents:
18377
diff
changeset
|
1148 function are cleared.\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1149 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1150 If the requested line is not a breakpoint no action is performed.\n\ |
18379
80d39575fd44
Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents:
18377
diff
changeset
|
1151 \n\ |
80d39575fd44
Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents:
18377
diff
changeset
|
1152 The special keyword @qcode{\"all\"} will clear all breakpoints from all\n\ |
80d39575fd44
Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents:
18377
diff
changeset
|
1153 files.\n\ |
5642 | 1154 @seealso{dbstop, dbstatus, dbwhere}\n\ |
1155 @end deftypefn") | |
3805 | 1156 { |
21259 | 1157 std::string symbol_name = ""; // stays empty for "dbclear if error" etc |
7083 | 1158 bp_table::intmap lines; |
21259 | 1159 std::string dummy; // "if" condition -- only used for dbstop |
7083 | 1160 |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1161 int nargin = args.length (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1162 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1163 parse_dbfunction_params ("dbclear", args, symbol_name, lines, dummy); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1164 |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1165 if (nargin == 1 && symbol_name == "all") |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1166 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1167 bp_table::remove_all_breakpoints (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1168 bp_table::dbclear_all_signals (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1169 } |
18379
80d39575fd44
Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents:
18377
diff
changeset
|
1170 else |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1171 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1172 if (symbol_name != "") |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1173 bp_table::remove_breakpoint (symbol_name, lines); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1174 } |
3805 | 1175 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1176 return ovl (); |
3805 | 1177 } |
1178 | |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1179 // Report the status of "dbstop if error ..." and "dbstop if warning ..." |
21562
6c2fd62db1f7
maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents:
21547
diff
changeset
|
1180 // If to_screen is true, the output goes to octave_stdout; otherwise it is |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1181 // returned. |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1182 // If dbstop if error is true but no explicit IDs are specified, the return |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1183 // value will have an empty field called "errs". If IDs are specified, the |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1184 // "errs" field will have a row per ID. If dbstop if error is false, there |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1185 // is no "errs" field. The "warn" field is set similarly by dbstop if warning |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1186 octave_map |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1187 bp_table::stop_on_err_warn_status (bool to_screen) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1188 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1189 octave_map retval; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1190 |
21259 | 1191 // print dbstop if error information |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1192 if (Vdebug_on_error) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1193 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1194 if (errors_that_stop.empty ()) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1195 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1196 if (to_screen) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1197 octave_stdout << "stop if error\n"; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1198 else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1199 retval.assign ("errs", octave_value("")); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1200 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1201 else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1202 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1203 Cell errs (dim_vector (bp_table::errors_that_stop.size (), 1)); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1204 int i = 0; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1205 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1206 for (std::set<std::string>::const_iterator e |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1207 = errors_that_stop.begin (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1208 e != errors_that_stop.end (); e++) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1209 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1210 if (to_screen) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1211 octave_stdout << "stop if error " << *e << "\n"; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1212 else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1213 errs (i++) = *e; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1214 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1215 if (!to_screen) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1216 retval.assign ("errs", octave_value (errs)); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1217 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1218 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1219 |
21259 | 1220 // print dbstop if caught error information |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1221 if (Vdebug_on_caught) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1222 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1223 if (caught_that_stop.empty ()) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1224 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1225 if (to_screen) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1226 octave_stdout << "stop if caught error\n"; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1227 else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1228 retval.assign ("caught", octave_value("")); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1229 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1230 else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1231 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1232 Cell errs (dim_vector (caught_that_stop.size (), 1)); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1233 int i = 0; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1234 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1235 for (std::set<std::string>::const_iterator e |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1236 = caught_that_stop.begin (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1237 e != caught_that_stop.end (); e++) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1238 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1239 if (to_screen) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1240 octave_stdout << "stop if caught error " << *e << "\n"; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1241 else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1242 errs (i++) = *e; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1243 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1244 if (!to_screen) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1245 retval.assign ("caught", octave_value (errs)); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1246 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1247 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1248 |
21259 | 1249 // print dbstop if warning information |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1250 if (Vdebug_on_warning) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1251 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1252 if (warnings_that_stop.empty ()) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1253 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1254 if (to_screen) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1255 octave_stdout << "stop if warning\n"; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1256 else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1257 retval.assign ("warn", octave_value("")); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1258 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1259 else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1260 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1261 Cell warn (dim_vector (warnings_that_stop.size (), 1)); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1262 int i = 0; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1263 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1264 for (std::set<std::string>::const_iterator w |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1265 = warnings_that_stop.begin (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1266 w != warnings_that_stop.end (); w++) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1267 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1268 if (to_screen) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1269 octave_stdout << "stop if warning " << *w << "\n"; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1270 else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1271 warn (i++) = *w; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1272 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1273 if (!to_screen) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1274 retval.assign ("warn", octave_value (warn)); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1275 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1276 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1277 |
21259 | 1278 // print dbstop if interrupt information |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1279 if (Vdebug_on_interrupt) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1280 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1281 if (to_screen) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1282 octave_stdout << "stop if interrupt\n"; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1283 else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1284 retval.assign ("intr", octave_value ()); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1285 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1286 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1287 return retval; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1288 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1289 |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
1290 DEFUN (dbstatus, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17753
diff
changeset
|
1291 "-*- texinfo -*-\n\ |
21259 | 1292 @deftypefn {} {} dbstatus\n\ |
1293 @deftypefnx {} {} dbstatus @var{func}\n\ | |
1294 @deftypefnx {} {@var{bp_list} =} dbstatus @dots{}\n\ | |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1295 Report the location of active breakpoints.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1296 \n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
1297 When called with no input or output arguments, print the list of all\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
1298 functions with breakpoints and the line numbers where those breakpoints are\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
1299 set.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
1300 \n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1301 If a function name @var{func} is specified then only report breakpoints\n\ |
21259 | 1302 for the named function and its subfunctions.\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1303 \n\ |
21259 | 1304 The optional return argument @var{bp_list} is a struct array with the\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1305 following fields.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1306 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1307 @table @asis\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1308 @item name\n\ |
21259 | 1309 The name of the function with a breakpoint. A subfunction, say @code{func2}\n\ |
1310 within an m-file, say @file{file.m}, is specified as @code{file>func2}.\n\ | |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1311 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1312 @item file\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1313 The name of the m-file where the function code is located.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1314 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1315 @item line\n\ |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1316 The line number with the breakpoint.\n\ |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1317 \n\ |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1318 @item cond\n\ |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1319 The condition that must be satisfied for the breakpoint to be active, or\n\ |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1320 the empty string for unconditional breakpoints.\n\ |
3805 | 1321 @end table\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1322 \n\ |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1323 @c Note: When @code{dbstatus} is called from the debug prompt within a function,\n\ |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1324 @c the list of breakpoints is automatically trimmed to the breakpoints in the\n\ |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1325 @c current function.\n\ |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1326 If @code{dbstop if error} is true but no explicit IDs are specified, the\n\ |
21259 | 1327 return value will have an empty field called @qcode{\"errs\"}. If IDs are\n\ |
1328 specified, the @code{errs} field will have one row per ID@. If\n\ | |
1329 @code{dbstop if error} is false, there is no @qcode{\"errs\"} field.\n\ | |
1330 The @qcode{\"warn\"} field is set similarly by @code{dbstop if warning}.\n\ | |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1331 \n\ |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1332 @seealso{dbstop, dbclear, dbwhere, dblist, dbstack}\n\ |
5642 | 1333 @end deftypefn") |
3805 | 1334 { |
1335 int nargin = args.length (); | |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1336 |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1337 if (nargin != 0 && nargin != 1) |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1338 error ("dbstatus: only zero or one arguments accepted\n"); |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1339 |
7082 | 1340 octave_value_list fcn_list; |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1341 bp_table::fname_bp_map bp_list; |
7083 | 1342 std::string symbol_name; |
3805 | 1343 |
1344 if (nargin == 1) | |
1345 { | |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
1346 if (! args(0).is_string ()) |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21094
diff
changeset
|
1347 err_wrong_type_arg ("dbstatus", args(0)); |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
1348 |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
1349 symbol_name = args(0).string_value (); |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
1350 fcn_list(0) = symbol_name; |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
1351 bp_list = bp_table::get_breakpoint_list (fcn_list); |
7082 | 1352 } |
1353 else | |
1354 { | |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1355 /* |
18376
bb162f81881d
Correctly return all breakpoints when called with no arguments (bug #41338).
Rik <rik@octave.org>
parents:
18375
diff
changeset
|
1356 if (Vdebugging) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17753
diff
changeset
|
1357 { |
18376
bb162f81881d
Correctly return all breakpoints when called with no arguments (bug #41338).
Rik <rik@octave.org>
parents:
18375
diff
changeset
|
1358 octave_user_code *dbg_fcn = get_user_code (); |
bb162f81881d
Correctly return all breakpoints when called with no arguments (bug #41338).
Rik <rik@octave.org>
parents:
18375
diff
changeset
|
1359 if (dbg_fcn) |
bb162f81881d
Correctly return all breakpoints when called with no arguments (bug #41338).
Rik <rik@octave.org>
parents:
18375
diff
changeset
|
1360 { |
bb162f81881d
Correctly return all breakpoints when called with no arguments (bug #41338).
Rik <rik@octave.org>
parents:
18375
diff
changeset
|
1361 symbol_name = dbg_fcn->name (); |
bb162f81881d
Correctly return all breakpoints when called with no arguments (bug #41338).
Rik <rik@octave.org>
parents:
18375
diff
changeset
|
1362 fcn_list(0) = symbol_name; |
bb162f81881d
Correctly return all breakpoints when called with no arguments (bug #41338).
Rik <rik@octave.org>
parents:
18375
diff
changeset
|
1363 } |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17753
diff
changeset
|
1364 } |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1365 */ |
7083 | 1366 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17753
diff
changeset
|
1367 bp_list = bp_table::get_breakpoint_list (fcn_list); |
3805 | 1368 } |
1369 | |
7083 | 1370 if (nargout == 0) |
3805 | 1371 { |
7083 | 1372 // Print out the breakpoint information. |
1373 | |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1374 for (bp_table::fname_bp_map_iterator it = bp_list.begin (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1375 it != bp_list.end (); it++) |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1376 { |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1377 std::list<bp_type> m = it->second; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1378 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1379 // print unconditional breakpoints, if any, on a single line |
7083 | 1380 |
21259 | 1381 // first, check to see if there are any |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1382 int have_unconditional = 0; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1383 for (std::list<bp_type>::const_iterator j = m.begin (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1384 j != m.end (); j++) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1385 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1386 if (j->cond == "") |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1387 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1388 if (have_unconditional++) |
21259 | 1389 break; // stop once we know its plural |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1390 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1391 } |
21259 | 1392 // If we actually have some, print line numbers only |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1393 if (have_unconditional) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1394 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1395 const char *_s_ = (have_unconditional > 1) ? "s" : ""; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1396 octave_stdout << "breakpoint" << _s_ <<" in " << it->first |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1397 << " at line" << _s_ << " "; |
7083 | 1398 |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1399 for (std::list<bp_type>::const_iterator j = m.begin (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1400 j != m.end (); j++) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1401 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1402 if (j->cond == "") |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1403 octave_stdout << j->line << " "; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1404 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1405 octave_stdout << std::endl; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1406 } |
14228
0beb62668d69
Use correct plural for dbstatus if there is more than 1 breakpoint set in file.
Rik <octave@nomad.inbox5.com>
parents:
14227
diff
changeset
|
1407 |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1408 // print conditional breakpoints, one per line, with conditions |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1409 for (std::list<bp_type>::const_iterator j = m.begin (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1410 j != m.end (); j++) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1411 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1412 if (j->cond != "") |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1413 octave_stdout << "breakpoint in " << it->first |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1414 << " at line " << j->line |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1415 << " if " << j->cond << "\n"; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1416 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1417 } |
7083 | 1418 |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1419 bp_table::stop_on_err_warn_status (true); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1420 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1421 return ovl (); |
7083 | 1422 } |
1423 else | |
1424 { | |
1425 // Fill in an array for return. | |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1426 int i = 0; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1427 octave_map retmap; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1428 octave_value retval; |
7083 | 1429 |
21259 | 1430 // count how many breakpoints there are |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1431 int count = 0; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1432 for (bp_table::const_fname_bp_map_iterator it = bp_list.begin (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1433 it != bp_list.end (); it++) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1434 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1435 for (std::list<bp_type>::const_iterator j = it->second.begin (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1436 j != it->second.end (); j++) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1437 count++; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1438 } |
7083 | 1439 |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1440 Cell names (dim_vector (count, 1)); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1441 Cell file (dim_vector (count, 1)); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1442 Cell line (dim_vector (count, 1)); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1443 Cell cond (dim_vector (count, 1)); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1444 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1445 for (bp_table::const_fname_bp_map_iterator it = bp_list.begin (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1446 it != bp_list.end (); it++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1447 { |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1448 std::string filename = it->first; |
21258
b248c28d9a7b
Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1449 const char *sub_fun = strchr (filename.c_str (), Vfilemarker); |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1450 if (sub_fun) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1451 filename = filename.substr(0, sub_fun - filename.c_str ()); |
21259 | 1452 octave_value path_name; |
1453 path_name = octave_canonicalize_file_name (do_which (filename)); | |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1454 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1455 for (std::list<bp_type>::const_iterator j = it->second.begin (); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1456 j != it->second.end (); j++) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1457 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1458 names(i) = it->first; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1459 file(i) = path_name; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1460 line(i) = octave_value (j->line); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1461 cond(i) = octave_value (j->cond); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1462 i++; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1463 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1464 } |
7083 | 1465 |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1466 retmap.assign ("name", names); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1467 retmap.assign ("file", file); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1468 retmap.assign ("line", line); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1469 retmap.assign ("cond", cond); |
7083 | 1470 |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1471 octave_map ew = bp_table::stop_on_err_warn_status (false); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1472 if (ew.numel () == 0) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1473 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1474 retval = octave_value (retmap); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1475 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1476 else |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1477 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1478 octave_map outer (dim_vector (3,1)); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1479 outer.assign ("bkpt", Cell (retmap)); |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1480 for (octave_map::const_iterator f = ew.begin (); f != ew.end (); f++) |
21259 | 1481 outer.setfield (f->first, ew.contents (f)); |
1482 | |
1483 retval = octave_value (outer); | |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1484 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1485 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1486 return retval; |
3805 | 1487 } |
1488 } | |
1489 | |
21258
b248c28d9a7b
Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1490 /* |
b248c28d9a7b
Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1491 %!test |
b248c28d9a7b
Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1492 %! dbstop @ftp/dir; |
b248c28d9a7b
Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1493 %! dbstop @audioplayer/set 70; |
b248c28d9a7b
Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1494 %! dbstop quantile>__quantile__; |
b248c28d9a7b
Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1495 %! dbstop ls; |
21259 | 1496 %! s = dbstatus; |
1497 %! dbclear all | |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21568
diff
changeset
|
1498 %! assert (s(1).name, "@audioplayer/set>setproperty"); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21568
diff
changeset
|
1499 %! assert (s(2).name, "@ftp/dir"); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21568
diff
changeset
|
1500 %! assert (s(3).name, "ls"); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21568
diff
changeset
|
1501 %! assert (s(4).name, "quantile>__quantile__"); |
21259 | 1502 %! assert (s(2).file(end-10:end), "/@ftp/dir.m"); |
21258
b248c28d9a7b
Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1503 */ |
b248c28d9a7b
Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1504 |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
1505 DEFUN (dbwhere, , , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17753
diff
changeset
|
1506 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
1507 @deftypefn {} {} dbwhere\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
1508 In debugging mode, report the current file and line number where execution\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
1509 is stopped.\n\ |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1510 @seealso{dbstack, dblist, dbstatus, dbcont, dbstep, dbup, dbdown}\n\ |
5645 | 1511 @end deftypefn") |
3805 | 1512 { |
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
|
1513 octave_user_code *dbg_fcn = get_user_code (); |
3805 | 1514 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1515 if (! dbg_fcn) |
21322
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21318
diff
changeset
|
1516 { |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21318
diff
changeset
|
1517 octave_stdout << "stopped at top level" << std::endl; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21318
diff
changeset
|
1518 return ovl (); |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21318
diff
changeset
|
1519 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1520 |
21322
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21318
diff
changeset
|
1521 octave_stdout << "stopped in " << dbg_fcn->name () << " at "; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1522 |
21322
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21318
diff
changeset
|
1523 int l = octave_call_stack::debug_user_code_line (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1524 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1525 if (l > 0) |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1526 { |
21322
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21318
diff
changeset
|
1527 octave_stdout << "line " << l; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21318
diff
changeset
|
1528 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21318
diff
changeset
|
1529 std::string file_name = dbg_fcn->fcn_file_name (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1530 |
21322
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21318
diff
changeset
|
1531 if (! file_name.empty ()) |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1532 { |
21322
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21318
diff
changeset
|
1533 octave_stdout << " [" << file_name << "]" << std::endl; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21318
diff
changeset
|
1534 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21318
diff
changeset
|
1535 std::string line = get_file_line (file_name, l); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1536 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1537 if (! line.empty ()) |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1538 octave_stdout << l << ": " << line << std::endl; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1539 } |
21322
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21318
diff
changeset
|
1540 else |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21318
diff
changeset
|
1541 octave_stdout << std::endl; |
3805 | 1542 } |
1543 else | |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1544 octave_stdout << "<unknown line>" << std::endl; |
3895 | 1545 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1546 return ovl (); |
3895 | 1547 } |
1548 | |
3946 | 1549 void |
3949 | 1550 do_dbtype (std::ostream& os, const std::string& name, int start, int end) |
3895 | 1551 { |
1552 std::string ff = fcn_file_in_path (name); | |
1553 | |
21077
40f931a63a91
Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
1554 if (ff.empty ()) |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1555 os << "dbtype: unknown function " << name << "\n"; |
21077
40f931a63a91
Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
1556 else |
40f931a63a91
Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
1557 { |
40f931a63a91
Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
1558 std::ifstream fs (ff.c_str (), std::ios::in); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1559 |
21077
40f931a63a91
Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
1560 if (! fs) |
40f931a63a91
Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
1561 os << "dbtype: unable to open '" << ff << "' for reading!\n"; |
40f931a63a91
Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
1562 else |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1563 { |
21077
40f931a63a91
Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
1564 int line = 1; |
40f931a63a91
Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
1565 std::string text; |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1566 |
21077
40f931a63a91
Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
1567 while (std::getline (fs, text) && line <= end) |
40f931a63a91
Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
1568 { |
40f931a63a91
Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
1569 if (line >= start) |
40f931a63a91
Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
1570 os << line << "\t" << text << "\n"; |
40f931a63a91
Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
1571 |
40f931a63a91
Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
1572 line++; |
40f931a63a91
Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
1573 } |
3895 | 1574 } |
21077
40f931a63a91
Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
1575 } |
3895 | 1576 |
6646 | 1577 os.flush (); |
3895 | 1578 } |
1579 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
1580 DEFUN (dbtype, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17753
diff
changeset
|
1581 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
1582 @deftypefn {} {} dbtype\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
1583 @deftypefnx {} {} dbtype @var{lineno}\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
1584 @deftypefnx {} {} dbtype @var{startl:endl}\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
1585 @deftypefnx {} {} dbtype @var{startl:end}\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
1586 @deftypefnx {} {} dbtype @var{func}\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
1587 @deftypefnx {} {} dbtype @var{func} @var{lineno}\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
1588 @deftypefnx {} {} dbtype @var{func} @var{startl:endl}\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
1589 @deftypefnx {} {} dbtype @var{func} @var{startl:end}\n\ |
15577 | 1590 Display a script file with line numbers.\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1591 \n\ |
15577 | 1592 When called with no arguments in debugging mode, display the script file\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
1593 currently being debugged.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
1594 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
1595 An optional range specification can be used to list only a portion of the\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
1596 file. The special keyword @qcode{\"end\"} is a valid line number\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
1597 specification for the last line of the file.\n\ |
15577 | 1598 \n\ |
1599 When called with the name of a function, list that script file with line\n\ | |
1600 numbers.\n\ | |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1601 @seealso{dblist, dbwhere, dbstatus, dbstop}\n\ |
5642 | 1602 @end deftypefn") |
3895 | 1603 { |
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
|
1604 octave_user_code *dbg_fcn; |
3946 | 1605 |
3895 | 1606 string_vector argv = args.make_argv ("dbtype"); |
3946 | 1607 |
20819
f428cbe7576f
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20817
diff
changeset
|
1608 switch (args.length ()) |
3895 | 1609 { |
21259 | 1610 case 0: // dbtype |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1611 dbg_fcn = get_user_code (); |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1612 |
20980
81c2b14c209f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
1613 if (! dbg_fcn) |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1614 error ("dbtype: must be inside a user function to give no arguments to dbtype\n"); |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1615 |
20980
81c2b14c209f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
1616 do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (), |
81c2b14c209f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
1617 0, std::numeric_limits<int>::max ()); |
81c2b14c209f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
1618 |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1619 break; |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1620 |
21259 | 1621 case 1: // (dbtype start:end) || (dbtype func) || (dbtype lineno) |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1622 { |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1623 std::string arg = argv[1]; |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1624 |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1625 size_t ind = arg.find (':'); |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1626 |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1627 if (ind != std::string::npos) // (dbtype start:end) |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1628 { |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1629 dbg_fcn = get_user_code (); |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1630 |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1631 if (dbg_fcn) |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1632 { |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1633 std::string start_str = arg.substr (0, ind); |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1634 std::string end_str = arg.substr (ind + 1); |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1635 |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1636 int start, end; |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1637 start = atoi (start_str.c_str ()); |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1638 if (end_str == "end") |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1639 end = std::numeric_limits<int>::max (); |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1640 else |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1641 end = atoi (end_str.c_str ()); |
3895 | 1642 |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1643 if (std::min (start, end) <= 0) |
20831
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20819
diff
changeset
|
1644 error ("dbtype: start and end lines must be >= 1\n"); |
18393
6a2cc29f55fc
Correctly handle 'dbtype lineno' case.
Rik <rik@octave.org>
parents:
18392
diff
changeset
|
1645 |
20980
81c2b14c209f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
1646 if (start > end) |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1647 error ("dbtype: start line must be less than end line\n"); |
20980
81c2b14c209f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
1648 |
81c2b14c209f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
1649 do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (), |
81c2b14c209f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
1650 start, end); |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1651 } |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1652 } |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1653 else // (dbtype func) || (dbtype lineno) |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1654 { |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1655 int line = atoi (arg.c_str ()); |
3895 | 1656 |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1657 if (line == 0) // (dbtype func) |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1658 { |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1659 dbg_fcn = get_user_code (arg); |
14227
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1660 |
20980
81c2b14c209f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
1661 if (! dbg_fcn) |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1662 error ("dbtype: function <%s> not found\n", arg.c_str ()); |
20980
81c2b14c209f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
1663 |
81c2b14c209f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
1664 do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (), |
81c2b14c209f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
1665 0, std::numeric_limits<int>::max ()); |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1666 } |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1667 else // (dbtype lineno) |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1668 { |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1669 if (line <= 0) |
20831
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20819
diff
changeset
|
1670 error ("dbtype: start and end lines must be >= 1\n"); |
3895 | 1671 |
14227
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1672 dbg_fcn = get_user_code (); |
3895 | 1673 |
14227
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1674 if (dbg_fcn) |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1675 do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (), |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1676 line, line); |
14227
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1677 } |
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1678 } |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1679 } |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1680 break; |
3895 | 1681 |
21259 | 1682 case 2: // (dbtype func start:end) || (dbtype func start) |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1683 { |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1684 dbg_fcn = get_user_code (argv[1]); |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1685 |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1686 if (! dbg_fcn) |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1687 error ("dbtype: function <%s> not found\n", argv[1].c_str ()); |
3895 | 1688 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1689 std::string arg = argv[2]; |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1690 int start, end; |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1691 size_t ind = arg.find (':'); |
6317 | 1692 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1693 if (ind != std::string::npos) |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1694 { |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1695 std::string start_str = arg.substr (0, ind); |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1696 std::string end_str = arg.substr (ind + 1); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1697 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1698 start = atoi (start_str.c_str ()); |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1699 if (end_str == "end") |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1700 end = std::numeric_limits<int>::max (); |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1701 else |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1702 end = atoi (end_str.c_str ()); |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1703 } |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1704 else |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1705 { |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1706 start = atoi (arg.c_str ()); |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1707 end = start; |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1708 } |
14227
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1709 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1710 if (std::min (start, end) <= 0) |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1711 error ("dbtype: start and end lines must be >= 1\n"); |
20980
81c2b14c209f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
1712 |
81c2b14c209f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
1713 if (start > end) |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1714 error ("dbtype: start line must be less than end line\n"); |
3895 | 1715 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1716 do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (), start, end); |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1717 } |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1718 break; |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1719 |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1720 default: |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1721 error ("dbtype: expecting zero, one, or two arguments\n"); |
3895 | 1722 } |
3805 | 1723 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1724 return ovl (); |
3805 | 1725 } |
1726 | |
16842
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1727 DEFUN (dblist, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17753
diff
changeset
|
1728 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
1729 @deftypefn {} {} dblist\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
1730 @deftypefnx {} {} dblist @var{n}\n\ |
16842
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1731 In debugging mode, list @var{n} lines of the function being debugged\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
1732 centered around the current line to be executed.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
1733 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
1734 If unspecified @var{n} defaults to 10 (+/- 5 lines)\n\ |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1735 @seealso{dbwhere, dbtype, dbstack}\n\ |
16842
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1736 @end deftypefn") |
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1737 { |
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1738 int n = 10; |
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1739 |
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1740 if (args.length () == 1) |
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1741 { |
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1742 octave_value arg = args(0); |
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1743 |
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1744 if (arg.is_string ()) |
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1745 { |
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1746 std::string s_arg = arg.string_value (); |
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1747 |
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1748 n = atoi (s_arg.c_str ()); |
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1749 } |
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1750 else |
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1751 n = args(0).int_value (); |
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1752 |
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1753 if (n < 0) |
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1754 error ("dblist: N must be a non-negative integer"); |
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1755 } |
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1756 |
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1757 octave_user_code *dbg_fcn = get_user_code (); |
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1758 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1759 if (! dbg_fcn) |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1760 error ("dblist: must be inside a user function to use dblist\n"); |
16842
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1761 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1762 bool have_file = true; |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1763 |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1764 std::string name = dbg_fcn->fcn_file_name (); |
16842
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1765 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1766 if (name.empty ()) |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1767 { |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1768 have_file = false; |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1769 name = dbg_fcn->name (); |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1770 } |
16842
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1771 |
21322
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21318
diff
changeset
|
1772 int l = octave_call_stack::debug_user_code_line (); |
16842
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1773 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1774 if (l > 0) |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1775 { |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1776 if (have_file) |
16842
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1777 { |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1778 int l_min = std::max (l - n/2, 0); |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1779 int l_max = l + n/2; |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1780 do_dbtype (octave_stdout, name, l_min, l-1); |
16842
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1781 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1782 std::string line = get_file_line (name, l); |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1783 if (! line.empty ()) |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1784 octave_stdout << l << "-->\t" << line << std::endl; |
16842
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1785 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1786 do_dbtype (octave_stdout, name, l+1, l_max); |
16842
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1787 } |
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1788 } |
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1789 else |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1790 { |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1791 octave_stdout << "dblist: unable to determine source code line" |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1792 << std::endl; |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1793 } |
16842
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1794 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1795 return ovl (); |
16842
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1796 } |
035b5fe157ad
Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents:
16771
diff
changeset
|
1797 |
13689
b68d95054947
print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents:
13326
diff
changeset
|
1798 static octave_value_list |
b68d95054947
print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents:
13326
diff
changeset
|
1799 do_dbstack (const octave_value_list& args, int nargout, std::ostream& os) |
7736 | 1800 { |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
1801 int nargin = args.length (); |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
1802 |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
1803 if (nargin > 2) |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
1804 print_usage (); |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
1805 |
7736 | 1806 octave_value_list retval; |
1807 | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9724
diff
changeset
|
1808 unwind_protect frame; |
7890 | 1809 |
7901 | 1810 octave_idx_type curr_frame = -1; |
7890 | 1811 |
7901 | 1812 size_t nskip = 0; |
7736 | 1813 |
20817
3d551b2ae928
Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents:
20804
diff
changeset
|
1814 if (nargin == 1 || nargin == 2) |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1815 { |
7890 | 1816 int n = 0; |
1817 | |
20817
3d551b2ae928
Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents:
20804
diff
changeset
|
1818 for (octave_idx_type i = 0; i < nargin; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1819 { |
17649
a09511ebf7ef
Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17281
diff
changeset
|
1820 octave_value arg = args(i); |
a09511ebf7ef
Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17281
diff
changeset
|
1821 |
a09511ebf7ef
Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17281
diff
changeset
|
1822 if (arg.is_string ()) |
a09511ebf7ef
Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17281
diff
changeset
|
1823 { |
a09511ebf7ef
Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17281
diff
changeset
|
1824 std::string s_arg = arg.string_value (); |
a09511ebf7ef
Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17281
diff
changeset
|
1825 |
a09511ebf7ef
Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17281
diff
changeset
|
1826 // Skip "-completenames", octave returns full names anyway. |
a09511ebf7ef
Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17281
diff
changeset
|
1827 if (s_arg == "-completenames") |
a09511ebf7ef
Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17281
diff
changeset
|
1828 continue; |
a09511ebf7ef
Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17281
diff
changeset
|
1829 |
a09511ebf7ef
Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17281
diff
changeset
|
1830 n = atoi (s_arg.c_str ()); |
a09511ebf7ef
Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17281
diff
changeset
|
1831 } |
a09511ebf7ef
Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17281
diff
changeset
|
1832 else |
a09511ebf7ef
Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17281
diff
changeset
|
1833 n = arg.int_value (); |
a09511ebf7ef
Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17281
diff
changeset
|
1834 |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1835 if (n <= 0) |
17649
a09511ebf7ef
Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17281
diff
changeset
|
1836 error ("dbstack: N must be a non-negative integer"); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1837 } |
7890 | 1838 |
1839 if (n > 0) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1840 nskip = n; |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1841 } |
7736 | 1842 |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1843 if (nargout == 0) |
7736 | 1844 { |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1845 octave_map stk = octave_call_stack::backtrace (nskip, curr_frame); |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1846 octave_idx_type nframes_to_display = stk.numel (); |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1847 |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1848 if (nframes_to_display > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1849 { |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1850 octave_preserve_stream_state stream_state (os); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1851 |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1852 os << "stopped in:\n\n"; |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1853 |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1854 Cell names = stk.contents ("name"); |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1855 Cell files = stk.contents ("file"); |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1856 Cell lines = stk.contents ("line"); |
10839 | 1857 |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1858 bool show_top_level = true; |
10839 | 1859 |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1860 size_t max_name_len = 0; |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1861 |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1862 for (octave_idx_type i = 0; i < nframes_to_display; i++) |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1863 { |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1864 std::string name = names(i).string_value (); |
10839 | 1865 |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1866 max_name_len = std::max (name.length (), max_name_len); |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1867 } |
7890 | 1868 |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1869 for (octave_idx_type i = 0; i < nframes_to_display; i++) |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1870 { |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1871 std::string name = names(i).string_value (); |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1872 std::string file = files(i).string_value (); |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1873 int line = lines(i).int_value (); |
10839 | 1874 |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1875 if (show_top_level && i == curr_frame) |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1876 show_top_level = false; |
10839 | 1877 |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1878 os << (i == curr_frame ? " --> " : " ") |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1879 << std::setw (max_name_len) << name |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1880 << " at line " << line |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1881 << " [" << file << "]" |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1882 << std::endl; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1883 } |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1884 |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1885 if (show_top_level) |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1886 os << " --> top level" << std::endl; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1887 } |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1888 } |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1889 else |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1890 { |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1891 octave_map stk = octave_call_stack::backtrace (nskip, curr_frame, false); |
18440
96a495813047
Don't put parent function in subfunction stack structure name (bug #41506).
Rik <rik@octave.org>
parents:
18398
diff
changeset
|
1892 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1893 retval = ovl (stk, curr_frame < 0 ? 1 : curr_frame + 1); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1894 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1895 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1896 return retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1897 } |
7736 | 1898 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1899 // A function that can be easily called from a debugger print the Octave stack. |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1900 // This can be useful for finding what line of code the interpreter is |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1901 // currently executing when the debugger is stopped in some C++ function, |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1902 // for example. |
13326
23cc9c13b622
show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
1903 |
13784
0bbe319bf26b
octave_class::size: return matrix with correct dimensions
John W. Eaton <jwe@octave.org>
parents:
13689
diff
changeset
|
1904 void |
13326
23cc9c13b622
show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
1905 show_octave_dbstack (void) |
23cc9c13b622
show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
1906 { |
13689
b68d95054947
print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents:
13326
diff
changeset
|
1907 do_dbstack (octave_value_list (), 0, std::cerr); |
b68d95054947
print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents:
13326
diff
changeset
|
1908 } |
b68d95054947
print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents:
13326
diff
changeset
|
1909 |
b68d95054947
print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents:
13326
diff
changeset
|
1910 DEFUN (dbstack, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17753
diff
changeset
|
1911 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
1912 @deftypefn {} {} dbstack\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
1913 @deftypefnx {} {} dbstack @var{n}\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
1914 @deftypefnx {} {} dbstack @var{-completenames}\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
1915 @deftypefnx {} {[@var{stack}, @var{idx}] =} dbstack (@dots{})\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1916 Display or return current debugging function stack information.\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
1917 \n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1918 With optional argument @var{n}, omit the @var{n} innermost stack frames.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1919 \n\ |
17649
a09511ebf7ef
Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17281
diff
changeset
|
1920 Although accepted, the argument @var{-completenames} is silently ignored.\n\ |
20713
2469d78a1d8b
Consistently use 'filename' rather than 'file name' throughout code base.
Rik <rik@octave.org>
parents:
20700
diff
changeset
|
1921 Octave always returns absolute filenames.\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
1922 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
1923 The arguments @var{n} and @var{-completenames} can be both specified in any\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
1924 order.\n\ |
17649
a09511ebf7ef
Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17281
diff
changeset
|
1925 \n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1926 The optional return argument @var{stack} is a struct array with the\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1927 following fields:\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1928 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1929 @table @asis\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1930 @item file\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1931 The name of the m-file where the function code is located.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1932 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1933 @item name\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1934 The name of the function with a breakpoint.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1935 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1936 @item line\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1937 The line number of an active breakpoint.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1938 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1939 @item column\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1940 The column number of the line where the breakpoint begins.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1941 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1942 @item scope\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1943 Undocumented.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1944 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1945 @item context\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1946 Undocumented.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1947 @end table\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1948 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1949 The return argument @var{idx} specifies which element of the @var{stack}\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1950 struct array is currently active.\n\ |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21127
diff
changeset
|
1951 @seealso{dbup, dbdown, dbwhere, dblist, dbstatus}\n\ |
13689
b68d95054947
print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents:
13326
diff
changeset
|
1952 @end deftypefn") |
b68d95054947
print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents:
13326
diff
changeset
|
1953 { |
b68d95054947
print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents:
13326
diff
changeset
|
1954 return do_dbstack (args, nargout, octave_stdout); |
13326
23cc9c13b622
show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
1955 } |
23cc9c13b622
show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
1956 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1957 static void |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1958 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
|
1959 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1960 int n = 1; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1961 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1962 if (args.length () == 1) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1963 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1964 octave_value arg = args(0); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1965 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1966 if (arg.is_string ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1967 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1968 std::string s_arg = arg.string_value (); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1969 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1970 n = atoi (s_arg.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1971 } |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1972 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1973 n = args(0).int_value (); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1974 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1975 |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1976 if (who == "dbup") |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1977 n = -n; |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1978 |
20557
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1979 if (! octave_call_stack::goto_frame_relative (n, true)) |
b10432a40432
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1980 error ("%s: invalid stack frame", who.c_str ()); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1981 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1982 |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
1983 DEFUN (dbup, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17753
diff
changeset
|
1984 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
1985 @deftypefn {} {} dbup\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
1986 @deftypefnx {} {} dbup @var{n}\n\ |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1987 In debugging mode, move up the execution stack @var{n} frames.\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
1988 \n\ |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1989 If @var{n} is omitted, move up one frame.\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1990 @seealso{dbstack, dbdown}\n\ |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1991 @end deftypefn") |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1992 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1993 do_dbupdown (args, "dbup"); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1994 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
1995 return ovl (); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1996 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1997 |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
1998 DEFUN (dbdown, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17753
diff
changeset
|
1999 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
2000 @deftypefn {} {} dbdown\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
2001 @deftypefnx {} {} dbdown @var{n}\n\ |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
2002 In debugging mode, move down the execution stack @var{n} frames.\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
2003 \n\ |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
2004 If @var{n} is omitted, move down one frame.\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
2005 @seealso{dbstack, dbup}\n\ |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
2006 @end deftypefn") |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
2007 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
2008 do_dbupdown (args, "dbdown"); |
7736 | 2009 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
2010 return ovl (); |
7736 | 2011 } |
2012 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
2013 DEFUN (dbstep, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17753
diff
changeset
|
2014 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
2015 @deftypefn {} {} dbstep\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
2016 @deftypefnx {} {} dbstep @var{n}\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
2017 @deftypefnx {} {} dbstep in\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
2018 @deftypefnx {} {} dbstep out\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
2019 @deftypefnx {} {} dbnext @dots{}\n\ |
9724
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9484
diff
changeset
|
2020 In debugging mode, execute the next @var{n} lines of code.\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
2021 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
2022 If @var{n} is omitted, execute the next single line of code. If the next\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
2023 line of code is itself defined in terms of an m-file remain in the existing\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
2024 function.\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
|
2025 \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
|
2026 Using @code{dbstep in} will cause execution of the next line to step into\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
2027 any m-files defined on the next line.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
2028 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
2029 Using @code{dbstep out} will cause execution to continue until the current\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
2030 function returns.\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
2031 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
2032 @code{dbnext} is an alias for @code{dbstep}.\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
|
2033 @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
|
2034 @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
|
2035 { |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2036 if (! Vdebugging) |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2037 error ("dbstep: can only be called in debug mode"); |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2038 |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2039 int nargin = args.length (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2040 |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2041 if (nargin > 1) |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2042 print_usage (); |
20804
a6eaedd8bd75
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20713
diff
changeset
|
2043 |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2044 if (nargin == 1) |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2045 { |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2046 std::string arg = args(0).xstring_value ("dbstep: input argument must be a string"); |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2047 |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2048 if (arg == "in") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2049 { |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2050 Vdebugging = false; |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2051 |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2052 tree_evaluator::dbstep_flag = -1; |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2053 } |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2054 else if (arg == "out") |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2055 { |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2056 Vdebugging = false; |
20582
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20557
diff
changeset
|
2057 |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2058 tree_evaluator::dbstep_flag = -2; |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2059 } |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2060 else |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2061 { |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2062 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
|
2063 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
2064 if (n < 1) |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
2065 error ("dbstep: invalid argument"); |
19743
67f2c76f9f4d
Remove unnecessary checking of error_state after is_string validation.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
2066 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
2067 Vdebugging = false; |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
2068 |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20941
diff
changeset
|
2069 tree_evaluator::dbstep_flag = n; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2070 } |
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
|
2071 } |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
2072 else |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2073 { |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2074 Vdebugging = false; |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2075 |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2076 tree_evaluator::dbstep_flag = 1; |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2077 } |
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
|
2078 |
20941
a4f5da7c5463
maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
2079 return ovl (); |
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
|
2080 } |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
2081 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
2082 DEFALIAS (dbnext, dbstep); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
2083 |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
2084 DEFUN (dbcont, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17753
diff
changeset
|
2085 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
2086 @deftypefn {} {} dbcont\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
2087 Leave command-line debugging mode and continue code execution normally.\n\ |
9724
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9484
diff
changeset
|
2088 @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
|
2089 @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
|
2090 { |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2091 if (! Vdebugging) |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2092 error ("dbcont: can only be called in debug mode"); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
2093 |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2094 if (args.length () != 0) |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2095 print_usage (); |
20804
a6eaedd8bd75
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20713
diff
changeset
|
2096 |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2097 Vdebugging = false; |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2098 |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2099 tree_evaluator::reset_debug_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
|
2100 |
20941
a4f5da7c5463
maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
2101 return ovl (); |
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
|
2102 } |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
2103 |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
2104 DEFUN (dbquit, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17753
diff
changeset
|
2105 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
2106 @deftypefn {} {} dbquit\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
2107 Quit debugging mode immediately without further code execution and return to\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
2108 the Octave prompt.\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
2109 @seealso{dbcont, dbstep}\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
|
2110 @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
|
2111 { |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2112 if (! Vdebugging) |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2113 error ("dbquit: can only be called in debug mode"); |
10186
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
2114 |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2115 if (args.length () != 0) |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2116 print_usage (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
2117 |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2118 Vdebugging = false; |
20804
a6eaedd8bd75
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20713
diff
changeset
|
2119 |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2120 tree_evaluator::reset_debug_state (); |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2121 |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2122 octave_throw_interrupt_exception (); |
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
|
2123 |
20941
a4f5da7c5463
maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
2124 return ovl (); |
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
|
2125 } |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
2126 |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
2127 DEFUN (isdebugmode, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17753
diff
changeset
|
2128 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
2129 @deftypefn {} {} isdebugmode ()\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
2130 Return true if in debugging mode, otherwise false.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
2131 @seealso{dbwhere, dbstack, dbstatus}\n\ |
8114
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
2132 @end deftypefn") |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
2133 { |
20804
a6eaedd8bd75
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20713
diff
changeset
|
2134 if (args.length () != 0) |
8114
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
2135 print_usage (); |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
2136 |
21127
df7891224709
maint: Use "return ovl (...)" in DEFUN macros.
Rik <rik@octave.org>
parents:
21118
diff
changeset
|
2137 return ovl (Vdebugging); |
8114
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
2138 } |
19379
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18236
diff
changeset
|
2139 |
19855
a59c5a16c9ab
Rename db_next_breakpoint_quiet to internal function.
Rik <rik@octave.org>
parents:
19743
diff
changeset
|
2140 DEFUN (__db_next_breakpoint_quiet__, args, , |
19379
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18236
diff
changeset
|
2141 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
2142 @deftypefn {} {} __db_next_breakpoint_quiet__ ()\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
2143 @deftypefnx {} {} __db_next_breakpoint_quiet__ (@var{flag})\n\ |
19855
a59c5a16c9ab
Rename db_next_breakpoint_quiet to internal function.
Rik <rik@octave.org>
parents:
19743
diff
changeset
|
2144 Disable line info printing at the next breakpoint.\n\ |
a59c5a16c9ab
Rename db_next_breakpoint_quiet to internal function.
Rik <rik@octave.org>
parents:
19743
diff
changeset
|
2145 \n\ |
a59c5a16c9ab
Rename db_next_breakpoint_quiet to internal function.
Rik <rik@octave.org>
parents:
19743
diff
changeset
|
2146 With a logical argument @var{flag}, set the state on or off.\n\ |
19379
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18236
diff
changeset
|
2147 @end deftypefn") |
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18236
diff
changeset
|
2148 { |
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18236
diff
changeset
|
2149 int nargin = args.length (); |
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18236
diff
changeset
|
2150 |
20804
a6eaedd8bd75
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20713
diff
changeset
|
2151 if (nargin > 1) |
a6eaedd8bd75
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20713
diff
changeset
|
2152 print_usage (); |
a6eaedd8bd75
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20713
diff
changeset
|
2153 |
a6eaedd8bd75
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20713
diff
changeset
|
2154 bool state = true; |
19379
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18236
diff
changeset
|
2155 |
20804
a6eaedd8bd75
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20713
diff
changeset
|
2156 if (nargin == 1) |
a6eaedd8bd75
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20713
diff
changeset
|
2157 state = args(0).bool_value (); |
19379
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18236
diff
changeset
|
2158 |
20804
a6eaedd8bd75
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20713
diff
changeset
|
2159 tree_evaluator::quiet_breakpoint_flag = state; |
19379
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18236
diff
changeset
|
2160 |
20941
a4f5da7c5463
maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
2161 return ovl (); |
19379
c1ce43276b86
avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents:
18236
diff
changeset
|
2162 } |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
2163 |