From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3514 invoked by alias); 19 Apr 2012 18:53:58 -0000 Received: (qmail 3504 invoked by uid 22791); 19 Apr 2012 18:53:56 -0000 X-SWARE-Spam-Status: No, hits=-3.6 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_HOSTKARMA_NO,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 19 Apr 2012 18:53:42 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 8920A1C6E3C; Thu, 19 Apr 2012 14:53:41 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 0byJEivTJFeJ; Thu, 19 Apr 2012 14:53:41 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 507501C6E1E; Thu, 19 Apr 2012 14:53:41 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id E539F145616; Thu, 19 Apr 2012 11:53:29 -0700 (PDT) Date: Thu, 19 Apr 2012 18:53:00 -0000 From: Joel Brobecker To: Eli Zaretskii Cc: gdb@sourceware.org Subject: Re: GDB/MI and ">" prompts (was: Interactive behavior of GDB run from Emacs on Windows) Message-ID: <20120419185329.GO25623@adacore.com> References: <83vckviv3b.fsf@gnu.org> <20120419154853.GM25623@adacore.com> <83sjfzitxx.fsf@gnu.org> <83r4vjitnj.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <83r4vjitnj.fsf@gnu.org> User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2012-04/txt/msg00161.txt.bz2 > With this knowhow in hand, my next question is about GDB/MI behavior > when it is connected to a tty device. Typing > > -interpreter-exec console "commands" > > from the console for some reason disables the ">" prompts for the > breakpoint commands. If stdin is NOT a tty, those prompts _are_ > output. Why the difference? I don't know if it is a feature or a bug. I would lean towards a bug. GDB treats all prompts the same, and asks the current interpreter whether to display the prompt or not. See gdb_readline_wrapper, which calls display_gdb_prompt, which does: /* Each interpreter has its own rules on displaying the command prompt. */ if (!current_interp_display_prompt_p ()) return; Although we are executing the command using the console interpreter, the current interpreter remains the GDB/MI interpreter: (top-gdb) p *current_interpreter $11 = {name = 0x19b8ce0 "mi", next = 0x19b9ec0, data = 0x1a32390, inited = 1, procs = 0x94d480, quiet_p = 0} And thus, current_interp_display_prompt_p returns false. Just to see what would happen if the GDB/MI interpreter was to display prompts, I tweaked mi_interpreter_prompt_p to always return 1, and here is what I get: -interpreter-exec console "commands 1" ~"Type commands for breakpoint(s) 1, one per line.\nEnd with a line saying just \"end\".\n" ~">" print 1 ~">" print 2 ~">" end The ~ lines are lines that would be printed verbatim on the debugger console, so I believe the user experience would be similar to what we get in non-MI mode. But of course, things are not as simple as this, since I do not think we want the GDB/MI to always print the prompt. Although, I didn't see how always returning 1 made a difference elsewhere, in particular with the main GDB prompt. So perhaps that could be a solution, I just don't know enough about this to be sure. The other thing that occured to me was that, perhaps, we should instead be switching the interpreter while executing the console command, but I doubt that would be correct. -- Joel