From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#70519: 30.0.50; Device for Emacs terminal I/O Date: Tue, 23 Apr 2024 08:32:25 +0300 Message-ID: <86zftk4pau.fsf@gnu.org> References: <871q6xkvm9.fsf@gmail.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36132"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 70519@debbugs.gnu.org To: Helmut Eller , Paul Eggert Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Apr 23 07:33:17 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rz8mK-0009Ae-IW for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 23 Apr 2024 07:33:16 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rz8lw-0008V5-6b; Tue, 23 Apr 2024 01:32:52 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rz8lu-0008Ua-OX for bug-gnu-emacs@gnu.org; Tue, 23 Apr 2024 01:32:50 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rz8lu-0001Y3-GI for bug-gnu-emacs@gnu.org; Tue, 23 Apr 2024 01:32:50 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rz8mA-000800-I5 for bug-gnu-emacs@gnu.org; Tue, 23 Apr 2024 01:33:06 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 23 Apr 2024 05:33:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70519 X-GNU-PR-Package: emacs Original-Received: via spool by 70519-submit@debbugs.gnu.org id=B70519.171385038030685 (code B ref 70519); Tue, 23 Apr 2024 05:33:06 +0000 Original-Received: (at 70519) by debbugs.gnu.org; 23 Apr 2024 05:33:00 +0000 Original-Received: from localhost ([127.0.0.1]:49966 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rz8m2-0007yg-Cg for submit@debbugs.gnu.org; Tue, 23 Apr 2024 01:33:00 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42722) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rz8lz-0007xN-CB for 70519@debbugs.gnu.org; Tue, 23 Apr 2024 01:32:56 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rz8lb-0001QQ-UN; Tue, 23 Apr 2024 01:32:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=/IJ+odTnnVJMELtlCbKMmgynbj4Z7KAAPRxWRdhYrB8=; b=hFAaUa6jaQUC XqX7qqquEmQMmqsMXGl8EgX5jrbdJ+MVCRf4x2AvE4HXpaWWflbsu6SH0p5gEdwzXWWmip1MVw08+ mBDVhbaFj0xAM6rZo3/IC0AboM4U8ZEmECTywCw99YuKoeXHcdrpt2g1wo53gjj8BOUrG5FNrjxhW V3Q6DfLhcMYDFviYMDamJewiH4rxSM3IBeSLbjWir6u4FUEaA5/fyUm18g2tkpZZyQrBm0hZilXcL w0wfVw5If5WuQ+hI4Kv1Xs5oQ0UJgXhnN1cLCZfDBdiOyxkHlkhjlpdey/s/13mduBDPo8QTxVo4L 3x4BNQsXn4DApDaUEm7nIA==; In-Reply-To: <871q6xkvm9.fsf@gmail.com> (message from Helmut Eller on Mon, 22 Apr 2024 22:09:18 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:283866 Archived-At: > From: Helmut Eller > Date: Mon, 22 Apr 2024 22:09:18 +0200 > > I'd like to start Emacs under GDB, but so that Emacs doesn't use the > same terminal as GDB. You should be able to do that with GDB features. These include: . the 'set inferior-tty' command . the 'set new-console' command The first sets the terminal of the debuggee to the named terminal, the latter causes GDB to create a new terminal each time you "run" a debuggee, and force the debuggee to use that new terminal. These commands should work for you without any changes to the Emacs sources. Alternatively, you could start GDB from a different terminal and attach it to an already running Emacs, but this does not allow you to debug the Emacs startup code. > It seems that the --terminal command line switch is there for > exactly this use case. > > However, it doesn't work. Emacs parses the command line option and > replaces stdin and stdout with the correct device, but then in dispnew.c > it always calls init_tty with 0 as argument for the device name. That > simply opens the controlling terminal, i.e. /dev/tty and that is usually > the same device as the one that GDB uses. > > What would you think of the change below? I don't think it's the correct change. For starters, ttyname is non-portable: on some supported platforms there's no way of getting at the name of a non-default terminal. More importantly, we already know the name of the terminal: we used it in emacs.c when we processed the --terminal switch. We just "forgot" it because we didn't save it anywhere. So one way of fixing this is to record that name and reuse it in init_tty. E.g., make DEV_TTY non-const, and save the actual name there when we process it in emacs.c. Adding Paul in case he has comments.