Mercurial > octave
annotate libinterp/parse-tree/bp-table.cc @ 27000:711f23332204
eliminate some unnecessary include statements
* oct-lvalue.h: Include stack-frame.h instead of call-stack.h.
* defun.cc, ddef-method.cc, cdef-package.cc: Don't include pt-eval.h.
* bp-table.cc, symtab.cc, toplev.cc: Don't include call-stack.h.
* fcn-info.cc, symtab.cc, pt-decl.h, pt-misc.h: Don't include symrec.h.
* symrec.cc: Don't include symscope.h.
* cdef-package.cc, pt-stmt.cc: Don't include pt-walk.h.
* ov-classdef.cc: Don't include symtab.h.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 29 Mar 2019 17:06:55 +0000 |
parents | de826e69a5ea |
children | 8408acb7ca4f |
rev | line source |
---|---|
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1 /* |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2 |
26376
00f796120a6d
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
26115
diff
changeset
|
3 Copyright (C) 2001-2019 Ben Sapp |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4 Copyright (C) 2007-2009 John Swensen |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 This file is part of Octave. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
7 |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24286
diff
changeset
|
8 Octave is free software: you can redistribute it and/or modify it |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
9 under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24286
diff
changeset
|
10 the Free Software Foundation, either version 3 of the License, or |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 (at your option) any later version. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
12 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
13 Octave is distributed in the hope that it will be useful, but |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
14 WITHOUT ANY WARRANTY; without even the implied warranty of |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
16 GNU General Public License for more details. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
17 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
18 You should have received a copy of the GNU General Public License |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
19 along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24286
diff
changeset
|
20 <https://www.gnu.org/licenses/>. |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
21 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
22 */ |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
23 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
24 #if defined (HAVE_CONFIG_H) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 # include "config.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 #endif |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 |
23824
061a343089be
Miscellaneous cleanups of C++11 std::string code.
Rik <rik@octave.org>
parents:
23807
diff
changeset
|
28 #include <algorithm> |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 #include <limits> |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 #include <list> |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 #include <map> |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 #include <set> |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 #include <string> |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 #include "file-ops.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 #include "bp-table.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 #include "defun-int.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 #include "error.h" |
25347
af3319d86a5f
eliminate some global references to interpreter internals
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
40 #include "interpreter.h" |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
41 #include "interpreter-private.h" |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
42 #include "oct-map.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
43 #include "octave-link.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
44 #include "ov-usr-fcn.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
45 #include "ov.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
46 #include "ovl.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
47 #include "pager.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
48 #include "parse.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 #include "pt-eval.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
50 #include "pt-exp.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
51 #include "pt-stmt.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
52 #include "sighandlers.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
53 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
54 namespace octave |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
55 { |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
56 // Clear all reasons to stop, other than breakpoints. |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
57 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
58 void bp_table::dbclear_all_signals (void) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
59 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
60 Vdebug_on_error = false; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
61 bp_table::m_errors_that_stop.clear (); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
62 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
63 Vdebug_on_caught = false; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
64 bp_table::m_caught_that_stop.clear (); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
65 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
66 Vdebug_on_warning = false; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
67 bp_table::m_warnings_that_stop.clear (); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
68 |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
69 Vdebug_on_interrupt = false; |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
70 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
71 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
72 // Process the "warn", "errs", "caught" and "intr" fields for a call of |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
73 // "dbstop (p)". |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
74 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
75 void bp_table::dbstop_process_map_args (const octave_map& mv) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
76 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
77 // process errs |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
78 // why so many levels of indirection needed? |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
79 bool fail = false; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
80 Cell U = mv.contents ("errs"); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
81 if (U.numel () != 1) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
82 fail = (U.numel () > 1); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
83 else |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
84 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
85 Array<octave_value> W = U.index (static_cast<octave_idx_type> (0)); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
86 if (W.isempty () || W(0).isempty ()) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
87 Vdebug_on_error = 1; // like "dbstop if error" with no identifier |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
88 else if (! W(0).iscell ()) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
89 fail = true; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
90 else |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
91 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
92 Cell V = W(0).cell_value (); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
93 for (int i = 0; i < V.numel (); i++) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
94 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
95 m_errors_that_stop.insert (V(i).string_value ()); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
96 Vdebug_on_error = 1; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
97 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
98 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
99 } |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
100 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
101 if (fail) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
102 error ("dbstop: invalid 'errs' field"); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
103 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
104 // process caught |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
105 // why so many levels of indirection needed? |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
106 fail = false; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
107 U = mv.contents ("caught"); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
108 if (U.numel () != 1) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
109 fail = (U.numel () > 1); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
110 else |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
111 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
112 Array<octave_value> W = U.index (static_cast<octave_idx_type> (0)); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
113 if (W.isempty () || W(0).isempty ()) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
114 Vdebug_on_caught = 1; // like "dbstop if caught error" with no ID |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
115 else if (! W(0).iscell ()) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
116 fail = true; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
117 else |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
118 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
119 Cell V = W(0).cell_value (); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
120 for (int i = 0; i < V.numel (); i++) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
121 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
122 m_caught_that_stop.insert (V(i).string_value ()); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
123 Vdebug_on_caught = 1; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
124 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
125 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
126 } |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
127 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
128 if (fail) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
129 error ("dbstop: invalid 'caught' field"); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
130 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
131 // process warn |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
132 // why so many levels of indirection needed? |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
133 fail = false; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
134 U = mv.contents ("warn"); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
135 if (U.numel () != 1) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
136 fail = (U.numel () > 1); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
137 else |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
138 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
139 Array<octave_value> W = U.index (static_cast<octave_idx_type> (0)); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
140 if (W.isempty () || W(0).isempty ()) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
141 Vdebug_on_warning = 1; // like "dbstop if warning" with no identifier |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
142 else if (! W(0).iscell ()) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
143 fail = true; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
144 else |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
145 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
146 Cell V = W(0).cell_value (); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
147 for (int i = 0; i < V.numel (); i++) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
148 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
149 m_warnings_that_stop.insert (V(i).string_value ()); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
150 Vdebug_on_warning = 1; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
151 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
152 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
153 } |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
154 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
155 if (fail) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
156 error ("dbstop: invalid 'warn' field"); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
157 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
158 // process interrupt |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
159 if (mv.isfield ("intr")) |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
160 Vdebug_on_interrupt = 1; |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
161 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
162 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
163 // Insert a breakpoint in function fcn at line within file fname, |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
164 // to stop only when condition is true. |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
165 // Record in m_bp_set that fname contains a breakpoint. |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
166 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
167 bool bp_table::add_breakpoint_1 (octave_user_code *fcn, |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
168 const std::string& fname, |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
169 const bp_table::intmap& line, |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
170 const std::string& condition, |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
171 bp_table::intmap& retval) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
172 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
173 bool found = false; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
174 |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
175 tree_statement_list *cmds = fcn->body (); |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
176 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
177 std::string file = fcn->fcn_file_name (); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
178 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
179 if (cmds) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
180 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
181 retval = cmds->add_breakpoint (file, line, condition); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
182 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
183 for (auto& idx_line_p : retval) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
184 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
185 if (idx_line_p.second != 0) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
186 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
187 // Normalize to store only the file name. |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
188 // Otherwise, there can be an entry for both |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
189 // file>subfunction and file, which causes a crash on |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
190 // dbclear all |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
191 const char *s = strchr (fname.c_str (), '>'); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
192 if (s) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
193 m_bp_set.insert (fname.substr (0, s - fname.c_str ())); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
194 else |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
195 m_bp_set.insert (fname); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
196 found = true; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
197 break; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
198 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
199 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
200 } |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
201 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
202 return found; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
203 } |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
204 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
205 // Cursory check that cond is a valid condition to use for a breakpoint. |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
206 // Currently allows conditions with side-effects, like 'y+=10' and 'y++'; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
207 // it is odd that the former is not flagged by "is_assignment_expression". |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
208 // Throws an exception if not valid. |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
209 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
210 bool bp_table::condition_valid (const std::string& cond) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
211 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
212 if (cond.length () > 0) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
213 { |
25441
143007dad864
store reference instead of pointer to interpreter in lexer
John W. Eaton <jwe@octave.org>
parents:
25438
diff
changeset
|
214 // ; to reject partial expr like "y==" |
143007dad864
store reference instead of pointer to interpreter in lexer
John W. Eaton <jwe@octave.org>
parents:
25438
diff
changeset
|
215 parser parser (cond + " ;", m_evaluator.get_interpreter ()); |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
216 parser.reset (); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
217 int parse_status = parser.run (); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
218 if (parse_status) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
219 error ("dbstop: Cannot parse condition '%s'", cond.c_str ()); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
220 else |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
221 { |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
222 tree_statement *stmt = nullptr; |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
223 if (! parser.m_stmt_list) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
224 error ("dbstop: " |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
225 "condition is not empty, but has nothing to evaluate"); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
226 else |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
227 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
228 if (parser.m_stmt_list->length () == 1 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
229 && (stmt = parser.m_stmt_list->front ()) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
230 && stmt->is_expression ()) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
231 { |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
232 tree_expression *expr = stmt->expression (); |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
233 if (expr->is_assignment_expression ()) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
234 error ("dbstop: condition cannot be an assignment. " |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
235 "Did you mean '=='?"); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
236 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
237 else |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
238 error ("dbstop: condition must be an expression"); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
239 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
240 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
241 } |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
242 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
243 return true; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
244 } |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
245 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
246 enum dbstop_args |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
247 { |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
248 dbstop_in, |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
249 dbstop_at, |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
250 dbstop_if, |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
251 dbstop_none |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
252 }; |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
253 |
26954
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
254 // FIXME: This function probalby needs to be completely overhauled to |
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
255 // correctly parse the full syntax of the dbstop command and properly |
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
256 // reject incorrect forms. |
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
257 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
258 // Parse parameters (args) of dbstop and dbclear commands. |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
259 // For dbstop, who=="dbstop"; for dbclear, who=="dbclear". |
26954
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
260 // The syntax is: dbstop [[in] symbol] [[at] [method | line [line [...]]]] [if condition] |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
261 // where the form of condition depends on whether or not a file or line has |
26954
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
262 // been seen. IF symbol and method are specified, then symbol should |
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
263 // be a class name. Otherwise it should be a function name. |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
264 // Also execute "if [error|warning|interrupt|naninf]" clauses. |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
265 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
266 void bp_table::parse_dbfunction_params (const char *who, |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
267 const octave_value_list& args, |
26954
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
268 std::string& func_name, |
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
269 std::string& class_name, |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
270 bp_table::intmap& lines, |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
271 std::string& cond) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
272 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
273 int nargin = args.length (); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
274 int list_idx = 0; |
26954
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
275 func_name = ""; |
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
276 class_name = ""; |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
277 lines = bp_table::intmap (); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
278 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
279 if (nargin == 0 || ! args(0).is_string ()) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
280 print_usage (who); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
281 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
282 // elements already processed |
26586
5fec5393a9c8
bp-table.cc: Don't declare and initialize multiple vars on one line.
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
283 bool seen_in = false; |
5fec5393a9c8
bp-table.cc: Don't declare and initialize multiple vars on one line.
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
284 bool seen_at = false; |
5fec5393a9c8
bp-table.cc: Don't declare and initialize multiple vars on one line.
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
285 bool seen_if = false; |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
286 int pos = 0; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
287 dbstop_args tok = dbstop_none; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
288 while (pos < nargin) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
289 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
290 // allow "in" and "at" to be implicit |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
291 if (args(pos).is_string ()) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
292 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
293 std::string arg = args(pos).string_value (); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
294 if (arg == "in") |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
295 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
296 tok = dbstop_in; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
297 pos++; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
298 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
299 else if (arg == "at") |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
300 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
301 tok = dbstop_at; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
302 pos++; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
303 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
304 else if (arg == "if") |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
305 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
306 tok = dbstop_if; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
307 pos++; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
308 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
309 else if (atoi (args(pos).string_value ().c_str ()) > 0) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
310 tok = dbstop_at; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
311 else |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
312 tok = dbstop_in; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
313 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
314 else |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
315 tok = dbstop_at; |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
316 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
317 if (pos >= nargin) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
318 error ("%s: '%s' missing argument", who, |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
319 (tok == dbstop_in |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
320 ? "in" : (tok == dbstop_at ? "at" : "if"))); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
321 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
322 // process the actual arguments |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
323 switch (tok) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
324 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
325 case dbstop_in: |
26954
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
326 func_name = args(pos).string_value (); |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
327 if (seen_in) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
328 error ("%s: Too many function names specified -- %s", |
26954
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
329 who, func_name.c_str ()); |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
330 else if (seen_at || seen_if) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
331 error ("%s: function name must come before line number and 'if'", |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
332 who); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
333 seen_in = true; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
334 pos++; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
335 break; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
336 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
337 case dbstop_at: |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
338 if (seen_at) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
339 error ("%s: Only one 'at' clause is allowed -- %s", |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
340 who, args(pos).string_value ().c_str ()); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
341 else if (seen_if) |
26107
05dfcb24ef12
Supply missing arguments to variable length *printf functions (bug #55046).
Rik <rik@octave.org>
parents:
25441
diff
changeset
|
342 error ("%s: line number must come before 'if' clause\n", who); |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
343 seen_at = true; |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
344 |
26954
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
345 if (seen_if) |
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
346 error ("%s: line number must come before 'if' clause\n", who); |
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
347 else if (seen_in) |
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
348 { |
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
349 std::string arg = args(pos).string_value (); |
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
350 |
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
351 // FIXME: we really want to distinguish number |
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
352 // vs. method name here. |
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
353 |
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
354 if (atoi (arg.c_str ()) == 0) |
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
355 { |
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
356 // We have class and function names but already |
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
357 // stored the class name in func_name. |
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
358 class_name = func_name; |
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
359 func_name = arg; |
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
360 pos++; |
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
361 break; |
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
362 } |
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
363 |
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
364 } |
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
365 else |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
366 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
367 // It was a line number. Get function name from debugger. |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
368 if (Vdebugging) |
26954
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
369 func_name = m_evaluator.get_user_code ()->profiler_name (); |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
370 else |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
371 error ("%s: function name must come before line number " |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
372 "and 'if'", who); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
373 seen_in = true; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
374 } |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
375 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
376 // Read a list of line numbers (or arrays thereof) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
377 for ( ; pos < nargin; pos++) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
378 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
379 if (args(pos).is_string ()) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
380 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
381 int line = atoi (args(pos).string_value ().c_str ()); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
382 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
383 if (line > 0) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
384 lines[list_idx++] = line; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
385 else |
26954
6e50f1fedeb5
dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents:
26586
diff
changeset
|
386 break; // may be "if" or a method name |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
387 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
388 else if (args(pos).isnumeric ()) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
389 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
390 const NDArray arg = args(pos).array_value (); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
391 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
392 for (octave_idx_type j = 0; j < arg.numel (); j++) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
393 lines[list_idx++] = static_cast<int> (arg.elem (j)); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
394 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
395 else |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
396 error ("%s: Invalid argument type %s", |
26107
05dfcb24ef12
Supply missing arguments to variable length *printf functions (bug #55046).
Rik <rik@octave.org>
parents:
25441
diff
changeset
|
397 who, args(pos).type_name ().c_str ()); |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
398 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
399 break; |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
400 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
401 case dbstop_if: |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
402 if (seen_in) // conditional breakpoint |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
403 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
404 cond = ""; // remaining arguments form condition |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
405 for (; pos < nargin; pos++) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
406 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
407 if (args(pos).is_string ()) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
408 cond += ' ' + args(pos).string_value (); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
409 else |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
410 error ("%s: arguments to 'if' must all be strings", who); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
411 } |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
412 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
413 cond = cond.substr (1); // omit initial space |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
414 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
415 else // stop on event (error, warning, interrupt, NaN/inf) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
416 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
417 std::string condition = args(pos).string_value (); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
418 int on_off = ! strcmp(who, "dbstop"); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
419 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
420 // list of error/warning IDs to update |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
421 std::set<std::string> *id_list = nullptr; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
422 bool *stop_flag = nullptr; // Vdebug_on_... flag |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
423 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
424 if (condition == "error") |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
425 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
426 id_list = &m_errors_that_stop; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
427 stop_flag = &Vdebug_on_error; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
428 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
429 else if (condition == "warning") |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
430 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
431 id_list = &m_warnings_that_stop; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
432 stop_flag = &Vdebug_on_warning; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
433 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
434 else if (condition == "caught" && nargin > pos+1 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
435 && args(pos+1).string_value () == "error") |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
436 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
437 id_list = &m_caught_that_stop; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
438 stop_flag = &Vdebug_on_caught; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
439 pos++; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
440 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
441 else if (condition == "interrupt") |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
442 { |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
443 Vdebug_on_interrupt = on_off; |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
444 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
445 else if (condition == "naninf") |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
446 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
447 #if defined (DBSTOP_NANINF) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
448 Vdebug_on_naninf = on_off; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
449 enable_fpe (on_off); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
450 #else |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
451 warning ("%s: condition '%s' not yet supported", |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
452 who, condition.c_str ()); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
453 #endif |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
454 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
455 else |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
456 error ("%s: invalid condition %s", |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
457 who, condition.c_str ()); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
458 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
459 // process ID list for "dbstop if error <error_ID>" etc |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
460 if (id_list) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
461 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
462 pos++; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
463 if (pos < nargin) // only affect a single error ID |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
464 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
465 if (! args(pos).is_string () || nargin > pos+1) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
466 error ("%s: ID must be a single string", who); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
467 else if (on_off == 1) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
468 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
469 id_list->insert (args(pos).string_value ()); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
470 *stop_flag = true; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
471 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
472 else |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
473 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
474 id_list->erase (args(pos).string_value ()); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
475 if (id_list->empty ()) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
476 *stop_flag = false; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
477 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
478 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
479 else // unqualified. Turn all on or off |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
480 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
481 id_list->clear (); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
482 *stop_flag = on_off; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
483 if (stop_flag == &Vdebug_on_error) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
484 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
485 // Matlab stops on both. |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
486 Vdebug_on_interrupt = on_off; |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
487 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
488 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
489 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
490 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
491 pos = nargin; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
492 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
493 break; |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
494 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
495 default: // dbstop_none should never occur |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
496 break; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
497 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
498 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
499 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
500 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
501 /* |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
502 %!test |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
503 %! dbclear all; # Clear out breakpoints before test |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
504 %! dbstop help; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
505 %! dbstop in ls; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
506 %! dbstop help at 100; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
507 %! dbstop in ls 100; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
508 %! dbstop help 201 if a==5; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
509 %! dbstop if error Octave:undefined-function; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
510 %! s = dbstatus; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
511 %! dbclear all; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
512 %! assert ({s.bkpt(:).name}, {"help", "help", "help>do_contents", "ls", "ls"}); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
513 %! assert ([s.bkpt(:).line], [48, 100, 201, 58, 100]); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
514 %! assert (s.errs, {"Octave:undefined-function"}); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
515 */ |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
516 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
517 // Return the sub/nested/main function of MAIN_FCN that contains |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
518 // line number LINENO of the source file. |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
519 // If END_LINE != 0, *END_LINE is set to last line of the returned function. |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
520 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
521 static octave_user_code * find_fcn_by_line (octave_user_code *main_fcn, |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
522 int lineno, int *end_line = nullptr) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
523 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
524 octave_user_code *retval = nullptr; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
525 octave_user_code *next_fcn = nullptr; // 1st function starting after lineno |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
526 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
527 // Find innermost nested (or parent) function containing lineno. |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
528 int earliest_end = std::numeric_limits<int>::max (); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
529 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
530 std::map<std::string, octave_value> subfcns = main_fcn->subfunctions (); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
531 for (const auto& str_val_p : subfcns) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
532 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
533 if (str_val_p.second.is_user_function ()) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
534 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
535 auto *dbg_subfcn = str_val_p.second.user_function_value (); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
536 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
537 // Check if lineno is within dbg_subfcn. |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
538 // FIXME: we could break when beginning_line() > lineno, |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
539 // but that makes the code "fragile" |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
540 // if the order of walking subfcns changes, |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
541 // for a minor speed improvement in non-critical code. |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
542 if (dbg_subfcn->ending_line () < earliest_end |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
543 && dbg_subfcn->ending_line () >= lineno |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
544 && dbg_subfcn->beginning_line () <= lineno) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
545 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
546 earliest_end = dbg_subfcn->ending_line (); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
547 retval = find_fcn_by_line (dbg_subfcn, lineno, &earliest_end); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
548 } |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
549 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
550 // Find the first fcn starting after lineno. |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
551 // This is used if line is not inside any function. |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
552 if (dbg_subfcn->beginning_line () >= lineno && ! next_fcn) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
553 next_fcn = dbg_subfcn; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
554 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
555 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
556 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
557 // The breakpoint is either in the subfunction found above, |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
558 // or in the main function, which we check now. |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
559 if (main_fcn->is_user_function ()) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
560 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
561 int e = dynamic_cast<octave_user_function *> (main_fcn)->ending_line (); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
562 if (e >= lineno && e < earliest_end) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
563 retval = main_fcn; |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
564 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
565 if (! retval) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
566 retval = next_fcn; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
567 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
568 else // main_fcn is a script. |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
569 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
570 if (! retval) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
571 retval = main_fcn; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
572 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
573 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
574 if (end_line && earliest_end < *end_line) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
575 *end_line = earliest_end; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
576 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
577 return retval; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
578 } |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
579 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
580 // Given file name fname, find the subfunction at line and create |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
581 // a breakpoint there. Put the system into debug_mode. |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
582 bp_table::intmap bp_table::add_breakpoint (const std::string& fname, |
26975
de826e69a5ea
make breakpoints in classdef methods work (bug #45404, bug #46451)
John W. Eaton <jwe@octave.org>
parents:
26954
diff
changeset
|
583 const std::string& class_name, |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
584 const bp_table::intmap& line, |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
585 const std::string& condition) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
586 { |
26975
de826e69a5ea
make breakpoints in classdef methods work (bug #45404, bug #46451)
John W. Eaton <jwe@octave.org>
parents:
26954
diff
changeset
|
587 octave_user_code *main_fcn = m_evaluator.get_user_code (fname, class_name); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
588 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
589 if (! main_fcn) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
590 error ("add_breakpoint: unable to find function '%s'\n", fname.c_str ()); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
591 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
592 condition_valid (condition); // Throw error if condition not valid. |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
593 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
594 intmap retval; |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
595 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
596 octave_idx_type len = line.size (); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
597 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
598 for (int i = 0; i < len; i++) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
599 { |
25342
416856765a55
be more careful with using auto in place of explicit const iterator decls
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
600 const_intmap_iterator m = line.find (i); |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
601 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
602 if (m != line.end ()) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
603 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
604 int lineno = m->second; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
605 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
606 octave_user_code *dbg_fcn = find_fcn_by_line (main_fcn, lineno); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
607 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
608 // We've found the right (sub)function. Now insert the breakpoint. |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
609 // We insert all breakpoints. |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
610 // If multiple are in the same function, we insert multiple times. |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
611 intmap ret_one; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
612 if (dbg_fcn |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
613 && add_breakpoint_1 (dbg_fcn, fname, line, condition, ret_one)) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
614 retval.insert (std::pair<int,int> (i, ret_one.find (i)->second)); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
615 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
616 } |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
617 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25360
diff
changeset
|
618 m_evaluator.debug_mode (bp_table::have_breakpoints () || Vdebugging); |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
619 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
620 return retval; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
621 } |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
622 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
623 int bp_table::remove_breakpoint_1 (octave_user_code *fcn, |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
624 const std::string& fname, |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
625 const bp_table::intmap& line) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
626 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
627 int retval = 0; |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
628 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
629 std::string file = fcn->fcn_file_name (); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
630 |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
631 tree_statement_list *cmds = fcn->body (); |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
632 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
633 // FIXME: move the operation on cmds to the tree_statement_list class? |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
634 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
635 if (cmds) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
636 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
637 octave_value_list results = cmds->list_breakpoints (); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
638 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
639 if (results.length () > 0) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
640 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
641 octave_idx_type len = line.size (); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
642 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
643 for (int i = 0; i < len; i++) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
644 { |
25342
416856765a55
be more careful with using auto in place of explicit const iterator decls
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
645 const_intmap_iterator p = line.find (i); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
646 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
647 if (p != line.end ()) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
648 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
649 int lineno = p->second; |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
650 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
651 cmds->delete_breakpoint (lineno); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
652 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
653 if (! file.empty ()) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
654 octave_link::update_breakpoint (false, file, lineno); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
655 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
656 } |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
657 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
658 results = cmds->list_breakpoints (); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
659 |
25337
3ff9192b676e
use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents:
25336
diff
changeset
|
660 auto it = m_bp_set.find (fname); |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
661 if (results.empty () && it != m_bp_set.end ()) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
662 m_bp_set.erase (it); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
663 } |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
664 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
665 retval = results.length (); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
666 } |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
667 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
668 return retval; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
669 } |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
670 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
671 int bp_table::remove_breakpoint (const std::string& fname, |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
672 const bp_table::intmap& line) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
673 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
674 int retval = 0; |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
675 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
676 octave_idx_type len = line.size (); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
677 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
678 if (len == 0) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
679 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
680 intmap results = remove_all_breakpoints_in_file (fname); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
681 retval = results.size (); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
682 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
683 else |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
684 { |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25347
diff
changeset
|
685 octave_user_code *dbg_fcn = m_evaluator.get_user_code (fname); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
686 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
687 if (! dbg_fcn) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
688 error ("remove_breakpoint: unable to find function %s\n", |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
689 fname.c_str ()); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
690 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
691 retval = remove_breakpoint_1 (dbg_fcn, fname, line); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
692 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
693 // Search subfunctions in the order they appear in the file. |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
694 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
695 const std::list<std::string> subfcn_names |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
696 = dbg_fcn->subfunction_names (); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
697 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
698 std::map<std::string, octave_value> subfcns |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
699 = dbg_fcn->subfunctions (); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
700 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
701 for (const auto& subf_nm : subfcn_names) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
702 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
703 const auto q = subfcns.find (subf_nm); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
704 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
705 if (q != subfcns.end ()) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
706 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
707 octave_user_code *dbg_subfcn = q->second.user_code_value (); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
708 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
709 retval += remove_breakpoint_1 (dbg_subfcn, fname, line); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
710 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
711 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
712 } |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
713 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25360
diff
changeset
|
714 m_evaluator.debug_mode (bp_table::have_breakpoints () || Vdebugging); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
715 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
716 return retval; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
717 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
718 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
719 // Remove all breakpoints from a file, including those in subfunctions. |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
720 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
721 bp_table::intmap |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
722 bp_table::remove_all_breakpoints_in_file (const std::string& fname, |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
723 bool silent) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
724 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
725 intmap retval; |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
726 |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25347
diff
changeset
|
727 octave_user_code *dbg_fcn = m_evaluator.get_user_code (fname); |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
728 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
729 if (dbg_fcn) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
730 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
731 std::string file = dbg_fcn->fcn_file_name (); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
732 |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
733 tree_statement_list *cmds = dbg_fcn->body (); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
734 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
735 if (cmds) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
736 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
737 retval = cmds->remove_all_breakpoints (file); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
738 |
25337
3ff9192b676e
use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents:
25336
diff
changeset
|
739 auto it = m_bp_set.find (fname); |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
740 if (it != m_bp_set.end ()) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
741 m_bp_set.erase (it); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
742 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
743 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
744 else if (! silent) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
745 error ("remove_all_breakpoint_in_file: " |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
746 "unable to find function %s\n", fname.c_str ()); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
747 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25360
diff
changeset
|
748 m_evaluator.debug_mode (bp_table::have_breakpoints () || Vdebugging); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
749 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
750 return retval; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
751 } |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
752 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
753 void bp_table::remove_all_breakpoints (void) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
754 { |
25342
416856765a55
be more careful with using auto in place of explicit const iterator decls
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
755 // Odd loop structure required because delete will invalidate |
416856765a55
be more careful with using auto in place of explicit const iterator decls
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
756 // m_bp_set iterators. |
25343
4d7790d9793f
use cbegin, crbegin, cend, and crend and auto decls where possible
John W. Eaton <jwe@octave.org>
parents:
25342
diff
changeset
|
757 for (auto it = m_bp_set.cbegin (), it_next = it; |
4d7790d9793f
use cbegin, crbegin, cend, and crend and auto decls where possible
John W. Eaton <jwe@octave.org>
parents:
25342
diff
changeset
|
758 it != m_bp_set.cend (); |
25342
416856765a55
be more careful with using auto in place of explicit const iterator decls
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
759 it = it_next) |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
760 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
761 ++it_next; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
762 remove_all_breakpoints_in_file (*it); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
763 } |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
764 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25360
diff
changeset
|
765 m_evaluator.debug_mode (bp_table::have_breakpoints () || Vdebugging); |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
766 } |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
767 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
768 std::string find_bkpt_list (octave_value_list slist, std::string match) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
769 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
770 std::string retval; |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
771 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
772 for (int i = 0; i < slist.length (); i++) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
773 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
774 if (slist(i).string_value () == match) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
775 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
776 retval = slist(i).string_value (); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
777 break; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
778 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
779 } |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
780 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
781 return retval; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
782 } |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
783 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
784 bp_table::fname_bp_map |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
785 bp_table::get_breakpoint_list (const octave_value_list& fname_list) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
786 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
787 fname_bp_map retval; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
788 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
789 // make copy since changes may invalidate iters of m_bp_set. |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
790 std::set<std::string> tmp_bp_set = m_bp_set; |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
791 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
792 for (auto& bp_fname : tmp_bp_set) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
793 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
794 if (fname_list.empty () |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
795 || find_bkpt_list (fname_list, bp_fname) != "") |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
796 { |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25347
diff
changeset
|
797 octave_user_code *dbg_fcn = m_evaluator.get_user_code (bp_fname); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
798 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
799 if (dbg_fcn) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
800 { |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
801 tree_statement_list *cmds = dbg_fcn->body (); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
802 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
803 // FIXME: move the operation on cmds to the |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
804 // tree_statement_list class? |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
805 if (cmds) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
806 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
807 std::list<bp_type> bkpts = cmds->breakpoints_and_conds (); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
808 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
809 if (! bkpts.empty ()) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
810 retval[bp_fname] = bkpts; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
811 } |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
812 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
813 // look for breakpoints in subfunctions |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
814 const std::list<std::string> subf_nm |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
815 = dbg_fcn->subfunction_names (); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
816 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
817 std::map<std::string, octave_value> subfcns |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
818 = dbg_fcn->subfunctions (); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
819 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
820 for (const auto& subfcn_nm : subf_nm) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
821 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
822 const auto q = subfcns.find (subfcn_nm); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
823 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
824 if (q != subfcns.end ()) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
825 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
826 octave_user_code *dbg_subfcn |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
827 = q->second.user_code_value (); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
828 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
829 cmds = dbg_subfcn->body (); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
830 if (cmds) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
831 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
832 std::list<bp_type> bkpts |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
833 = cmds->breakpoints_and_conds (); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
834 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
835 if (! bkpts.empty ()) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
836 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
837 std::string key |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
838 = bp_fname + '>' + dbg_subfcn->name (); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
839 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
840 retval[key] = bkpts; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
841 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
842 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
843 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
844 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
845 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
846 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
847 } |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
848 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
849 return retval; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
850 } |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
851 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
852 // Report the status of "dbstop if error ..." and "dbstop if warning ..." |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
853 // If to_screen is true, the output goes to octave_stdout; otherwise it is |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
854 // returned. |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
855 // If dbstop if error is true but no explicit IDs are specified, the return |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
856 // value will have an empty field called "errs". If IDs are specified, the |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
857 // "errs" field will have a row per ID. If dbstop if error is false, there |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
858 // is no "errs" field. The "warn" field is set similarly by dbstop if warning |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
859 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
860 octave_map bp_table::stop_on_err_warn_status (bool to_screen) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
861 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
862 octave_map retval; |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
863 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
864 // print dbstop if error information |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
865 if (Vdebug_on_error) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
866 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
867 if (m_errors_that_stop.empty ()) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
868 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
869 if (to_screen) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
870 octave_stdout << "stop if error\n"; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
871 else |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
872 retval.assign ("errs", octave_value("")); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
873 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
874 else |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
875 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
876 Cell errs (dim_vector (bp_table::m_errors_that_stop.size (), 1)); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
877 int i = 0; |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
878 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
879 for (const auto& e : m_errors_that_stop) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
880 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
881 if (to_screen) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
882 octave_stdout << "stop if error " << e << "\n"; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
883 else |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
884 errs(i++) = e; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
885 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
886 if (! to_screen) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
887 retval.assign ("errs", octave_value (errs)); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
888 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
889 } |
24286
6bfb96ab73cb
* bp-table.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
24279
diff
changeset
|
890 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
891 // print dbstop if caught error information |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
892 if (Vdebug_on_caught) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
893 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
894 if (m_caught_that_stop.empty ()) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
895 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
896 if (to_screen) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
897 octave_stdout << "stop if caught error\n"; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
898 else |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
899 retval.assign ("caught", octave_value("")); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
900 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
901 else |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
902 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
903 Cell errs (dim_vector (m_caught_that_stop.size (), 1)); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
904 int i = 0; |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
905 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
906 for (const auto& e : m_caught_that_stop) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
907 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
908 if (to_screen) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
909 octave_stdout << "stop if caught error " << e << "\n"; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
910 else |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
911 errs(i++) = e; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
912 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
913 if (! to_screen) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
914 retval.assign ("caught", octave_value (errs)); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
915 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
916 } |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
917 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
918 // print dbstop if warning information |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
919 if (Vdebug_on_warning) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
920 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
921 if (m_warnings_that_stop.empty ()) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
922 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
923 if (to_screen) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
924 octave_stdout << "stop if warning\n"; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
925 else |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
926 retval.assign ("warn", octave_value("")); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
927 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
928 else |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
929 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
930 Cell warn (dim_vector (m_warnings_that_stop.size (), 1)); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
931 int i = 0; |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
932 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
933 for (const auto& w : m_warnings_that_stop) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
934 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
935 if (to_screen) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
936 octave_stdout << "stop if warning " << w << "\n"; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
937 else |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
938 warn(i++) = w; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
939 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
940 if (! to_screen) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
941 retval.assign ("warn", octave_value (warn)); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
942 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
943 } |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
944 |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
945 // print dbstop if interrupt information |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
946 if (Vdebug_on_interrupt) |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
947 { |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
948 if (to_screen) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
949 octave_stdout << "stop if interrupt\n"; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
950 else |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
951 retval.assign ("intr", octave_value ()); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
952 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
953 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
954 return retval; |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
955 } |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
956 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
957 octave_user_code * |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
958 get_user_code (const std::string& fname) |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
959 { |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25347
diff
changeset
|
960 tree_evaluator& tw = __get_evaluator__ ("get_user_code"); |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
961 |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25347
diff
changeset
|
962 return tw.get_user_code (fname); |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
963 } |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
964 } |