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