changeset 19574:c1ce43276b86 gui-release

avoid printing debug location in cmd window when using GUI to step * pt-eval.cc, pt-eval.h (tree_evaluator::quiet_breakpoint_flag): New member variable. * debug.cc (Fdb_next_breakpoint_quiet): New function. * main-window.cc (main_window::execute_debug_callback): Call Fdb_next_breakpoint_quiet prior to Fdbstep and Fdbcont. * input.cc, input.h (get_debug_input): Don't print debug location if tree_evaluator::quiet_breakpoint_flag is true. Reset it after checking. * lex.ll (octave_lexer::fill_flex_buffer, octave_push_lexer::fill_flex_buffer): Don't abort if input_buf is empty.
author John W. Eaton <jwe@octave.org>
date Thu, 04 Dec 2014 16:06:31 -0500
parents f7ccd02bc060
children 5db5619fe54e 1572b5276b9a
files libgui/src/main-window.cc libinterp/corefcn/debug.cc libinterp/corefcn/input.cc libinterp/parse-tree/lex.ll libinterp/parse-tree/pt-eval.cc libinterp/parse-tree/pt-eval.h
diffstat 6 files changed, 78 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/main-window.cc
+++ b/libgui/src/main-window.cc
@@ -2198,13 +2198,22 @@
       _dbg_queue_mutex.unlock ();
 
       if (debug == "step")
-        Fdbstep ();
+        {
+          Fdb_next_breakpoint_quiet ();
+          Fdbstep ();
+        }
       else if (debug == "cont")
-        Fdbcont ();
+        {
+          Fdb_next_breakpoint_quiet ();
+          Fdbcont ();
+        }
       else if (debug == "quit")
         Fdbquit ();
       else
-        Fdbstep (ovl (debug.toStdString ()));
+        {
+          Fdb_next_breakpoint_quiet ();
+          Fdbstep (ovl (debug.toStdString ()));
+        }
 
       command_editor::interrupt (true);
     }
--- a/libinterp/corefcn/debug.cc
+++ b/libinterp/corefcn/debug.cc
@@ -1485,3 +1485,38 @@
 
   return retval;
 }
+
+DEFUN (db_next_breakpoint_quiet, args, ,
+       "-*- texinfo -*-\n\
+@deftypefn {Built-in Function} {} db_next_breakpoint_quiet ()\n\
+@deftypefnx {Built-in Function} {} db_next_breakpoint_quiet (@var{flag})\n\
+Disable line info printing at the next breakpoint.  With a logical\n\
+argument, set the state on or off.\n\
+@end deftypefn")
+{
+  octave_value retval;
+
+  int nargin = args.length ();
+
+  if (nargin == 0 || nargin == 1)
+    {
+      bool state = true;
+
+      if (nargin == 1)
+        {
+          state = args(0).bool_value ();
+
+          if (error_state)
+            {
+              gripe_wrong_type_arg ("db_next_breakpoint", args(0), true);
+              return retval;
+            }
+        }
+
+      tree_evaluator::quiet_breakpoint_flag = state;
+    }
+  else
+    print_usage ();
+
+  return retval;
+}
--- a/libinterp/corefcn/input.cc
+++ b/libinterp/corefcn/input.cc
@@ -184,10 +184,13 @@
   eof = false;
 
   std::string retval = command_editor::readline (s, eof);
-
+  
   if (! eof && retval.empty ())
     retval = "\n";
 
+  if (command_editor::interrupt (false))
+    retval = "";
+
   return retval;
 }
 
@@ -508,6 +511,9 @@
 {
   unwind_protect frame;
 
+  bool silent = tree_evaluator::quiet_breakpoint_flag;
+  tree_evaluator::quiet_breakpoint_flag = false;
+          
   octave_user_code *caller = octave_call_stack::caller_user_code ();
   std::string nm;
   int curr_debug_line;
@@ -544,10 +550,13 @@
           // that we are stopped on the no-op command that marks the
           // end of a function or script.
 
-          buf << "stopped in " << nm;
+          if (! silent)
+            {
+              buf << "stopped in " << nm;
 
-          if (curr_debug_line > 0)
-            buf << " at line " << curr_debug_line;
+              if (curr_debug_line > 0)
+                buf << " at line " << curr_debug_line;
+            }
 
           if (have_file)
             {
@@ -558,15 +567,21 @@
               frame.add_fcn (execute_in_debugger_handler,
                              std::pair<std::string, int> (nm, curr_debug_line));
 
-              std::string line_buf
-                = get_file_line (nm, curr_debug_line);
+              if (! silent)
+                {
+                  std::string line_buf
+                    = get_file_line (nm, curr_debug_line);
 
-              if (! line_buf.empty ())
-                buf << "\n" << curr_debug_line << ": " << line_buf;
+                  if (! line_buf.empty ())
+                    buf << "\n" << curr_debug_line << ": " << line_buf;
+                }
             }
         }
     }
 
+  if (silent)
+    command_editor::erase_empty_line (true);
+  
   std::string msg = buf.str ();
 
   if (! msg.empty ())
@@ -595,7 +610,7 @@
 
       if (command_editor::interrupt (false))
         break;
-      else
+       else
         {
           if (retval == 0 && curr_parser.stmt_list)
             {
@@ -910,6 +925,7 @@
       octave_call_stack::goto_frame_relative (0);
 
       tree_evaluator::debug_mode = true;
+      tree_evaluator::quiet_breakpoint_flag = false;
 
       tree_evaluator::current_frame = octave_call_stack::current_frame ();
 
--- a/libinterp/parse-tree/lex.ll
+++ b/libinterp/parse-tree/lex.ll
@@ -3398,12 +3398,7 @@
   if (! input_buf.empty ())
     status = input_buf.copy_chunk (buf, max_size);
   else
-    {
-      status = YY_NULL;
-
-      if (! input_buf.at_eof ())
-        fatal_error ("octave_base_lexer::fill_flex_buffer failed");
-    }
+    status = YY_NULL;
 
   return status;
 }
@@ -3419,12 +3414,7 @@
   if (! input_buf.empty ())
     status = input_buf.copy_chunk (buf, max_size);
   else
-    {
-      status = YY_NULL;
-
-      if (! input_buf.at_eof ())
-        fatal_error ("octave_base_lexer::fill_flex_buffer failed");
-    }
+    status = YY_NULL;
 
   return status;
 }
--- a/libinterp/parse-tree/pt-eval.cc
+++ b/libinterp/parse-tree/pt-eval.cc
@@ -57,6 +57,8 @@
 
 bool tree_evaluator::debug_mode = false;
 
+bool tree_evaluator::quiet_breakpoint_flag = false;
+
 tree_evaluator::stmt_list_type tree_evaluator::statement_context
   = tree_evaluator::other;
 
--- a/libinterp/parse-tree/pt-eval.h
+++ b/libinterp/parse-tree/pt-eval.h
@@ -149,6 +149,8 @@
 
   static bool debug_mode;
 
+  static bool quiet_breakpoint_flag;
+
   // Possible types of evaluation contexts.
   enum stmt_list_type
   {