3771
|
1 /* |
|
2 |
|
3 Copyright (C) 2001 Ben Sapp |
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
3771
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (octave_tree_bp_h) |
|
25 #define octave_tree_bp_h 1 |
|
26 |
|
27 #include "input.h" |
3805
|
28 #include "ov-usr-fcn.h" |
3771
|
29 #include "pt-walk.h" |
3805
|
30 #include "pt-pr-code.h" |
|
31 #include "toplev.h" |
3771
|
32 |
|
33 class tree; |
|
34 |
|
35 class |
|
36 tree_breakpoint : public tree_walker |
|
37 { |
|
38 public: |
|
39 |
|
40 enum action { set = 1, clear = 2, list = 3 }; |
|
41 |
|
42 tree_breakpoint (int l, action a) |
3805
|
43 : line (l), act (a), found (false), bp_list () { } |
3771
|
44 |
|
45 ~tree_breakpoint (void) { } |
|
46 |
|
47 bool success (void) const { return found; } |
|
48 |
|
49 void visit_argument_list (tree_argument_list&); |
|
50 |
|
51 void visit_binary_expression (tree_binary_expression&); |
|
52 |
4207
|
53 void visit_break_command (tree_break_command&); |
3771
|
54 |
|
55 void visit_colon_expression (tree_colon_expression&); |
|
56 |
4207
|
57 void visit_continue_command (tree_continue_command&); |
3771
|
58 |
|
59 void visit_decl_command (tree_decl_command&); |
|
60 |
|
61 void visit_decl_elt (tree_decl_elt&); |
|
62 |
|
63 void visit_decl_init_list (tree_decl_init_list&); |
|
64 |
|
65 void visit_while_command (tree_while_command&); |
|
66 |
|
67 void visit_do_until_command (tree_do_until_command&); |
|
68 |
|
69 void visit_simple_for_command (tree_simple_for_command&); |
|
70 |
|
71 void visit_complex_for_command (tree_complex_for_command&); |
|
72 |
|
73 void visit_octave_user_function (octave_user_function&); |
|
74 |
|
75 void visit_octave_user_function_header (octave_user_function&); |
|
76 |
|
77 void visit_octave_user_function_trailer (octave_user_function&); |
|
78 |
|
79 void visit_identifier (tree_identifier&); |
|
80 |
|
81 void visit_if_clause (tree_if_clause&); |
|
82 |
|
83 void visit_if_command (tree_if_command&); |
|
84 |
|
85 void visit_if_command_list (tree_if_command_list&); |
|
86 |
|
87 void visit_index_expression (tree_index_expression&); |
|
88 |
|
89 void visit_matrix (tree_matrix&); |
|
90 |
|
91 void visit_cell (tree_cell&); |
|
92 |
|
93 void visit_multi_assignment (tree_multi_assignment&); |
|
94 |
|
95 void visit_no_op_command (tree_no_op_command&); |
|
96 |
5861
|
97 void visit_anon_fcn_handle (tree_anon_fcn_handle&); |
|
98 |
3771
|
99 void visit_constant (tree_constant&); |
|
100 |
4342
|
101 void visit_fcn_handle (tree_fcn_handle&); |
|
102 |
3771
|
103 void visit_parameter_list (tree_parameter_list&); |
|
104 |
|
105 void visit_postfix_expression (tree_postfix_expression&); |
|
106 |
|
107 void visit_prefix_expression (tree_prefix_expression&); |
|
108 |
4207
|
109 void visit_return_command (tree_return_command&); |
3771
|
110 |
|
111 void visit_return_list (tree_return_list&); |
|
112 |
|
113 void visit_simple_assignment (tree_simple_assignment&); |
|
114 |
|
115 void visit_statement (tree_statement&); |
|
116 |
|
117 void visit_statement_list (tree_statement_list&); |
|
118 |
|
119 void visit_switch_case (tree_switch_case&); |
|
120 |
|
121 void visit_switch_case_list (tree_switch_case_list&); |
|
122 |
|
123 void visit_switch_command (tree_switch_command&); |
|
124 |
|
125 void visit_try_catch_command (tree_try_catch_command&); |
|
126 |
|
127 void visit_unwind_protect_command (tree_unwind_protect_command&); |
|
128 |
3805
|
129 octave_value_list get_list (void) { return bp_list; } |
3771
|
130 |
|
131 int get_line (void) { return line; } |
|
132 |
|
133 private: |
|
134 |
|
135 void take_action (tree &tr); |
|
136 |
3805
|
137 // Statement line number we are looking for. |
3771
|
138 int line; |
|
139 |
3805
|
140 // What to do. |
3771
|
141 action act; |
3805
|
142 |
|
143 // Have we already found the line? |
3771
|
144 bool found; |
|
145 |
3805
|
146 // List of breakpoint line numbers. |
|
147 octave_value_list bp_list; |
3771
|
148 |
|
149 // No copying! |
|
150 |
|
151 tree_breakpoint (const tree_breakpoint&); |
|
152 |
|
153 tree_breakpoint& operator = (const tree_breakpoint&); |
|
154 }; |
|
155 |
4185
|
156 // TRUE means SIGINT should put us in the debugger at the next |
|
157 // available breakpoint. |
|
158 extern bool octave_debug_on_interrupt_state; |
|
159 |
3771
|
160 #define MAYBE_DO_BREAKPOINT \ |
|
161 do \ |
|
162 { \ |
6802
|
163 octave_function *xfcn = octave_call_stack::current (); \ |
5743
|
164 \ |
4185
|
165 if (octave_debug_on_interrupt_state \ |
|
166 || (tree::break_next && tree::last_line == 0) \ |
3805
|
167 || (tree::break_next \ |
6802
|
168 && xfcn == tree::break_function \ |
3805
|
169 && tree::last_line != line ()) \ |
|
170 || is_breakpoint ()) \ |
3771
|
171 { \ |
4185
|
172 octave_debug_on_interrupt_state = false; \ |
|
173 \ |
3772
|
174 tree::break_next = false; \ |
3805
|
175 \ |
6802
|
176 if (xfcn) \ |
|
177 octave_stdout << xfcn->name () << ": "; \ |
3805
|
178 \ |
|
179 octave_stdout << "line " << line () << ", " \ |
|
180 << "column " << column () \ |
|
181 << std::endl; \ |
|
182 \ |
|
183 tree_print_code tpc (octave_stdout); \ |
|
184 this->accept (tpc); \ |
|
185 \ |
|
186 octave_stdout << std::endl; \ |
|
187 \ |
|
188 tree::break_statement = this; \ |
|
189 \ |
3771
|
190 do_keyboard (); \ |
|
191 } \ |
|
192 } \ |
|
193 while (0) |
|
194 |
|
195 #endif |
|
196 |
|
197 /* |
|
198 ;;; Local Variables: *** |
|
199 ;;; mode: C++ *** |
|
200 ;;; End: *** |
|
201 */ |