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 |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_tree_bp_h) |
|
24 #define octave_tree_bp_h 1 |
|
25 |
4192
|
26 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
3771
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 #include "input.h" |
3805
|
31 #include "ov-usr-fcn.h" |
3771
|
32 #include "pt-walk.h" |
3805
|
33 #include "pt-pr-code.h" |
|
34 #include "toplev.h" |
3771
|
35 |
|
36 class tree; |
|
37 |
|
38 class |
|
39 tree_breakpoint : public tree_walker |
|
40 { |
|
41 public: |
|
42 |
|
43 enum action { set = 1, clear = 2, list = 3 }; |
|
44 |
|
45 tree_breakpoint (int l, action a) |
3805
|
46 : line (l), act (a), found (false), bp_list () { } |
3771
|
47 |
|
48 ~tree_breakpoint (void) { } |
|
49 |
|
50 bool success (void) const { return found; } |
|
51 |
|
52 void visit_argument_list (tree_argument_list&); |
|
53 |
|
54 void visit_binary_expression (tree_binary_expression&); |
|
55 |
4173
|
56 void visit_break_expression (tree_break_expression&); |
3771
|
57 |
|
58 void visit_colon_expression (tree_colon_expression&); |
|
59 |
4173
|
60 void visit_continue_expression (tree_continue_expression&); |
3771
|
61 |
|
62 void visit_decl_command (tree_decl_command&); |
|
63 |
|
64 void visit_decl_elt (tree_decl_elt&); |
|
65 |
|
66 void visit_decl_init_list (tree_decl_init_list&); |
|
67 |
|
68 void visit_while_command (tree_while_command&); |
|
69 |
|
70 void visit_do_until_command (tree_do_until_command&); |
|
71 |
|
72 void visit_simple_for_command (tree_simple_for_command&); |
|
73 |
|
74 void visit_complex_for_command (tree_complex_for_command&); |
|
75 |
|
76 void visit_octave_user_function (octave_user_function&); |
|
77 |
|
78 void visit_octave_user_function_header (octave_user_function&); |
|
79 |
|
80 void visit_octave_user_function_trailer (octave_user_function&); |
|
81 |
|
82 void visit_identifier (tree_identifier&); |
|
83 |
|
84 void visit_if_clause (tree_if_clause&); |
|
85 |
|
86 void visit_if_command (tree_if_command&); |
|
87 |
|
88 void visit_if_command_list (tree_if_command_list&); |
|
89 |
|
90 void visit_index_expression (tree_index_expression&); |
|
91 |
|
92 void visit_matrix (tree_matrix&); |
|
93 |
|
94 void visit_cell (tree_cell&); |
|
95 |
|
96 void visit_multi_assignment (tree_multi_assignment&); |
|
97 |
|
98 void visit_no_op_command (tree_no_op_command&); |
|
99 |
|
100 void visit_constant (tree_constant&); |
|
101 |
|
102 void visit_parameter_list (tree_parameter_list&); |
|
103 |
|
104 void visit_plot_command (tree_plot_command&); |
|
105 |
|
106 void visit_plot_limits (plot_limits&); |
|
107 |
|
108 void visit_plot_range (plot_range&); |
|
109 |
|
110 void visit_postfix_expression (tree_postfix_expression&); |
|
111 |
|
112 void visit_prefix_expression (tree_prefix_expression&); |
|
113 |
4173
|
114 void visit_return_expression (tree_return_expression&); |
3771
|
115 |
|
116 void visit_return_list (tree_return_list&); |
|
117 |
|
118 void visit_simple_assignment (tree_simple_assignment&); |
|
119 |
|
120 void visit_statement (tree_statement&); |
|
121 |
|
122 void visit_statement_list (tree_statement_list&); |
|
123 |
|
124 void visit_subplot (subplot&); |
|
125 |
|
126 void visit_subplot_axes (subplot_axes&); |
|
127 |
|
128 void visit_subplot_list (subplot_list&); |
|
129 |
|
130 void visit_subplot_style (subplot_style&); |
|
131 |
|
132 void visit_subplot_using (subplot_using&); |
|
133 |
|
134 void visit_switch_case (tree_switch_case&); |
|
135 |
|
136 void visit_switch_case_list (tree_switch_case_list&); |
|
137 |
|
138 void visit_switch_command (tree_switch_command&); |
|
139 |
|
140 void visit_try_catch_command (tree_try_catch_command&); |
|
141 |
|
142 void visit_unwind_protect_command (tree_unwind_protect_command&); |
|
143 |
3805
|
144 octave_value_list get_list (void) { return bp_list; } |
3771
|
145 |
|
146 int get_line (void) { return line; } |
|
147 |
|
148 private: |
|
149 |
|
150 void take_action (tree &tr); |
|
151 |
3805
|
152 // Statement line number we are looking for. |
3771
|
153 int line; |
|
154 |
3805
|
155 // What to do. |
3771
|
156 action act; |
3805
|
157 |
|
158 // Have we already found the line? |
3771
|
159 bool found; |
|
160 |
3805
|
161 // List of breakpoint line numbers. |
|
162 octave_value_list bp_list; |
3771
|
163 |
|
164 // No copying! |
|
165 |
|
166 tree_breakpoint (const tree_breakpoint&); |
|
167 |
|
168 tree_breakpoint& operator = (const tree_breakpoint&); |
|
169 }; |
|
170 |
4185
|
171 // TRUE means SIGINT should put us in the debugger at the next |
|
172 // available breakpoint. |
|
173 extern bool octave_debug_on_interrupt_state; |
|
174 |
3771
|
175 #define MAYBE_DO_BREAKPOINT \ |
|
176 do \ |
|
177 { \ |
4185
|
178 if (octave_debug_on_interrupt_state \ |
|
179 || (tree::break_next && tree::last_line == 0) \ |
3805
|
180 || (tree::break_next \ |
|
181 && curr_function == tree::break_function \ |
|
182 && tree::last_line != line ()) \ |
|
183 || is_breakpoint ()) \ |
3771
|
184 { \ |
4185
|
185 octave_debug_on_interrupt_state = false; \ |
|
186 \ |
3772
|
187 tree::break_next = false; \ |
3805
|
188 \ |
|
189 if (curr_function) \ |
|
190 octave_stdout << curr_function->function_name () << ": "; \ |
|
191 \ |
|
192 octave_stdout << "line " << line () << ", " \ |
|
193 << "column " << column () \ |
|
194 << std::endl; \ |
|
195 \ |
|
196 tree_print_code tpc (octave_stdout); \ |
|
197 this->accept (tpc); \ |
|
198 \ |
|
199 octave_stdout << std::endl; \ |
|
200 \ |
|
201 tree::break_statement = this; \ |
|
202 \ |
3771
|
203 do_keyboard (); \ |
|
204 } \ |
|
205 } \ |
|
206 while (0) |
|
207 |
|
208 #endif |
|
209 |
|
210 /* |
|
211 ;;; Local Variables: *** |
|
212 ;;; mode: C++ *** |
|
213 ;;; End: *** |
|
214 */ |