[PATCH] remote.c: Allow inferior to reply with an error

Alexandra Petlanova Hajkova ahajkova@redhat.com
Mon Jan 9 12:55:36 GMT 2023


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


More information about the Gdb-patches mailing list