From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22981 invoked by alias); 14 Aug 2005 22:52:21 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 22961 invoked by uid 22791); 14 Aug 2005 22:52:13 -0000 Received: from viper.snap.net.nz (HELO viper.snap.net.nz) (202.37.101.8) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Sun, 14 Aug 2005 22:52:13 +0000 Received: from farnswood.snap.net.nz (p233-tnt2.snap.net.nz [202.124.108.233]) by viper.snap.net.nz (Postfix) with ESMTP id 5A3AE60737B for ; Mon, 15 Aug 2005 10:52:09 +1200 (NZST) Received: by farnswood.snap.net.nz (Postfix, from userid 501) id 04F4D62A99; Sun, 14 Aug 2005 23:54:44 +0100 (BST) From: Nick Roberts MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <17151.52148.262754.334426@farnswood.snap.net.nz> Date: Mon, 15 Aug 2005 02:13:00 -0000 To: gdb-patches@sources.redhat.com Subject: Re: RFC: MI output during program execution X-SW-Source: 2005-08/txt/msg00169.txt.bz2 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 ----