From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from omta036.useast.a.cloudfilter.net (omta036.useast.a.cloudfilter.net [44.202.169.35]) by sourceware.org (Postfix) with ESMTPS id E8D083858C78 for ; Tue, 12 Dec 2023 20:03:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E8D083858C78 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E8D083858C78 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702411422; cv=none; b=fO7AuBHpwaFCT4BjVno7koV7JxfHNk2c55WVyolOfx3XrrURYAZjkd32OZ72r2hAppfFv4CufaSvkatqQuStOSxqt0rcRPeG4jW3s0R0owfW9DurKlm/v5fCnjOdvBvilJpvdUM6DnI1K8ezh+22nqTmkQ8/BXvn1mfXHbU230w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702411422; c=relaxed/simple; bh=6dNMEKlPVq0uOmFeqK2ZzW0ccsLjYgD52Q25oZlYN9Y=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=riWDBJKgB7VtG4hqP5ykKzSxFt1mLDmQIQwsKYkNICM5CrCcQwc5yzXya14jij8SzgCn6lXlsGh03+TKUbhJw23TUpjaVEJaOP4CdxV0imGwy3nZC2LJY9ICCcNHilJMc0gmbM+Z0crN9g85bXT1ph5uMgWbwo5HiDIBwaN3U8k= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6010a.ext.cloudfilter.net ([10.0.30.248]) by cmsmtp with ESMTPS id D5Ayr54hdgpyED8yirSmo6; Tue, 12 Dec 2023 20:03:40 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id D8yhrLUkf8vT0D8yhrRAS7; Tue, 12 Dec 2023 20:03:40 +0000 X-Authority-Analysis: v=2.4 cv=ffi+dmcF c=1 sm=1 tr=0 ts=6578bc9c a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=e2cXIFwxEfEA:10 a=Qbun_eYptAEA:10 a=20KFwNOVAAAA:8 a=4FAJN3lAhaK282EIWGgA:9 a=QEXdDO2ut3YA:10 a=qCpqNhVE49DEqPOWPEN-:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID: In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=JNWLzKlXqZUtPfCVcSn+BDKjnG2wDl6sCEmw1w58+e0=; b=w8RJcKAj2lg6v46yHEgPoDLYrW 6ewwVarJVUZ5j+aXqz6gk/svrDap/YI0AEpzl7yaF4pVHEi/xw1eY6vvA6JyX1nh0qRrL5EJXIzu/ oN/CbO4kxlNaYdLXVVMXdlQCy; Received: from 71-211-161-25.hlrn.qwest.net ([71.211.161.25]:34278 helo=murgatroyd) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rD8yh-002IkV-13; Tue, 12 Dec 2023 13:03:39 -0700 From: Tom Tromey To: Alexandra =?utf-8?B?SMOhamtvdsOh?= Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 3/6] Add new vDefaultInferiorFd packet References: <20231117111840.2040709-1-ahajkova@redhat.com> <20231117111840.2040709-4-ahajkova@redhat.com> X-Attribution: Tom Date: Tue, 12 Dec 2023 13:03:38 -0700 In-Reply-To: <20231117111840.2040709-4-ahajkova@redhat.com> ("Alexandra =?utf-8?B?SMOhamtvdsOhIidz?= message of "Fri, 17 Nov 2023 12:18:37 +0100") Message-ID: <87r0jrb339.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 71.211.161.25 X-Source-L: No X-Exim-ID: 1rD8yh-002IkV-13 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-161-25.hlrn.qwest.net (murgatroyd) [71.211.161.25]:34278 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfFwHm/Ri6Fqe5ZNHtWMAjJiH+s+P4zaZAtnamW6XCP9zkI5qWqeX624zlbYx/GMioraY5Xm6jEoIsDwliuENVdKlvN9GGJtJFA6O9k8mj7ILKxp1bFrA c0FD57fCGcaNyyUl4nzzLLhoHyRqzucnbnAQ6/HMF2y8+y0b9PsgD/gw4VYYrvmSrrAnxRp/S46dvhRbBvZDRIlYeQQdbIaHyBE= X-Spam-Status: No, score=-3017.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: >>>>> "Alexandra" =3D=3D Alexandra H=C3=A1jkov=C3=A1 = writes: Alexandra> +@item vDefaultInferior;@var{fd0};@var{fd1};@var{fd2} I think the packet name is wrong on this line. Alexandra> +@item vDefaultInferiorFd Alexandra> +@anchor{default inferior file descriptors} Alexandra> +@cindex @samp{vDefaultInferiorFd} packet Alexandra> +@value{GDBN} would preserve the numbers of STDOUT/STDIN/STDERR = file descriptors. Alexandra> +Preserved numbers of the file descriptors are then sent to GDBs= erver. Alexandra> +If GDBserver is run locally and will accept the numbers of the = file Alexandra> +descriptors, it will start the inferior connected to the same S= TDIN/OUT/ERR Alexandra> +@value{GDBN} is connected to. This allows the inferior run unde= r the local GDBserver To me, the use of "sent" here makes it sound like this is using the (obscure) SCM_RIGHTS feature, that lets one send file descriptors over a socket. However, it isn't, instead it is invoking gdbserver with some extra file descriptors already opened, and then telling the server which ones to use. I think the text should be reworded to make this more clear. =20 Alexandra> + /* Returns true if connecting inferior to the same terminal a= s GDB is Alexandra> + supported, false otherwise. */ Alexandra> + bool remote_fd_switch_p () const Alexandra> + { return packet_support (PACKET_vDefaultInferiorFd) =3D=3D PA= CKET_ENABLE; } This seems a little odd to me in that if I set up some kind of 'nc' bridge and use it to connect to a remote valgrind-gdbserver, it will try to use the gdb file descriptors but that just won't make sense at all. I guess I'm wondering if this should try to use whatever mechanism we came up with for checking if the remote is really remote. I don't remember if that ended up going in or not. Alexandra> + if ((m_features.packet_support (PACKET_vDefaultInferiorFd) != =3D PACKET_DISABLE) Alexandra> + && (rs->remote_desc->fds[0] !=3D -1) && (rs->remote_desc-= >fds[1] !=3D -1) Alexandra> + && (rs->remote_desc->fds[2] !=3D -1)) These are over-parenthesized. Alexandra> +volatile int multi_mode =3D 0; I think you can drop the volatile. I suspect that was an artifact of the old longjmp-based exception system. Alexandra> @@ -4295,6 +4413,14 @@ process_serial_event (void) Alexandra> response_needed =3D true; =20 Alexandra> char ch =3D cs.own_buf[0]; Alexandra> + if (deferred_inferior_startup) Alexandra> + { Alexandra> + /* Actually start the inferior if not a qSupported or Alexandra> + vDefaultInferiorFd packet. */ Alexandra> + if (!startswith(cs.own_buf, "qSupported") Alexandra> + && !startswith(cs.own_buf, "vDefaultInferiorFd")) Alexandra> + do_deferred_startup (); Alexandra> + } I had to read this a few times before I felt like it made sense. Since there is an ordering dependency here, I think that should be documented. That is, vDefaultInferiorFd is only accepted after qSupported and before any other request. Tom