From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 749613858D28 for ; Fri, 6 Jan 2023 15:12:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 749613858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673017944; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4z6s+nkGs+R3R+Kr4WUlrZGdWaPgEA+r3QVVKbjuPQo=; b=dwcgJPhmHRAam8RSNi3OQzfRIOm169uS1UI/CVCwzD7g5Kx0QCWc7Wc4oyZBtoqfiwJjCt vjxAQmVAm/JKwTpNhWG7TDSQ+PweaLdq3E3mibiDuirKHFJHBjh54IkWI/C3jEEvD9W/tl effrEdtF5LOGkqAkb1znYxwXlecTnRc= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-266-g8GT9rWVPRWk5RqXSK4UiA-1; Fri, 06 Jan 2023 10:12:22 -0500 X-MC-Unique: g8GT9rWVPRWk5RqXSK4UiA-1 Received: by mail-qv1-f72.google.com with SMTP id i7-20020a056214020700b004ffce246a2bso892597qvt.3 for ; Fri, 06 Jan 2023 07:12:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:to:from:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=MUokm+jXXCw3qvMSQfonPQlqiVp0d9yxB7DCmTDjMO8=; b=Y//CFlCzceKdXpwfqZwksMPm2TE9Ly71Mr8ihjTMd1xPdVk4Z8ZuYhBhVT5On5STV3 IYYy/Ax1MkIaS5dKErmWJbUi1v2dggLR48AhtyTh6V5EKL6bWKUTB/0NkLalAxhT3bC2 rMHL182CC6PHu0hIneInQEEgl2ReJ/YfQRGYPeSKrG4tMgmnuQfGng88iY5LO8lEAGlK dN5kDZTFqgDuP/W8xsSc/8aJVb1/baMBzJGwnIM7nBHx8noFtdMccoSoYsiXJ4JIwJsu YyfovG1GMjQPjxLdC5C2Jv/SRMdGtuIdLzJf8wH4iX2rFSeFOiAj4u/wCR1/jgvYu7fQ kN1w== X-Gm-Message-State: AFqh2kqOG0xubwsZAo/XYwhtlUdduv1S/FbH9siYRWeglROkxAUvsKdy xFIKlPFJgbpD5/JZVbiipIvQHpQqN4+EXLvX5CUBU5XN8WZA1CtSHc0+ksy1lrJ4x1R7EvbhSvq xF5oP6Tf2IyYS8asmCRq3dA== X-Received: by 2002:a05:622a:5a15:b0:3a7:ee3d:21b3 with SMTP id fy21-20020a05622a5a1500b003a7ee3d21b3mr91419639qtb.0.1673017941421; Fri, 06 Jan 2023 07:12:21 -0800 (PST) X-Google-Smtp-Source: AMrXdXsXerjMbjGAPdx1iZ9oeJtSAbL2fRuRh7Pi/WT53+VsHqIejxmqlYu26GD/ZMsMnLDGapRATQ== X-Received: by 2002:a05:622a:5a15:b0:3a7:ee3d:21b3 with SMTP id fy21-20020a05622a5a1500b003a7ee3d21b3mr91419619qtb.0.1673017941196; Fri, 06 Jan 2023 07:12:21 -0800 (PST) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id d13-20020ac8668d000000b003a6a4744432sm596024qtp.87.2023.01.06.07.12.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Jan 2023 07:12:20 -0800 (PST) From: Andrew Burgess To: =?us-ascii?Q?AlexandraH=3D=3FUTF-8=3FB=3Fw6E=3D=3F=3Djkov=3D=3FUTF-8?= =?us-ascii?Q?=3FB=3Fw6E=3D=3F=3D?=@sourceware.org, gdb-patches@sourceware.org Subject: Re: [PATCH] remote.c: Allow inferior to reply with an error In-Reply-To: <20230104113909.1395263-1-ahajkova@redhat.com> References: <20230104113909.1395263-1-ahajkova@redhat.com> Date: Fri, 06 Jan 2023 15:12:19 +0000 Message-ID: <87o7rby9ws.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: AlexandraH=C3=A1jkov=C3=A1@sourceware.org writes: > From: Alexandra H=C3=A1jkov=C3=A1 > > When gdb communicates with the inferior with the remote > protocol, the only possible response to the QSetWorkingDir > packet is "OK". If the inferior will reply with anything > else, gdb will complain about the unexpected reply and stop > its communication with the inferior. > > [remote] Sending packet: $QSetWorkingDir:2f746d70#bb > [remote] Packet received: E00 > Remote replied unexpectedly while setting the inferior's working > directory: E00 > (gdb) > > But setting the inferior's working dir is not always possible due > to various reasons and we may not want to always stop the communication. > This patch proposes to just warn the user in a case it wasn't possible > to set the working dir but proceed without an error. > > [remote] Sending packet: $QSetWorkingDir:2f746d70#bb > remote] Packet received: E00 > warning: Remote failed to set the inferior's working directory: E00 > [remote] Sending packet: $vRun;2f7573722f62696e2f6563686f#3d > --- > gdb/doc/gdb.texinfo | 3 +++ > gdb/remote.c | 8 +++----- Changes like this should definitely have a test, but, in this case, I have bigger worries, see below... > 2 files changed, 6 insertions(+), 5 deletions(-) > > diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo > index dd8f8bc757c..54cab3afa9c 100644 > --- a/gdb/doc/gdb.texinfo > +++ b/gdb/doc/gdb.texinfo > @@ -42515,6 +42515,9 @@ Reply: > @table @samp > @item OK > The request succeeded. > + > +@item E @var{nn} > +An error occurred. The error number @var{nn} is given as hex digits. > @end table > =20 > @item qfThreadInfo > diff --git a/gdb/remote.c b/gdb/remote.c > index 218bca30d04..db5b949a28b 100644 > --- a/gdb/remote.c > +++ b/gdb/remote.c > @@ -10421,11 +10421,9 @@ remote_target::extended_remote_set_inferior_cwd = () > if (packet_ok (rs->buf, > =09=09 &remote_protocol_packets[PACKET_QSetWorkingDir]) > =09 !=3D PACKET_OK) > -=09error (_("\ > -Remote replied unexpectedly while setting the inferior's working\n\ > -directory: %s"), > -=09 rs->buf.data ()); > - > +=09warning (_("\ > +Remote failed to set the inferior's working directory: %s"), > + rs->buf.data ()); I don't think this should be merged. I don't think changing this error into a warning is a good idea. Surely, if GDB can't switch to the directory that the user expects, then we should stop and tell the user that we can't do what they've asked, then the user could update things and try again. As a (maybe extreme) example, what if the user was debugging 'rm -f *', but first changed from their $HOME directory to '/tmp/test-dir/'. If the requested directory doesn't exist then we're going to just carry on and run the test in $HOME .... that seems like a bad idea to me. Thanks, Andrew