Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Re: RFC: MI output during program execution
@ 2005-08-18 13:28 Nick Roberts
  2005-08-19  0:52 ` Mark Kettenis
  0 siblings, 1 reply; 83+ messages in thread
From: Nick Roberts @ 2005-08-18 13:28 UTC (permalink / raw)
  To: gdb-patches


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)
  {


^ permalink raw reply	[flat|nested] 83+ messages in thread
* Re: RFC: MI output during program execution
@ 2005-08-17  3:18 Nick Roberts
  0 siblings, 0 replies; 83+ messages in thread
From: Nick Roberts @ 2005-08-17  3:18 UTC (permalink / raw)
  To: Jim Ingham; +Cc: gdb-patches


> Note that for a truly asynchronous target, what you get is:

> (gdb)
> -exec-continue
> ^running
> (gdb)
> -exec-status
> ^done,status="running"
> (gdb)
> -exec-interrupt
> ^done,reason="signal-received",signal-name="SIGINT",signal- meaning="Interrupt",thread-id="1"
> (gdb)

> Or something like that... So in that case the ^running really is the
> equivalent of the ^done...

I don't really mind if it is ^running or *running, I just want GDB to issue
notification when the inferior starts or stops running after a CLI command is
executed.  Currently I can't tell when to update the UI when such commands are
issued through the GUD buffer.  Daniel suggested this was a different case to
breakpoint-changed or thread-changed but I think it requires a similar
solution.

Nick


^ permalink raw reply	[flat|nested] 83+ messages in thread
[parent not found: <1124238360.5670.ezmlm@sources.redhat.com>]
* Re: RFC: MI output during program execution
@ 2005-08-15  2:15 Nick Roberts
  0 siblings, 0 replies; 83+ messages in thread
From: Nick Roberts @ 2005-08-15  2:15 UTC (permalink / raw)
  To: gdb-patches



> +   if ((strcmp (interpreter_p, "mi") == 0) || (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);

I mean:

+   if ((strcmp (interpreter_p, "mi") == 0) || (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);
+     }

of course.

Nick


^ permalink raw reply	[flat|nested] 83+ messages in thread
* Re: RFC: MI output during program execution
@ 2005-08-15  2:13 Nick Roberts
  2005-08-15  4:26 ` Daniel Jacobowitz
  0 siblings, 1 reply; 83+ messages in thread
From: Nick Roberts @ 2005-08-15  2:13 UTC (permalink / raw)
  To: gdb-patches


I've read most of the discussion through the archives.  I find the idea of
notifying the frontend about all changes of state a laudable goal but
currently too difficult (for me).  However, I would still like GDB to
convey to the frontend when the inferior is running.  Jim's point about the
"define" command shoots down the patch that I sent earlier so I would like to
suggest another approach.  I would like to take the "^running" and "*stopped"
tokens out of mi-main.c and put them in infrun.c where annotate_starting and
annotate_stopped are respectively called.  This seems more in line with the
idea of notification and works when I test it natively on GNU/Linux.  I am
sure that it will fail somewhere else (remote targets?) otherwise this
approach would have surely been used in the first place.

With this method user-defined commands work as for simple GDB commands.  CLI
commands don't give full MI output but information like the current line can
be obtained by polling with -stack-info-frame.

-exec-next
^running
(gdb) 
*stopped,reason="end-stepping-range",thread-id="0",frame={addr="0x080484ef",func="main",args=[{name="argc",value="1"},{name="argv",value="0xbffff794"}],file="myprog.c",fullname="/home/nick/myprog.c",line="46"}
(gdb) 
n
&"n\n"
^running
(gdb) 
~"47\t  int n1=7, n2=8, n3=9;\n"
*stopped
^done
(gdb) 

Using strcmp (interpreter_p, "mi") and not strncmp (interpreter_p, "mi", 2)
means that this should only change behaviour for the current mi level.

WDYT?

Nick

*** infrun.c.~1.203~	2005-08-15 10:38:14.000000000 +1200
--- infrun.c	2005-08-15 10:42:50.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,799 ----
  
    annotate_starting ();
  
+   if (strcmp (interpreter_p, "mi") == 0)
+     {
+       fputs_unfiltered ("^running\n", raw_stdout);
+       fputs_unfiltered ("(gdb) \n", 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 ****
--- 3145,3158 ----
  done:
    annotate_stopped ();
    observer_notify_normal_stop (stop_bpstat);
+   if ((strcmp (interpreter_p, "mi") == 0) || (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-main.c.~1.80.~	2005-06-14 09:18:08.000000000 +1200
--- mi/mi-main.c	2005-08-14 20:10:44.000000000 +1200
*************** mi_execute_async_cli_command (char *mi, 
*** 1306,1313 ****
           command. */
        if (last_async_command)
  	fputs_unfiltered (last_async_command, raw_stdout);
-       fputs_unfiltered ("^running\n", raw_stdout);
-       fputs_unfiltered ("(gdb) \n", raw_stdout);
        gdb_flush (raw_stdout);
      }
    else
--- 1306,1311 ----
*************** mi_execute_async_cli_command (char *mi, 
*** 1318,1324 ****
           run command to the target. */
        if (last_async_command)
  	fputs_unfiltered (last_async_command, raw_stdout);
-       fputs_unfiltered ("^running\n", raw_stdout);
      }
  
    execute_command ( /*ui */ run, 0 /*from_tty */ );
--- 1316,1321 ----
*************** mi_execute_async_cli_command (char *mi, 
*** 1332,1341 ****
           the stopped message. */
        if (last_async_command)
  	fputs_unfiltered (last_async_command, raw_stdout);
-       fputs_unfiltered ("*stopped", raw_stdout);
-       mi_out_put (uiout, raw_stdout);
-       mi_out_rewind (uiout);
-       fputs_unfiltered ("\n", raw_stdout);
        return MI_CMD_QUIET;
      }
    return MI_CMD_DONE;
--- 1329,1334 ----


^ permalink raw reply	[flat|nested] 83+ messages in thread
* RFC: MI output during program execution
@ 2005-08-08  5:20 Nick Roberts
  2005-08-08 13:05 ` Daniel Jacobowitz
  2005-08-08 21:00 ` Eli Zaretskii
  0 siblings, 2 replies; 83+ messages in thread
From: Nick Roberts @ 2005-08-08  5:20 UTC (permalink / raw)
  To: gdb-patches


Although Emacs will increasingly use GDB/MI to interact with GDB, the GUD
buffer will always require the use of CLI commands.  These are executed via
"-interpreter-exec console" that Jim Ingham/Apple contributed.  In general
this isn't a problem, but CLI commands which start the inferior e.g run, next,
finish etc do not tell Emacs when the inferior is executing (do not output
^running) and in some cases generate inappropriate output such as the current
source line as CLI output.  I would like to change the output of these
commands to that of their MI counterparts.  I think that Apple have added a
separate interpreter (console-quoted) for this kind of thing.  The patch below
reflects my more modest resources and limited knowledge and seems to do the
kind of thing that Emacs needs.  It doesn't change direct use of MI commands,
just the behaviour of a subset of CLI commands invoked the the MI interpreter:

-exec-next
^running
(gdb) 
*stopped,reason="end-stepping-range",thread-id="0",frame={addr="0x080484ef",func="main",args=[{name="argc",value="1"},{name="argv",value="0xbffff794"}],file="myprog.c",fullname="/home/nick/myprog.c",line="46"}
(gdb) 

-interpreter-exec console next
^running
(gdb) 
*stopped,reason="end-stepping-range",thread-id="0",frame={addr="0x0804851f",func="main",args=[{name="argc",value="1"},{name="argv",value="0xbffff794"}],file="myprog.c",fullname="/home/nick/myprog.c",line="47"}
^done
(gdb) 

Note that the latter generates an extra ^done as the MI command
-interpreter-exec completes.  I'm not asking for approval at this stage, but
any feedback would be most welcome.

Nick



*** mi/mi-interp.c.~1.15.~	2005-08-01 10:45:28.000000000 +1200
--- mi/mi-interp.c	2005-08-08 11:10:08.000000000 +1200
***************
*** 33,38 ****
--- 33,40 ----
  #include "mi-out.h"
  #include "mi-console.h"
  
+ #include "cli/cli-decode.h"
+ 
  struct mi_interp
  {
    /* MI's output channels */
*************** mi_cmd_interpreter_exec (char *command, 
*** 239,250 ****
           and then set it back to 0 when we are done. */
        sync_execution = 1;
        {
! 	struct gdb_exception e = interp_exec (interp_to_use, argv[i]);
! 	if (e.reason < 0)
  	  {
! 	    mi_error_message = xstrdup (e.message);
! 	    result = MI_CMD_ERROR;
! 	    break;
  	  }
        }
        xfree (buff);
--- 241,288 ----
           and then set it back to 0 when we are done. */
        sync_execution = 1;
        {
! 	struct gdb_exception e;
! 	int flag = 0;
! 
! 	if (strcmp (argv[0], "console") == 0)
! 	  /* Stick with MI for commands which run the inferior. */
! 	  {
! 	    struct cmd_list_element *c;
! 	    extern struct cmd_list_element *cmdlist;
! 	    char *token, *cp;
! 
! 	    flag = 1;
! 	    cp = xstrdup (argv[i]);
! 	    c = lookup_cmd (&cp, cmdlist, "", 0, 0);
! 	    if (strcmp (c->name, "run") == 0)
! 	      mi_cmd_exec_run (cp, 0);
! 	    else if (strcmp (c->name, "next") == 0)
! 	      mi_cmd_exec_next (cp, 0);
! 	    else if (strcmp (c->name, "nexti") == 0)
! 	      mi_cmd_exec_next_instruction (cp, 0);
! 	    else if (strcmp (c->name, "step") == 0)
! 	      mi_cmd_exec_step (cp, 0);
! 	    else if (strcmp (c->name, "stepi") == 0)
! 	      mi_cmd_exec_step_instruction (cp, 0);
! 	    else if (strcmp (c->name, "finish") == 0)
! 	      mi_cmd_exec_finish (cp, 0);
! 	    else if (strcmp (c->name, "until") == 0)
! 	      mi_cmd_exec_until (cp, 0);
! 	    else if (strcmp (c->name, "return") == 0)
! 	      mi_cmd_exec_return (cp, 0);
! 	    else
! 	      flag = 0;
! 	  }
! 
! 	if (!flag)
  	  {
! 	    e = interp_exec (interp_to_use, argv[i]);
! 	    if (e.reason < 0)
! 	      {
! 		mi_error_message = xstrdup (e.message);
! 		result = MI_CMD_ERROR;
! 		break;
! 	      }
  	  }
        }
        xfree (buff);


^ permalink raw reply	[flat|nested] 83+ messages in thread

end of thread, other threads:[~2006-03-28 22:29 UTC | newest]

Thread overview: 83+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1123605445.30442.ezmlm@sources.redhat.com>
2005-08-09 17:24 ` RFC: MI output during program execution Jim Ingham
2005-08-09 17:59   ` Bob Rossi
2005-08-09 18:09     ` Jim Ingham
2005-08-09 18:23       ` Bob Rossi
2005-08-09 18:40         ` Jim Ingham
2005-08-10  0:48           ` Daniel Jacobowitz
2005-08-10  0:48             ` Jim Ingham
2005-08-10  2:37               ` Daniel Jacobowitz
2005-08-09 18:13   ` Eli Zaretskii
2005-08-09 18:23     ` Bob Rossi
2005-08-09 19:39       ` Eli Zaretskii
2005-08-10  0:41         ` Bob Rossi
2005-08-10  0:42           ` Daniel Jacobowitz
2005-08-10  1:07             ` Bob Rossi
2005-08-10  2:37               ` Jim Ingham
2005-08-12  8:06                 ` Bob Rossi
2005-08-12 10:36                   ` Eli Zaretskii
2005-08-12 12:05                     ` Bob Rossi
2005-08-12 17:25                       ` Eli Zaretskii
2005-08-12 20:45                         ` Bob Rossi
2005-08-12 20:49                           ` Daniel Jacobowitz
2005-08-13  1:11                             ` Bob Rossi
2005-08-13  1:15                               ` Daniel Jacobowitz
2005-08-13 11:07                             ` Eli Zaretskii
2005-08-12 20:54                           ` Mark Kettenis
2005-08-13 15:05                             ` Bob Rossi
2005-08-12 21:01                         ` Daniel Jacobowitz
2005-08-13 11:13                           ` Eli Zaretskii
2005-08-12 17:03                   ` Jim Ingham
2005-08-13  0:33                     ` Bob Rossi
2005-08-13  0:44                       ` Jim Ingham
2005-08-13  5:04                         ` Bob Rossi
2005-08-13  6:47                           ` Daniel Jacobowitz
2005-08-13 11:06                             ` Jim Ingham
2005-08-13 14:51                               ` Bob Rossi
2005-08-13 16:55                                 ` Daniel Jacobowitz
2005-08-13 12:53                             ` Eli Zaretskii
2005-08-13 21:52                             ` Mark Kettenis
2005-08-13  0:22                   ` Daniel Jacobowitz
2005-08-11 10:10               ` Daniel Jacobowitz
2005-08-18 13:28 Nick Roberts
2005-08-19  0:52 ` Mark Kettenis
  -- strict thread matches above, loose matches on Subject: below --
2005-08-17  3:18 Nick Roberts
     [not found] <1124238360.5670.ezmlm@sources.redhat.com>
2005-08-17  1:10 ` Jim Ingham
2005-08-15  2:15 Nick Roberts
2005-08-15  2:13 Nick Roberts
2005-08-15  4:26 ` Daniel Jacobowitz
2005-08-15 10:03   ` Nick Roberts
2005-08-16  0:04     ` Bob Rossi
2005-08-16  0:33       ` Nick Roberts
2005-08-16  0:43     ` Daniel Jacobowitz
2005-08-16  3:54       ` Bob Rossi
2005-08-08  5:20 Nick Roberts
2005-08-08 13:05 ` Daniel Jacobowitz
2005-08-08 18:23   ` Jim Ingham
2005-08-09 17:32     ` Nick Roberts
2005-08-21 22:09     ` Nick Roberts
2005-08-24  2:20       ` Stan Shebs
2005-08-24 16:59         ` Nick Roberts
2005-08-24 20:15           ` Jim Ingham
2005-08-24 20:48             ` Nick Roberts
2005-08-27 12:09           ` Stan Shebs
2005-09-12  3:20         ` Nick Roberts
2005-09-12  3:40           ` Daniel Jacobowitz
2005-09-19 10:30           ` Nick Roberts
2005-09-19 13:17             ` Daniel Jacobowitz
2005-09-19 22:12               ` Nick Roberts
2005-09-19 22:17               ` Nick Roberts
2005-09-19 22:32                 ` Daniel Jacobowitz
2005-10-03  3:20             ` Nick Roberts
2005-10-03 13:18               ` Daniel Jacobowitz
2005-10-03 20:28                 ` Nick Roberts
2005-10-03 20:31                   ` Daniel Jacobowitz
2005-10-03 21:39                     ` Stan Shebs
2005-10-03 21:50                       ` Jim Ingham
2005-10-03 21:59                         ` Daniel Jacobowitz
2005-10-03 22:01                       ` Daniel Jacobowitz
2006-03-28  0:40                 ` Nick Roberts
2006-03-28 22:12                   ` Daniel Jacobowitz
2006-03-28 22:36                     ` Nick Roberts
2006-03-28 23:13                       ` Daniel Jacobowitz
2005-08-08 21:00 ` Eli Zaretskii
2005-08-09 17:52   ` Nick Roberts

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox