From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1650 invoked by alias); 26 May 2016 11:43:15 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 1633 invoked by uid 89); 26 May 2016 11:43:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=pty, pipes, investigating, eclipse X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 26 May 2016 11:43:03 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B80496409F; Thu, 26 May 2016 11:43:02 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4QBh14G011685; Thu, 26 May 2016 07:43:02 -0400 Subject: Re: [PATCH v2 24/25] Add new command to create extra console/mi UI channels To: Eli Zaretskii References: <1458573675-15478-1-git-send-email-palves@redhat.com> <1458573675-15478-25-git-send-email-palves@redhat.com> <83twjz6bex.fsf@gnu.org> <56F02689.2050503@redhat.com> <83r3f369io.fsf@gnu.org> <56F035F3.6060702@redhat.com> Cc: gdb-patches@sourceware.org From: Pedro Alves Message-ID: <3f622c77-762a-c86e-cafb-60f75a598d6c@redhat.com> Date: Thu, 26 May 2016 11:43:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: <56F035F3.6060702@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2016-05/txt/msg00454.txt.bz2 On 03/21/2016 05:57 PM, Pedro Alves wrote: > On 03/21/2016 05:11 PM, Eli Zaretskii wrote: > >> >>> If necessary, it would also be easy to extend the command to support >>> separate streams for in/out/err, like, e.g.: >>> >>> (gdb) new-ui INTERP IN OUT ERR >>> >>> And then it'd be possible to open a new MI channel through >>> unidirectional named pipes, regular files, etc. too. >> >> But doesn't readline need a console-compatible device? PTYs pass the >> isatty test, but pipes and regular files fail it, so will readline at >> all work? > > You'll normally be specifying "MI" as INTERP, which does not need to > use readline at all. So as mentioned above, a frontend first starts GDB > in console mode, with stdin/stdout/stderr associated with a PTY/console, > and then opens a secondary ui with "new-ui" for MI. And this MI ui does > _not_ need to pass the isatty test, as MI does not really need a terminal > for anything. > I've been thinking a bit on how to make this all work on Windows, with Eclipse, and my current thinking is that instead of some hack to embed a native console window inside the GUI, better would be to reuse the same Eclipse terminal emulator widget, and coax gdb to send the right terminal escape sequences for cursor movement and character placement as a Unix gdb would. Instead of a pty, that terminal widget would be backed by a bidirectional named pipe. Cygwin ptys use that behind the scenes as well. So in the end, GDB would be running with input/output connected to a named pipe, and we'd need to force gdb and ncurses to believe that that is a terminal. I'm aware that GNU ncurses, has a concept of "drivers", and it has a driver for real windows consoles ("win32con") and that is the default. AFAIK, the way to select the driver is to set the TERM env var. So in theory, all one would need to do is to set the TERM env var to vt100, xterm, or some such to force the right driver. The problems will probably be around isatty checks in readline and ncurses, as you suggested. There may also be #ifdef WIN32 bits in those libraries that are #ifdef-ing out code that we'll need, assuming terminal == console, though I haven't really checked. The isatty problem looks very much like the problem a native Windows/mingw program has when run on a Cygwin terminal (and MSYS/MSYS2, which are Cygwin forks), since Cygwin emulates pseudo terminals via named pipes. See, e.g.,: http://www.spinics.net/lists/git/msg274348.html So I think it should be possible to make it work on Windows, and I think it's the right way forward, though some further ncurses/readline/gdb patching might be in order. So it looks like if you get native Windows GDB (readline/ncurses) behaving correctly (history, completion, etc.) when run on a Cygwin terminal, then from within Eclipse or any other GUI, it would work as well. BTW, while investigating this, I found that since some recent update to Windows 10, Windows consoles now supports ansi/vt100 escape sequences, finally: http://www.nivot.org/blog/post/2016/02/04/Windows-10-TH2-%28v1511%29-Console-Host-Enhancements This further reinforces to me the idea of using ansi escapes on Windows Eclipse/gdb too. Thanks, Pedro Alves