Message ID | 20230104113909.1395263-1-ahajkova@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DE08B3858D39 for <patchwork@sourceware.org>; Wed, 4 Jan 2023 11:39:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DE08B3858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1672832376; bh=oqr+Mw+10M5k+GsX5gmvr1qvmwHlRJO/LqNrTkNM3Sw=; h=From:To:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=HAAyf9UavxHxIHJmF+0YcgdMB9CvvfjvpCPZsey5MVJ/zX5HEbBj71mhrgxMbWZCR SHk16Ndif+fmrcA/P0Hp65P4Ohlr9O7hQq+lztHFZ1LMVx1Y0iiaO97ERs4mTplFyI Xh2l2uHvnrP4pUgTakqTfWTdbZ1QjE+SmDgCpkGA= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-224.mimecast.com (us-smtp-delivery-224.mimecast.com [170.10.129.224]) by sourceware.org (Postfix) with ESMTPS id A422F3858D1E for <gdb-patches@sourceware.org>; Wed, 4 Jan 2023 11:39:14 +0000 (GMT) Authentication-Results: sourceware.org; dkim=permerror (bad message/signature format) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-589-ou9qpRwjMVake9obmFD1iQ-1; Wed, 04 Jan 2023 06:39:13 -0500 X-MC-Unique: ou9qpRwjMVake9obmFD1iQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 11DE5382C966 for <gdb-patches@sourceware.org>; Wed, 4 Jan 2023 11:39:13 +0000 (UTC) Received: from ovpn-208-29.brq.redhat.com (ovpn-208-29.brq.redhat.com [10.40.208.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 649921121314 for <gdb-patches@sourceware.org>; Wed, 4 Jan 2023 11:39:12 +0000 (UTC) From: AlexandraH =?utf-8?b?w6E=?= jkov =?utf-8?b?w6E=?= @sourceware.org To: gdb-patches@sourceware.org Subject: [PATCH] remote.c: Allow inferior to reply with an error Date: Wed, 4 Jan 2023 12:39:09 +0100 Message-Id: <20230104113909.1395263-1-ahajkova@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: <> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00, FROM_EXCESS_BASE64, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
remote.c: Allow inferior to reply with an error
|
|
Commit Message
Alexandra Petlanova Hajkova
Jan. 4, 2023, 11:39 a.m. UTC
From: Alexandra Hájková <ahajkova@redhat.com>
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 +++-----
2 files changed, 6 insertions(+), 5 deletions(-)
Comments
> From: AlexandraHájková@sourceware.org > Date: Wed, 4 Jan 2023 12:39:09 +0100 > From: Alexandra Hájková <ahajkova@redhat.com> > > 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 +++----- > 2 files changed, 6 insertions(+), 5 deletions(-) OK for the documentation part. Thanks.
>>>>> AlexandraHájková <AlexandraHájková@sourceware.org> writes: > 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. Thank you, this is ok. Tom
AlexandraHájková@sourceware.org writes: > From: Alexandra Hájková <ahajkova@redhat.com> > > 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 > > @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, > &remote_protocol_packets[PACKET_QSetWorkingDir]) > != PACKET_OK) > - error (_("\ > -Remote replied unexpectedly while setting the inferior's working\n\ > -directory: %s"), > - rs->buf.data ()); > - > + warning (_("\ > +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
> 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. I agree. Simon
Ping On Wed, Jan 4, 2023 at 12:39 PM <AlexandraHájková@sourceware.org> wrote: > From: Alexandra Hájková <ahajkova@redhat.com> > > 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 +++----- > 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 > > @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, > &remote_protocol_packets[PACKET_QSetWorkingDir]) > != PACKET_OK) > - error (_("\ > -Remote replied unexpectedly while setting the inferior's working\n\ > -directory: %s"), > - rs->buf.data ()); > - > + warning (_("\ > +Remote failed to set the inferior's working directory: %s"), > + rs->buf.data ()); > } > } > > -- > 2.38.1 > >
>>>>> "Alexandra" == Alexandra Petlanova Hajkova via Gdb-patches <gdb-patches@sourceware.org> writes:
Alexandra> Ping
I think there were a few replies to this one on the list.
Tom
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 @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, &remote_protocol_packets[PACKET_QSetWorkingDir]) != PACKET_OK) - error (_("\ -Remote replied unexpectedly while setting the inferior's working\n\ -directory: %s"), - rs->buf.data ()); - + warning (_("\ +Remote failed to set the inferior's working directory: %s"), + rs->buf.data ()); } }