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