From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26982 invoked by alias); 8 Aug 2005 05:20:17 -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 26970 invoked by uid 22791); 8 Aug 2005 05:20:12 -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; Mon, 08 Aug 2005 05:20:12 +0000 Received: from farnswood.snap.net.nz (p133-tnt1.snap.net.nz [202.124.110.133]) by viper.snap.net.nz (Postfix) with ESMTP id 55853604061 for ; Mon, 8 Aug 2005 16:33:31 +1200 (NZST) Received: by farnswood.snap.net.nz (Postfix, from userid 501) id DC27E62A99; Mon, 8 Aug 2005 05:20:44 +0100 (BST) From: Nick Roberts MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <17142.56731.941946.838268@farnswood.snap.net.nz> Date: Mon, 08 Aug 2005 05:20:00 -0000 To: gdb-patches@sources.redhat.com Subject: RFC: MI output during program execution X-SW-Source: 2005-08/txt/msg00085.txt.bz2 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);