00001 /* 00002 00003 Copyright (C) 2001-2012 Ben Sapp 00004 00005 This file is part of Octave. 00006 00007 Octave is free software; you can redistribute it and/or modify it 00008 under the terms of the GNU General Public License as published by the 00009 Free Software Foundation; either version 3 of the License, or (at your 00010 option) any later version. 00011 00012 Octave is distributed in the hope that it will be useful, but WITHOUT 00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00014 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00015 for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with Octave; see the file COPYING. If not, see 00019 <http://www.gnu.org/licenses/>. 00020 00021 */ 00022 00023 #if !defined (octave_tree_bp_h) 00024 #define octave_tree_bp_h 1 00025 00026 #include "input.h" 00027 #include "ov-usr-fcn.h" 00028 #include "pt-walk.h" 00029 #include "pt-pr-code.h" 00030 #include "toplev.h" 00031 00032 class tree; 00033 class tree_decl_command; 00034 00035 class 00036 tree_breakpoint : public tree_walker 00037 { 00038 public: 00039 00040 enum action { set = 1, clear = 2, list = 3 }; 00041 00042 tree_breakpoint (int l, action a) 00043 : line (l), act (a), found (false), bp_list () { } 00044 00045 ~tree_breakpoint (void) { } 00046 00047 bool success (void) const { return found; } 00048 00049 void visit_argument_list (tree_argument_list&); 00050 00051 void visit_binary_expression (tree_binary_expression&); 00052 00053 void visit_break_command (tree_break_command&); 00054 00055 void visit_colon_expression (tree_colon_expression&); 00056 00057 void visit_continue_command (tree_continue_command&); 00058 00059 void visit_global_command (tree_global_command&); 00060 00061 void visit_static_command (tree_static_command&); 00062 00063 void visit_decl_elt (tree_decl_elt&); 00064 00065 void visit_decl_init_list (tree_decl_init_list&); 00066 00067 void visit_while_command (tree_while_command&); 00068 00069 void visit_do_until_command (tree_do_until_command&); 00070 00071 void visit_simple_for_command (tree_simple_for_command&); 00072 00073 void visit_complex_for_command (tree_complex_for_command&); 00074 00075 void visit_octave_user_script (octave_user_script&); 00076 00077 void visit_octave_user_function (octave_user_function&); 00078 00079 void visit_octave_user_function_header (octave_user_function&); 00080 00081 void visit_octave_user_function_trailer (octave_user_function&); 00082 00083 void visit_function_def (tree_function_def&); 00084 00085 void visit_identifier (tree_identifier&); 00086 00087 void visit_if_clause (tree_if_clause&); 00088 00089 void visit_if_command (tree_if_command&); 00090 00091 void visit_if_command_list (tree_if_command_list&); 00092 00093 void visit_index_expression (tree_index_expression&); 00094 00095 void visit_matrix (tree_matrix&); 00096 00097 void visit_cell (tree_cell&); 00098 00099 void visit_multi_assignment (tree_multi_assignment&); 00100 00101 void visit_no_op_command (tree_no_op_command&); 00102 00103 void visit_anon_fcn_handle (tree_anon_fcn_handle&); 00104 00105 void visit_constant (tree_constant&); 00106 00107 void visit_fcn_handle (tree_fcn_handle&); 00108 00109 void visit_parameter_list (tree_parameter_list&); 00110 00111 void visit_postfix_expression (tree_postfix_expression&); 00112 00113 void visit_prefix_expression (tree_prefix_expression&); 00114 00115 void visit_return_command (tree_return_command&); 00116 00117 void visit_return_list (tree_return_list&); 00118 00119 void visit_simple_assignment (tree_simple_assignment&); 00120 00121 void visit_statement (tree_statement&); 00122 00123 void visit_statement_list (tree_statement_list&); 00124 00125 void visit_switch_case (tree_switch_case&); 00126 00127 void visit_switch_case_list (tree_switch_case_list&); 00128 00129 void visit_switch_command (tree_switch_command&); 00130 00131 void visit_try_catch_command (tree_try_catch_command&); 00132 00133 void visit_unwind_protect_command (tree_unwind_protect_command&); 00134 00135 octave_value_list get_list (void) { return bp_list; } 00136 00137 int get_line (void) { return line; } 00138 00139 private: 00140 00141 void do_decl_command (tree_decl_command&); 00142 00143 void take_action (tree& tr); 00144 00145 void take_action (tree_statement& stmt); 00146 00147 // Statement line number we are looking for. 00148 int line; 00149 00150 // What to do. 00151 action act; 00152 00153 // Have we already found the line? 00154 bool found; 00155 00156 // List of breakpoint line numbers. 00157 octave_value_list bp_list; 00158 00159 // No copying! 00160 00161 tree_breakpoint (const tree_breakpoint&); 00162 00163 tree_breakpoint& operator = (const tree_breakpoint&); 00164 }; 00165 00166 // TRUE means SIGINT should put us in the debugger at the next 00167 // available breakpoint. 00168 extern bool octave_debug_on_interrupt_state; 00169 00170 #endif