RFC: MI output during program execution

Nick Roberts nickrob@snap.net.nz
Thu Aug 18 13:28:00 GMT 2005


I've updated my previous patch to use mi_insert/mi_remove_notify_hooks instead
of the condition (strcmp (interpreter_p, "mi") == 0).  This mechanism could be
used more pervasively with ui_out_is_mi_like_p to give furher MI output e.g
reason for stopping.  It could also be used for any event notification that is
developed for MI.  It might not work with true asynchronous behaviour but
in that case the existing suppression of queries using mi_interp_query_hook
must also fail.

Nick


*** defs.h.~1.189.~	2005-08-08 18:20:44.000000000 +1200
--- defs.h	2005-08-18 09:51:14.000000000 +1200
*************** extern struct continuation *cmd_continua
*** 711,716 ****
--- 711,718 ----
  /* Used only by the step_1 function. */
  extern struct continuation *intermediate_continuation;
  
+ extern int gdb_mi_run_status;
+ 
  /* From utils.c */
  extern void add_continuation (void (*)(struct continuation_arg *),
  			      struct continuation_arg *);


*** infrun.c.~1.203~	2005-08-15 10:38:14.000000000 +1200
--- infrun.c	2005-08-18 11:06:01.000000000 +1200
***************
*** 49,54 ****
--- 49,57 ----
  
  #include "gdb_assert.h"
  #include "mi/mi-common.h"
+ #include "mi/mi-out.h"
+ 
+ extern struct ui_file *raw_stdout;
  
  /* Prototypes for local functions */
  
*************** proceed (CORE_ADDR addr, enum target_sig
*** 785,790 ****
--- 788,803 ----
  
    annotate_starting ();
  
+   if (gdb_mi_run_status || (ui_out_is_mi_like_p (uiout)))
+     {
+       fputs_unfiltered ("^running\n", raw_stdout);
+       if (!target_can_async_p ())
+ 	{
+ 	  fputs_unfiltered ("(gdb) \n", raw_stdout);
+ 	   gdb_flush (raw_stdout);
+ 	}
+     }
+ 
    /* Make sure that output from GDB appears before output from the
       inferior.  */
    gdb_flush (gdb_stdout);
*************** Further execution is probably impossible
*** 3136,3141 ****
--- 3149,3164 ----
  done:
    annotate_stopped ();
    observer_notify_normal_stop (stop_bpstat);
+   if (gdb_mi_run_status || (ui_out_is_mi_like_p (uiout)))
+     {
+       fputs_unfiltered ("*stopped", raw_stdout);
+       if (ui_out_is_mi_like_p (uiout))
+ 	{
+ 	  mi_out_put (uiout, raw_stdout);
+ 	  mi_out_rewind (uiout);
+ 	}
+       fputs_unfiltered ("\n", raw_stdout);
+     }
  }
  
  static int


*** mi/mi-interp.c.~1.15.~	2005-08-01 10:45:28.000000000 +1200
--- mi/mi-interp.c	2005-08-18 09:54:29.000000000 +1200
*************** struct mi_interp
*** 48,53 ****
--- 48,55 ----
    struct interp *mi_interp;
  };
  
+ int gdb_mi_run_status = 0;
+ 
  /* These are the interpreter setup, etc. functions for the MI interpreter */
  static void mi_execute_command_wrapper (char *cmd);
  static void mi_command_loop (int mi_version);
*************** static void
*** 280,291 ****
--- 282,295 ----
  mi_insert_notify_hooks (void)
  {
    deprecated_query_hook = mi_interp_query_hook;
+   gdb_mi_run_status = 1;
  }
  
  static void
  mi_remove_notify_hooks (void)
  {
    deprecated_query_hook = NULL;
+   gdb_mi_run_status = 0;
  }
  
  static int
*************** mi_interp_query_hook (const char *ctlstr
*** 294,299 ****
--- 298,309 ----
    return 1;
  }
  
+ static int
+ mi_cli_hook (const char *ctlstr, va_list ap)
+ {
+   return 1;
+ }
+ 
  static void
  mi_execute_command_wrapper (char *cmd)
  {



More information about the Gdb-patches mailing list