public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] remote.c: Allow inferior to reply with an error
@ 2023-01-04 11:39 
  2023-01-04 14:42 ` Eli Zaretskii
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From:  @ 2023-01-04 11:39 UTC (permalink / raw)
  To: gdb-patches

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] remote.c: Allow inferior to reply with an error
  2023-01-04 11:39 [PATCH] remote.c: Allow inferior to reply with an error 
@ 2023-01-04 14:42 ` Eli Zaretskii
  2023-01-05 18:16 ` Tom Tromey
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2023-01-04 14:42 UTC (permalink / raw)
  To: ahajkova; +Cc: gdb-patches

> 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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] remote.c: Allow inferior to reply with an error
  2023-01-04 11:39 [PATCH] remote.c: Allow inferior to reply with an error 
  2023-01-04 14:42 ` Eli Zaretskii
@ 2023-01-05 18:16 ` Tom Tromey
  2023-01-06 15:12 ` Andrew Burgess
  2023-01-09 12:55 ` Alexandra Petlanova Hajkova
  3 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2023-01-05 18:16 UTC (permalink / raw)
  To: =?utf-8?Q?AlexandraH=C3=A1jkov=C3=A1?=; +Cc: gdb-patches

>>>>> 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] remote.c: Allow inferior to reply with an error
  2023-01-04 11:39 [PATCH] remote.c: Allow inferior to reply with an error 
  2023-01-04 14:42 ` Eli Zaretskii
  2023-01-05 18:16 ` Tom Tromey
@ 2023-01-06 15:12 ` Andrew Burgess
  2023-01-06 18:59   ` Simon Marchi
  2023-01-09 12:55 ` Alexandra Petlanova Hajkova
  3 siblings, 1 reply; 7+ messages in thread
From: Andrew Burgess @ 2023-01-06 15:12 UTC (permalink / raw)


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] remote.c: Allow inferior to reply with an error
  2023-01-06 15:12 ` Andrew Burgess
@ 2023-01-06 18:59   ` Simon Marchi
  0 siblings, 0 replies; 7+ messages in thread
From: Simon Marchi @ 2023-01-06 18:59 UTC (permalink / raw)
  To: Andrew Burgess, gdb-patches

> 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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] remote.c: Allow inferior to reply with an error
  2023-01-04 11:39 [PATCH] remote.c: Allow inferior to reply with an error 
                   ` (2 preceding siblings ...)
  2023-01-06 15:12 ` Andrew Burgess
@ 2023-01-09 12:55 ` Alexandra Petlanova Hajkova
  2023-01-09 17:14   ` Tom Tromey
  3 siblings, 1 reply; 7+ messages in thread
From: Alexandra Petlanova Hajkova @ 2023-01-09 12:55 UTC (permalink / raw)
  To: AlexandraH=?UTF-8?B?w6E=?=jkov=?UTF-8?B?w6E=?=; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 2236 bytes --]

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
>
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] remote.c: Allow inferior to reply with an error
  2023-01-09 12:55 ` Alexandra Petlanova Hajkova
@ 2023-01-09 17:14   ` Tom Tromey
  0 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2023-01-09 17:14 UTC (permalink / raw)
  To: Alexandra Petlanova Hajkova via Gdb-patches
  Cc: =?utf-8?Q?AlexandraH=C3=A1jkov=C3=A1?=, Alexandra Petlanova Hajkova

>>>>> "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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-01-09 17:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-04 11:39 [PATCH] remote.c: Allow inferior to reply with an error 
2023-01-04 14:42 ` Eli Zaretskii
2023-01-05 18:16 ` Tom Tromey
2023-01-06 15:12 ` Andrew Burgess
2023-01-06 18:59   ` Simon Marchi
2023-01-09 12:55 ` Alexandra Petlanova Hajkova
2023-01-09 17:14   ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).