From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16632 invoked by alias); 23 Nov 2014 10:25:01 -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 16623 invoked by uid 89); 23 Nov 2014 10:25:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Sun, 23 Nov 2014 10:24:59 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id CE601116808; Sun, 23 Nov 2014 05:24:57 -0500 (EST) 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 JPUKq-yTWn2w; Sun, 23 Nov 2014 05:24:57 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 642B11167FB; Sun, 23 Nov 2014 05:24:57 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id AFB7D40F79; Sun, 23 Nov 2014 14:24:56 +0400 (RET) Date: Sun, 23 Nov 2014 10:25:00 -0000 From: Joel Brobecker To: Patrick Palka Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] [RFC] Don't propagate our current terminal state to the inferior Message-ID: <20141123102456.GG7136@adacore.com> References: <1416688748-20448-1-git-send-email-patrick@parcs.ath.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1416688748-20448-1-git-send-email-patrick@parcs.ath.cx> User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2014-11/txt/msg00565.txt.bz2 > Currently when we start an inferior we have the inferior inherit our > terminal state. Under TUI, our terminal is highly modified by ncurses > and readline. So when starting an inferior under TUI, the inferior will > have a highly modified terminal state which will interfere with standard > I/O. For example, > > $ gdb gdb > (gdb) break main > (gdb) run > (gdb) print puts ("a\nb") > a > b > $1 = 4 > (gdb) [enter TUI mode] > (gdb) run > (gdb) [exit TUI mode] > (gdb) print puts ("a\nb") > a > b > $2 = 4 > (gdb) print puts ("a\r\nb\r") > a > b > $3 = 6 > > As you can see, when we start the inferior under the regular interface, > puts() prints the text properly. But when we start the inferior under > TUI, puts() does not print the text properly. This is because when we > start the inferior under TUI it inherits our current terminal state > which has been modified by ncurses to, among other things, require an > explicit \r\n to print a new line. As a result the inferior performs > standard I/O in an unexpected way. > > Because of this discrepancy, it doesn't seem like a good idea to have > the inferior inherit our _current_ terminal state for it may have been > modified by readline and/or ncurses. Instead, we should have the > inferior inherit a pristine snapshot of our terminal state taken before > readline or ncurses have had a chance to alter it. This enables the > inferior to run in a more accurate way, more closely mimicking its > behavior had the program run standalone. And it fixes the above > mentioned issue. > > I wonder, does this change make sense? What do others think? FWIW: It does make sense to me, but I have been known to have a really superficial view or how terminals work. I'd be more comfortable if you waited for someone like Pedro to give it a second look. If no one reviews it by, say, Dec 8th, can you ping me again? Thank you, -- Joel