annotate libinterp/parse-tree/bp-table.cc @ 25347:af3319d86a5f

eliminate some global references to interpreter internals * bp-table.h, bp-table.cc (bp_table::m_interpreter): New data member. (get_user_code): Deprecate. * interpreter.h, interpreter.cc (interpreter::get_user_code): New function. Change all uses of global get_uesr_code to use interpreter::get_user_code instead.
author John W. Eaton <jwe@octave.org>
date Thu, 03 May 2018 16:04:53 -0400
parents 4d7790d9793f
children bc5f225bc578
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
25054
6652d3823428 maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 24738
diff changeset
3 Copyright (C) 2001-2018 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 <fstream>
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 #include <limits>
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 #include <list>
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 #include <map>
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 #include <set>
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 #include <string>
23170
b3f2645803fe Add headers needed on MacOS to avoid "implicit instantiation of undefined
Mike Miller <mtmiller@octave.org>
parents: 23158
diff changeset
35 #include <sstream>
b3f2645803fe Add headers needed on MacOS to avoid "implicit instantiation of undefined
Mike Miller <mtmiller@octave.org>
parents: 23158
diff changeset
36 #include <iostream>
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 #include "file-ops.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 #include "bp-table.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 #include "defun-int.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 #include "call-stack.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 #include "error.h"
25347
af3319d86a5f eliminate some global references to interpreter internals
John W. Eaton <jwe@octave.org>
parents: 25343
diff changeset
44 #include "interpreter.h"
23553
14723784b9f2 don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
45 #include "interpreter-private.h"
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 #include "oct-map.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47 #include "octave-link.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48 #include "ov-usr-fcn.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49 #include "ov.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 #include "ovl.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51 #include "pager.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 #include "parse.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 #include "pt-eval.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54 #include "pt-exp.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55 #include "pt-stmt.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56 #include "sighandlers.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57 #include "symtab.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
59 namespace octave
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60 {
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
61 // 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
62
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
63 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
64 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
65 Vdebug_on_error = false;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
66 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
67
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
68 Vdebug_on_caught = false;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
69 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
70
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
71 Vdebug_on_warning = false;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
72 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
73
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
74 Vdebug_on_interrupt = false;
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
75 }
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 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
78 // "dbstop (p)".
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
80 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
81 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
82 // process errs
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
83 // 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
84 bool fail = false;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
85 Cell U = mv.contents ("errs");
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
86 if (U.numel () != 1)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
87 fail = (U.numel () > 1);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
88 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
89 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
90 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
91 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
92 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
93 else if (! W(0).iscell ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
94 fail = true;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
95 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
96 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
97 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
98 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
99 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
100 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
101 Vdebug_on_error = 1;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
102 }
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 }
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
105
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
106 if (fail)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
107 error ("dbstop: invalid 'errs' field");
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
108
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
109 // process caught
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
110 // 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
111 fail = false;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
112 U = mv.contents ("caught");
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
113 if (U.numel () != 1)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
114 fail = (U.numel () > 1);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
115 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
116 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
117 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
118 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
119 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
120 else if (! W(0).iscell ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
121 fail = true;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
122 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
123 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
124 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
125 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
126 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
127 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
128 Vdebug_on_caught = 1;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
129 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
130 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
131 }
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
132
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
133 if (fail)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
134 error ("dbstop: invalid 'caught' field");
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
135
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
136 // process warn
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
137 // 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
138 fail = false;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
139 U = mv.contents ("warn");
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
140 if (U.numel () != 1)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
141 fail = (U.numel () > 1);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
142 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
143 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
144 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
145 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
146 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
147 else if (! W(0).iscell ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
148 fail = true;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
149 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
150 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
151 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
152 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
153 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
154 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
155 Vdebug_on_warning = 1;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
156 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
157 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
158 }
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
159
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
160 if (fail)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
161 error ("dbstop: invalid 'warn' field");
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
162
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
163 // process interrupt
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
164 if (mv.isfield ("intr"))
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
165 Vdebug_on_interrupt = 1;
24738
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
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
168 // 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
169 // 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
170 // 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
171
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
172 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
173 const std::string& fname,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
174 const bp_table::intmap& line,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
175 const std::string& condition,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
176 bp_table::intmap& retval)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
177 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
178 bool found = false;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
179
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
180 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
181
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
182 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
183
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
184 if (cmds)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
185 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
186 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
187
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
188 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
189 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
190 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
191 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
192 // 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
193 // 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
194 // 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
195 // dbclear all
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
196 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
197 if (s)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
198 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
199 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
200 m_bp_set.insert (fname);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
201 found = true;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
202 break;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
203 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
204 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
205 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
206
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
207 return found;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
208 }
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 // 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
211 // 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
212 // 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
213 // Throws an exception if not valid.
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
214
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
215 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
216 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
217 if (cond.length () > 0)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
218 {
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
219 parser parser (cond + " ;"); // ; to reject partial expr like "y=="
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
220 parser.reset ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
221 int parse_status = parser.run ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
222 if (parse_status)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
223 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
224 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
225 {
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
226 tree_statement *stmt = nullptr;
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
227 if (! parser.m_stmt_list)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
228 error ("dbstop: "
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
229 "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
230 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
231 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
232 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
233 && (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
234 && stmt->is_expression ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
235 {
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
236 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
237 if (expr->is_assignment_expression ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
238 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
239 "Did you mean '=='?");
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 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
242 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
243 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
244 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
245 }
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
246
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
247 return true;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
248 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
249
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
250 enum dbstop_args
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
251 {
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
252 dbstop_in,
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
253 dbstop_at,
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
254 dbstop_if,
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
255 dbstop_none
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
256 };
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
257
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".
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
260 // The syntax is: dbstop [[in] symbol] [[at] line [line [...]]] [if condition]
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
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
262 // been seen.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
263 // 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
264
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
265 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
266 const octave_value_list& args,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
267 std::string& symbol_name,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
268 bp_table::intmap& lines,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
269 std::string& cond)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
270 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
271 int nargin = args.length ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
272 int list_idx = 0;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
273 symbol_name = "";
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
274 lines = bp_table::intmap ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
275
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
276 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
277 print_usage (who);
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
278
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
279 // elements already processed
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
280 bool seen_in = false, seen_at = false, seen_if = false;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
281 int pos = 0;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
282 dbstop_args tok = dbstop_none;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
283 while (pos < nargin)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
284 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
285 // 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
286 if (args(pos).is_string ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
287 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
288 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
289 if (arg == "in")
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
290 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
291 tok = dbstop_in;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
292 pos++;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
293 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
294 else if (arg == "at")
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_at;
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 == "if")
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_if;
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 (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
305 tok = dbstop_at;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
306 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
307 tok = dbstop_in;
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
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
310 tok = dbstop_at;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
311
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
312 if (pos >= nargin)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
313 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
314 (tok == dbstop_in
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
315 ? "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
316
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
317 // process the actual arguments
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
318 switch (tok)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
319 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
320 case dbstop_in:
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
321 symbol_name = args(pos).string_value ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
322 if (seen_in)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
323 error ("%s: Too many function names specified -- %s",
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
324 who, symbol_name.c_str ());
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
325 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
326 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
327 who);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
328 seen_in = true;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
329 pos++;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
330 break;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
331
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
332 case dbstop_at:
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
333 if (seen_at)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
334 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
335 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
336 else if (seen_if)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
337 error ("%s: line number must come before 'if' clause\n");
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
338 seen_at = true;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
339
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
340 if (! seen_in)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
341 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
342 // 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
343 if (Vdebugging)
25347
af3319d86a5f eliminate some global references to interpreter internals
John W. Eaton <jwe@octave.org>
parents: 25343
diff changeset
344 symbol_name
af3319d86a5f eliminate some global references to interpreter internals
John W. Eaton <jwe@octave.org>
parents: 25343
diff changeset
345 = m_interpreter.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
346 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
347 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
348 "and 'if'", who);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
349 seen_in = true;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
350 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
351 else if (seen_if)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
352 error ("%s: line number must come before 'if' clause\n");
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
353
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
354 // 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
355 for ( ; pos < nargin; pos++)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
356 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
357 if (args(pos).is_string ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
358 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
359 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
360
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
361 if (line > 0)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
362 lines[list_idx++] = line;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
363 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
364 break; // may be "if"
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
365 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
366 else if (args(pos).isnumeric ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
367 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
368 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
369
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
370 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
371 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
372 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
373 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
374 error ("%s: Invalid argument type %s",
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
375 args(pos).type_name ().c_str ());
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
376 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
377 break;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
378
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
379 case dbstop_if:
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
380 if (seen_in) // conditional breakpoint
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
381 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
382 cond = ""; // remaining arguments form condition
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
383 for (; pos < nargin; pos++)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
384 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
385 if (args(pos).is_string ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
386 cond += ' ' + args(pos).string_value ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
387 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
388 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
389 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
390
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
391 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
392 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
393 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
394 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
395 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
396 int on_off = ! strcmp(who, "dbstop");
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
397
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
398 // 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
399 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
400 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
401
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
402 if (condition == "error")
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 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
405 stop_flag = &Vdebug_on_error;
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 else if (condition == "warning")
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
408 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
409 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
410 stop_flag = &Vdebug_on_warning;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
411 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
412 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
413 && 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
414 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
415 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
416 stop_flag = &Vdebug_on_caught;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
417 pos++;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
418 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
419 else if (condition == "interrupt")
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
420 {
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
421 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
422 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
423 else if (condition == "naninf")
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
424 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
425 #if defined (DBSTOP_NANINF)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
426 Vdebug_on_naninf = on_off;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
427 enable_fpe (on_off);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
428 #else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
429 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
430 who, condition.c_str ());
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
431 #endif
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
432 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
433 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
434 error ("%s: invalid condition %s",
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
435 who, condition.c_str ());
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
436
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
437 // 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
438 if (id_list)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
439 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
440 pos++;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
441 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
442 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
443 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
444 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
445 else if (on_off == 1)
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 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
448 *stop_flag = true;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
449 }
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 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
452 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
453 if (id_list->empty ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
454 *stop_flag = false;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
455 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
456 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
457 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
458 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
459 id_list->clear ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
460 *stop_flag = on_off;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
461 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
462 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
463 // Matlab stops on both.
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
464 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
465 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
466 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
467 }
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 pos = nargin;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
470 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
471 break;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
472
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
473 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
474 break;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
475 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
476 }
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 /*
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
480 %!test
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
481 %! 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
482 %! dbstop help;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
483 %! dbstop in ls;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
484 %! dbstop help at 100;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
485 %! dbstop in ls 100;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
486 %! 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
487 %! 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
488 %! s = dbstatus;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
489 %! dbclear all;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
490 %! 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
491 %! 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
492 %! 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
493 */
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
494
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
495 // 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
496 // 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
497 // 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
498
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
499 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
500 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
501 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
502 octave_user_code *retval = nullptr;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
503 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
504
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
505 // 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
506 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
507
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
508 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
509 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
510 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
511 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
512 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
513 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
514
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
515 // 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
516 // 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
517 // 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
518 // 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
519 // 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
520 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
521 && dbg_subfcn->ending_line () >= lineno
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
522 && dbg_subfcn->beginning_line () <= lineno)
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 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
525 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
526 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
527
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
528 // 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
529 // 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
530 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
531 next_fcn = dbg_subfcn;
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 }
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 // 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
536 // 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
537 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
538 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
539 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
540 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
541 retval = main_fcn;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
542
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
543 if (! retval)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
544 retval = next_fcn;
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 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
547 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
548 if (! retval)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
549 retval = main_fcn;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
550 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
551
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
552 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
553 *end_line = earliest_end;
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 return retval;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
556 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
557
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
558 // 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
559 // 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
560 bp_table::intmap bp_table::add_breakpoint (const std::string& fname,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
561 const bp_table::intmap& line,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
562 const std::string& condition)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
563 {
25347
af3319d86a5f eliminate some global references to interpreter internals
John W. Eaton <jwe@octave.org>
parents: 25343
diff changeset
564 octave_user_code *main_fcn = m_interpreter.get_user_code (fname);
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
565
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
566 if (! main_fcn)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
567 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
568
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
569 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
570
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
571 intmap retval;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
572
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
573 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
574
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
575 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
576 {
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
577 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
578
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
579 if (m != line.end ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
580 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
581 int lineno = m->second;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
582
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
583 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
584
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
585 // 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
586 // We insert all breakpoints.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
587 // 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
588 intmap ret_one;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
589 if (dbg_fcn
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
590 && 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
591 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
592 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
593 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
594
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
595 tree_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
596
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
597 return retval;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
598 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
599
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
600 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
601 const std::string& fname,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
602 const bp_table::intmap& line)
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 retval = 0;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
605
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
606 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
607
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
608 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
609
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
610 // 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
611
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
612 if (cmds)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
613 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
614 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
615
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
616 if (results.length () > 0)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
617 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
618 octave_idx_type len = line.size ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
619
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
620 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
621 {
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
622 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
623
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
624 if (p != line.end ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
625 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
626 int lineno = p->second;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
627
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
628 cmds->delete_breakpoint (lineno);
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
629
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
630 if (! file.empty ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
631 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
632 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
633 }
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 results = cmds->list_breakpoints ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
636
25337
3ff9192b676e use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents: 25336
diff changeset
637 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
638 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
639 m_bp_set.erase (it);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
640 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
641
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
642 retval = results.length ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
643 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
644
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
645 return retval;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
646 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
647
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
648 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
649 const bp_table::intmap& line)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
650 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
651 int retval = 0;
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 octave_idx_type len = line.size ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
654
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
655 if (len == 0)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
656 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
657 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
658 retval = results.size ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
659 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
660 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
661 {
25347
af3319d86a5f eliminate some global references to interpreter internals
John W. Eaton <jwe@octave.org>
parents: 25343
diff changeset
662 octave_user_code *dbg_fcn = m_interpreter.get_user_code (fname);
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
663
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
664 if (! dbg_fcn)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
665 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
666 fname.c_str ());
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 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
669
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
670 // 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
671
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
672 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
673 = dbg_fcn->subfunction_names ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
674
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
675 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
676 = dbg_fcn->subfunctions ();
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 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
679 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
680 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
681
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
682 if (q != subfcns.end ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
683 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
684 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
685
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
686 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
687 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
688 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
689 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
690
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
691 tree_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
692
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
693 return retval;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
694 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
695
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
696 // 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
697
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
698 bp_table::intmap
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
699 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
700 bool silent)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
701 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
702 intmap retval;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
703
25347
af3319d86a5f eliminate some global references to interpreter internals
John W. Eaton <jwe@octave.org>
parents: 25343
diff changeset
704 octave_user_code *dbg_fcn = m_interpreter.get_user_code (fname);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
705
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
706 if (dbg_fcn)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
707 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
708 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
709
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
710 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
711
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
712 if (cmds)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
713 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
714 retval = cmds->remove_all_breakpoints (file);
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
715
25337
3ff9192b676e use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents: 25336
diff changeset
716 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
717 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
718 m_bp_set.erase (it);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
719 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
720 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
721 else if (! silent)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
722 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
723 "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
724
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
725 tree_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
726
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
727 return retval;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
728 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
729
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
730 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
731 {
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
732 // 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
733 // 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
734 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
735 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
736 it = it_next)
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
737 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
738 ++it_next;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
739 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
740 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
741
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
742 tree_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
743 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
744
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
745 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
746 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
747 std::string retval;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
748
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
749 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
750 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
751 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
752 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
753 retval = slist(i).string_value ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
754 break;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
755 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
756 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
757
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
758 return retval;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
759 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
760
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
761 bp_table::fname_bp_map
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
762 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
763 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
764 fname_bp_map retval;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
765
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
766 // 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
767 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
768
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
769 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
770 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
771 if (fname_list.empty ()
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
772 || 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
773 {
25347
af3319d86a5f eliminate some global references to interpreter internals
John W. Eaton <jwe@octave.org>
parents: 25343
diff changeset
774 octave_user_code *dbg_fcn = m_interpreter.get_user_code (bp_fname);
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
775
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
776 if (dbg_fcn)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
777 {
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
778 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
779
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
780 // 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
781 // tree_statement_list class?
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
782 if (cmds)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
783 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
784 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
785
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
786 if (! bkpts.empty ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
787 retval[bp_fname] = bkpts;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
788 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
789
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
790 // look for breakpoints in subfunctions
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
791 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
792 = dbg_fcn->subfunction_names ();
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 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
795 = dbg_fcn->subfunctions ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
796
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
797 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
798 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
799 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
800
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
801 if (q != subfcns.end ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
802 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
803 octave_user_code *dbg_subfcn
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
804 = q->second.user_code_value ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
805
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
806 cmds = dbg_subfcn->body ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
807 if (cmds)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
808 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
809 std::list<bp_type> bkpts
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
810 = cmds->breakpoints_and_conds ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
811
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
812 if (! bkpts.empty ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
813 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
814 std::string key
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
815 = bp_fname + '>' + dbg_subfcn->name ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
816
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
817 retval[key] = bkpts;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
818 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
819 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
820 }
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 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
823 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
824 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
825
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
826 return retval;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
827 }
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 // 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
830 // 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
831 // returned.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
832 // 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
833 // 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
834 // "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
835 // 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
836
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
837 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
838 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
839 octave_map retval;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
840
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
841 // print dbstop if error information
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
842 if (Vdebug_on_error)
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 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
845 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
846 if (to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
847 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
848 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
849 retval.assign ("errs", octave_value(""));
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
850 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
851 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
852 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
853 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
854 int i = 0;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
855
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
856 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
857 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
858 if (to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
859 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
860 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
861 errs(i++) = e;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
862 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
863 if (! to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
864 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
865 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
866 }
24286
6bfb96ab73cb * bp-table.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 24279
diff changeset
867
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
868 // 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
869 if (Vdebug_on_caught)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
870 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
871 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
872 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
873 if (to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
874 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
875 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
876 retval.assign ("caught", octave_value(""));
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
877 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
878 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
879 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
880 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
881 int i = 0;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
882
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
883 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
884 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
885 if (to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
886 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
887 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
888 errs(i++) = e;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
889 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
890 if (! to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
891 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
892 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
893 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
894
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
895 // print dbstop if warning information
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
896 if (Vdebug_on_warning)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
897 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
898 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
899 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
900 if (to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
901 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
902 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
903 retval.assign ("warn", octave_value(""));
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
904 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
905 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
906 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
907 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
908 int i = 0;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
909
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
910 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
911 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
912 if (to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
913 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
914 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
915 warn(i++) = w;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
916 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
917 if (! to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
918 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
919 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
920 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
921
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
922 // print dbstop if interrupt information
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
923 if (Vdebug_on_interrupt)
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
924 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
925 if (to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
926 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
927 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
928 retval.assign ("intr", octave_value ());
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
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
931 return retval;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
932 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
933
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
934 octave_user_code *
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
935 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
936 {
25347
af3319d86a5f eliminate some global references to interpreter internals
John W. Eaton <jwe@octave.org>
parents: 25343
diff changeset
937 interpreter& interp = __get_interpreter__ ("get_user_code");
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
938
25347
af3319d86a5f eliminate some global references to interpreter internals
John W. Eaton <jwe@octave.org>
parents: 25343
diff changeset
939 return interp.get_user_code (fname);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
940 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
941 }