# HG changeset patch # User Torsten # Date 1451818156 -3600 # Node ID 8000dacaea986441151f0f022ca4911d757a3192 # Parent 5a340d8458d695167b67708ec166da982ded041d GUI: no more extra command queue for debug commands * main-window.cc (constructor): remove initializations for debug queue; (debug_continue,debug_step_into,debug_step_over,debug_step_out,debug_quit): queue new debug commands into common queue; (queue_debug): removed obsolete function; (execute_debug_callback): move this function into the execute method of the new octave_cmd_debug class; * main-window.h: remove obsolete prototypes and class variables * octave-cmd.cc (octave_cmd_debug::execute): execute method of new class for debug commands; (octave-cmd.h): changed private into protected for inheritance, new class octave_cmd_debug derived from octave_cmd_exec diff -r 5a340d8458d6 -r 8000dacaea98 libgui/src/main-window.cc --- a/libgui/src/main-window.cc Sat Jan 02 10:28:59 2016 -0800 +++ b/libgui/src/main-window.cc Sun Jan 03 11:49:16 2016 +0100 @@ -92,9 +92,6 @@ _cmd_queue (QList ()), // no command pending _cmd_processing (1), _cmd_queue_mutex (), - _dbg_queue (new QStringList ()), // no debug pending - _dbg_processing (1), - _dbg_queue_mutex (), _prevent_readline_conflicts (true), _suppress_dbg_location (true), _start_gui (start_gui) @@ -958,31 +955,36 @@ void main_window::debug_continue (void) { - queue_debug ("cont"); + octave_cmd_debug *cmd = new octave_cmd_debug ("cont", _suppress_dbg_location); + queue_command (cmd); } void main_window::debug_step_into (void) { - queue_debug ("in"); + octave_cmd_debug *cmd = new octave_cmd_debug ("in", _suppress_dbg_location); + queue_command (cmd); } void main_window::debug_step_over (void) { - queue_debug ("step"); + octave_cmd_debug *cmd = new octave_cmd_debug ("step", _suppress_dbg_location); + queue_command (cmd); } void main_window::debug_step_out (void) { - queue_debug ("out"); + octave_cmd_debug *cmd = new octave_cmd_debug ("out", _suppress_dbg_location); + queue_command (cmd); } void main_window::debug_quit (void) { - queue_debug ("quit"); + octave_cmd_debug *cmd = new octave_cmd_debug ("quit", _suppress_dbg_location); + queue_command (cmd); } void @@ -2166,65 +2168,6 @@ _octave_qt_link->update_directory (); } -// The next callbacks are invoked by GUI buttons. Those buttons -// should only be active when we are doing debugging, which means that -// Octave is waiting for input in get_debug_input. Calling -// command_editor::interrupt will force readline to return even if it -// has not read any input, and then get_debug_input will return, -// allowing the evaluator to continue and execute the next statement. - -void -main_window::queue_debug (QString debug_cmd) -{ - _dbg_queue_mutex.lock (); - _dbg_queue->append (debug_cmd); // queue command - _dbg_queue_mutex.unlock (); - - if (_dbg_processing.tryAcquire ()) // if callback not processing, post event - octave_link::post_event (this, &main_window::execute_debug_callback); -} - -void -main_window::execute_debug_callback () -{ - bool repost = false; // flag for reposting event for this callback - - if (! _dbg_queue->isEmpty ()) // list can not be empty here, just to make sure - { - _dbg_queue_mutex.lock (); // critical path - QString debug = _dbg_queue->takeFirst (); - if (_dbg_queue->isEmpty ()) - _dbg_processing.release (); // cmd queue empty, processing will stop - else - repost = true; // not empty, repost at end - _dbg_queue_mutex.unlock (); - - if (debug == "step") - { - F__db_next_breakpoint_quiet__ (ovl (_suppress_dbg_location)); - Fdbstep (); - } - else if (debug == "cont") - { - F__db_next_breakpoint_quiet__ (ovl (_suppress_dbg_location)); - Fdbcont (); - } - else if (debug == "quit") - Fdbquit (); - else - { - F__db_next_breakpoint_quiet__ (ovl (_suppress_dbg_location)); - Fdbstep (ovl (debug.toStdString ())); - } - - command_editor::interrupt (true); - } - - if (repost) // queue not empty, so repost event for further processing - octave_link::post_event (this, &main_window::execute_debug_callback); - -} - void main_window::find_files (const QString &start_dir) { diff -r 5a340d8458d6 -r 8000dacaea98 libgui/src/main-window.h --- a/libgui/src/main-window.h Sat Jan 02 10:28:59 2016 -0800 +++ b/libgui/src/main-window.h Sun Jan 03 11:49:16 2016 +0100 @@ -288,10 +288,6 @@ void queue_command (octave_cmd *cmd); - void queue_debug (QString command); - - void execute_debug_callback (); - void configure_shortcuts (); workspace_model *_workspace_model; @@ -404,11 +400,6 @@ QSemaphore _cmd_processing; QMutex _cmd_queue_mutex; - // semaphore to synchronize debug signals and related callbacks - QStringList *_dbg_queue; - QSemaphore _dbg_processing; - QMutex _dbg_queue_mutex; - bool _prevent_readline_conflicts; bool _suppress_dbg_location; bool _start_gui; diff -r 5a340d8458d6 -r 8000dacaea98 libgui/src/octave-cmd.cc --- a/libgui/src/octave-cmd.cc Sat Jan 02 10:28:59 2016 -0800 +++ b/libgui/src/octave-cmd.cc Sun Jan 03 11:49:16 2016 +0100 @@ -80,3 +80,31 @@ command_editor::accept_line (); } + + +// --------------------------------------------------------------------- +// class octave_cmd_debug: executing a debugger command + +void +octave_cmd_debug::execute () +{ + if (_cmd == "step") + { + F__db_next_breakpoint_quiet__ (ovl (_suppress_dbg_location)); + Fdbstep (); + } + else if (_cmd == "cont") + { + F__db_next_breakpoint_quiet__ (ovl (_suppress_dbg_location)); + Fdbcont (); + } + else if (_cmd == "quit") + Fdbquit (); + else + { + F__db_next_breakpoint_quiet__ (ovl (_suppress_dbg_location)); + Fdbstep (ovl (_cmd.toStdString ())); + } + + command_editor::interrupt (true); +} diff -r 5a340d8458d6 -r 8000dacaea98 libgui/src/octave-cmd.h --- a/libgui/src/octave-cmd.h Sat Jan 02 10:28:59 2016 -0800 +++ b/libgui/src/octave-cmd.h Sun Jan 03 11:49:16 2016 +0100 @@ -49,7 +49,7 @@ octave_cmd_exec (const QString& cmd) : octave_cmd () { _cmd = cmd; }; void execute (); -private: +protected: QString _cmd; }; @@ -65,8 +65,29 @@ octave_cmd_eval (const QFileInfo& info) : octave_cmd () { _info = info; }; void execute (); -private: +protected: QFileInfo _info; }; + + +// --------------------------------------------------------------------- +// class octave_cmd_debug + +class octave_cmd_debug : public octave_cmd_exec +{ +public: + + octave_cmd_debug (const QString& cmd, bool suppress_location) + : octave_cmd_exec (cmd) + { + _suppress_dbg_location = suppress_location; + }; + + void execute (); + +protected: + + bool _suppress_dbg_location; +}; #endif