diff --git a/libgui/src/interpreter-qobject.cc b/libgui/src/interpreter-qobject.cc --- a/libgui/src/interpreter-qobject.cc +++ b/libgui/src/interpreter-qobject.cc @@ -142,14 +142,6 @@ namespace octave evmgr.post_event (meth); } - void interpreter_qobject::interrupt (void) - { - if (! m_interpreter) - return; - - m_interpreter->interrupt (); - } - qt_interpreter_events * interpreter_qobject::qt_link (void) { return m_octave_qobj.qt_link (); diff --git a/libgui/src/interpreter-qobject.h b/libgui/src/interpreter-qobject.h --- a/libgui/src/interpreter-qobject.h +++ b/libgui/src/interpreter-qobject.h @@ -52,8 +52,6 @@ namespace octave void interpreter_event (const meth_callback& meth); - void interrupt (void); - signals: void ready (void); diff --git a/libgui/src/octave-qobject.cc b/libgui/src/octave-qobject.cc --- a/libgui/src/octave-qobject.cc +++ b/libgui/src/octave-qobject.cc @@ -363,14 +363,6 @@ namespace octave m_interpreter_qobj->interpreter_event (meth); } - void base_qobject::interpreter_interrupt (void) - { - // The following is a direct function call across threads. It works - // because the it is accessing a thread-safe function. - - m_interpreter_qobj->interrupt (); - } - void base_qobject::copy_image_to_clipboard (const QString& file, bool remove_file) { diff --git a/libgui/src/octave-qobject.h b/libgui/src/octave-qobject.h --- a/libgui/src/octave-qobject.h +++ b/libgui/src/octave-qobject.h @@ -152,8 +152,6 @@ namespace octave void interpreter_event (const meth_callback& meth); - void interpreter_interrupt (void); - void copy_image_to_clipboard (const QString& file, bool remove_file); protected: diff --git a/libgui/src/terminal-dock-widget.cc b/libgui/src/terminal-dock-widget.cc --- a/libgui/src/terminal-dock-widget.cc +++ b/libgui/src/terminal-dock-widget.cc @@ -56,7 +56,7 @@ namespace octave setFocusProxy (m_terminal); connect (m_terminal, SIGNAL (interrupt_signal (void)), - &oct_qobj, SLOT (interpreter_interrupt (void))); + this, SLOT (terminal_interrupt (void))); // Connect the visibility signal to the terminal for dis-/enabling timers connect (this, SIGNAL (visibilityChanged (bool)), @@ -99,4 +99,20 @@ namespace octave return w->hasFocus (); } + + void terminal_dock_widget::terminal_interrupt (void) + { + // FIXME: Protect with mutex? + + octave_signal_caught = 1; + octave_interrupt_state++; + + // Send SIGINT to all other processes in our process group. + // This is needed to interrupt calls to system (), for example. + + int sigint; + octave_get_sig_number ("SIGINT", &sigint); + + octave_kill_wrapper (0, sigint); + } } diff --git a/libgui/src/terminal-dock-widget.h b/libgui/src/terminal-dock-widget.h --- a/libgui/src/terminal-dock-widget.h +++ b/libgui/src/terminal-dock-widget.h @@ -48,6 +48,14 @@ namespace octave bool has_focus (void) const; + signals: + + void interrupt_signal (void); + + protected slots: + + void terminal_interrupt (void); + private: QTerminal *m_terminal; diff --git a/libinterp/corefcn/interpreter.cc b/libinterp/corefcn/interpreter.cc --- a/libinterp/corefcn/interpreter.cc +++ b/libinterp/corefcn/interpreter.cc @@ -42,7 +42,6 @@ #include "lo-blas-proto.h" #include "lo-error.h" #include "oct-env.h" -#include "quit.h" #include "str-vec.h" #include "signal-wrappers.h" #include "unistd-wrappers.h" @@ -477,7 +476,6 @@ namespace octave m_inhibit_startup_message (false), m_load_path_initialized (false), m_history_initialized (false), - m_interrupt_all_in_process_group (true), m_cancel_quit (false), m_executing_finish_script (false), m_executing_atexit (false), @@ -1705,69 +1703,6 @@ namespace octave return m_evaluator.autoloaded_functions (); } - // May be used to send an interrupt signal to the the interpreter from - // another thread (for example, the GUI). - - void interpreter::interrupt (void) - { - static int sigint = 0; - static bool first = true; - - if (first) - { - octave_get_sig_number ("SIGINT", &sigint); - first = false; - } - - // Send SIGINT to Octave and (optionally) all other processes in its - // process group. The signal handler for SIGINT will set a global - // variable indicating an interrupt has happened. That variable is - // checked in many places in the Octave interpreter and eventually - // results in an interrupt_exception being thrown. Finally, that - // exception is caught and returns control to one of the - // read-eval-print loops or to the server loop. We use a signal - // instead of just setting the global variables here so that we will - // probably send interrupt signals to any subprocesses as well as - // interrupt execution of the interpreter. - - pid_t pid - = m_interrupt_all_in_process_group ? 0 : octave_getpid_wrapper (); - - octave_kill_wrapper (pid, sigint); - } - - void interpreter::pause (void) - { - // FIXME: To be reliable, these tree_evaluator functions must be - // made thread safe. - - m_evaluator.break_on_next_statement (true); - m_evaluator.reset_debug_state (); - } - - void interpreter::stop (void) - { - // FIXME: To be reliable, these tree_evaluator functions must be - // made thread safe. - - if (m_evaluator.in_debug_repl ()) - m_evaluator.dbquit (true); - else - interrupt (); - } - - void interpreter::resume (void) - { - // FIXME: To be reliable, these tree_evaluator functions must be - // made thread safe. - - // FIXME: Should there be any feeback about not doing anything if - // not in debug mode? - - if (m_evaluator.in_debug_repl ()) - m_evaluator.dbcont (); - } - void interpreter::handle_exception (const execution_exception& ee) { m_error_system.save_exception (ee); diff --git a/libinterp/corefcn/interpreter.h b/libinterp/corefcn/interpreter.h --- a/libinterp/corefcn/interpreter.h +++ b/libinterp/corefcn/interpreter.h @@ -213,16 +213,6 @@ namespace octave return m_initialized; } - void interrupt_all_in_process_group (bool b) - { - m_interrupt_all_in_process_group = b; - } - - bool interrupt_all_in_process_group (void) const - { - return m_interrupt_all_in_process_group; - } - application *get_app_context (void) { return m_app_context; @@ -477,19 +467,6 @@ namespace octave std::list autoloaded_functions (void) const; - void interrupt (void); - - // Pause interpreter execution at the next available statement and - // enter the debugger. - void pause (void); - - // Exit debugger or stop execution and return to the top-level REPL - // or server loop. - void stop (void); - - // Resume interpreter execution if paused. - void resume (void); - void handle_exception (const execution_exception& ee); void recover_from_exception (void); @@ -610,8 +587,6 @@ namespace octave bool m_history_initialized; - bool m_interrupt_all_in_process_group; - bool m_cancel_quit; bool m_executing_finish_script; diff --git a/libinterp/parse-tree/pt-eval.cc b/libinterp/parse-tree/pt-eval.cc --- a/libinterp/parse-tree/pt-eval.cc +++ b/libinterp/parse-tree/pt-eval.cc @@ -117,7 +117,10 @@ namespace octave bool in_debug_repl (void) const { return m_in_debug_repl; } - void dbcont (void) { m_execution_mode = EX_CONTINUE; } + void dbcont (void) + { + m_execution_mode = EX_CONTINUE; + } void dbquit (bool all = false) { @@ -1203,9 +1206,7 @@ namespace octave void tree_evaluator::reset_debug_state (void) { - m_debug_mode = (m_bp_table.have_breakpoints () - || m_dbstep_flag != 0 - || m_break_on_next_stmt + m_debug_mode = (m_bp_table.have_breakpoints () || m_dbstep_flag != 0 || in_debug_repl ()); } @@ -4189,11 +4190,6 @@ namespace octave m_dbstep_flag = -1; } - if (! break_on_this_statement) - break_on_this_statement = m_break_on_next_stmt; - - m_break_on_next_stmt = false; - if (break_on_this_statement) { m_dbstep_flag = 0; diff --git a/libinterp/parse-tree/pt-eval.h b/libinterp/parse-tree/pt-eval.h --- a/libinterp/parse-tree/pt-eval.h +++ b/libinterp/parse-tree/pt-eval.h @@ -134,8 +134,8 @@ namespace octave m_debug_mode (false), m_quiet_breakpoint_flag (false), m_debugger_stack (), m_exit_status (0), m_max_recursion_depth (256), m_whos_line_format (" %a:4; %ln:6; %cs:16:6:1; %rb:12; %lc:-1;\n"), - m_silent_functions (false), m_string_fill_char (' '), m_PS4 ("+ "), - m_dbstep_flag (0), m_break_on_next_stmt (false), m_echo (ECHO_OFF), + m_silent_functions (false), m_string_fill_char (' '), + m_PS4 ("+ "), m_dbstep_flag (0), m_echo (ECHO_OFF), m_echo_state (false), m_echo_file_name (), m_echo_file_pos (1), m_echo_files (), m_in_top_level_repl (false), m_server_mode (false), m_in_loop_command (false), @@ -642,9 +642,6 @@ namespace octave void dbcont (void); - // Return true if we are in the debug repl and m_execution_mode is - // set to exit the debugger. Otherwise, do nothing. - void dbquit (bool all = false); octave_value PS4 (const octave_value_list& args, int nargout); @@ -751,23 +748,6 @@ namespace octave void set_dbstep_flag (int step) { m_dbstep_flag = step; } - bool break_on_next_statement (void) const - { - return m_break_on_next_stmt; - } - - bool break_on_next_statement (bool val) - { - bool old_val = m_break_on_next_stmt; - m_break_on_next_stmt = val; - return old_val; - } - - void set_break_on_next_statement (bool val) - { - m_break_on_next_stmt = val; - } - octave_value echo (const octave_value_list& args, int nargout); int echo (void) const { return m_echo; } @@ -889,10 +869,6 @@ namespace octave // If < 0, stop executing at the next possible stopping point. int m_dbstep_flag; - // If TRUE, and we are not stopping for another reason (dbstep or a - // breakpoint) then stop at next statement and enter the debugger. - bool m_break_on_next_stmt; - // Echo commands as they are executed? // // 1 ==> echo commands read from script files