public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix qRcmd error code parsing
@ 2022-03-31 15:59 Luis Machado
  2022-03-31 16:04 ` Eli Zaretskii
  2022-04-04 19:16 ` Tom Tromey
  0 siblings, 2 replies; 4+ messages in thread
From: Luis Machado @ 2022-03-31 15:59 UTC (permalink / raw)
  To: gdb-patches

Someone at IRC spotted a bug in qRcmd handling. This looks like an oversight
or it is that way for historical reasons.

The code in gdb/remote.c:remote_target::rcmd uses isdigit instead of
isxdigit. One could argue that we are expecting decimal numbers, but further
below we use fromhex ().

Update the function to use isxdigit instead and also update the documentation.

I see there are lots of other cases of undocumented number format for error
messages, mostly described as NN instead of nn. For now I'll just update
this particular function.
---
 gdb/doc/gdb.texinfo | 3 ++-
 gdb/remote.c        | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 729f9d79a93..607b680b3c0 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -42076,7 +42076,8 @@ A command response with no output.
 @item @var{OUTPUT}
 A command response with the hex encoded output string @var{OUTPUT}.
 @item E @var{NN}
-Indicate a badly formed request.
+Indicate a badly formed request.  The error number @var{NN} is given as
+hex digits.
 @item @w{}
 An empty reply indicates that @samp{qRcmd} is not recognized.
 @end table
diff --git a/gdb/remote.c b/gdb/remote.c
index bc308bd77f8..fe3a73bc6e0 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -11564,7 +11564,7 @@ remote_target::rcmd (const char *command, struct ui_file *outbuf)
       if (strcmp (buf, "OK") == 0)
 	break;
       if (strlen (buf) == 3 && buf[0] == 'E'
-	  && isdigit (buf[1]) && isdigit (buf[2]))
+	  && isxdigit (buf[1]) && isxdigit (buf[2]))
 	{
 	  error (_("Protocol error with Rcmd"));
 	}
-- 
2.25.1


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

* Re: [PATCH] Fix qRcmd error code parsing
  2022-03-31 15:59 [PATCH] Fix qRcmd error code parsing Luis Machado
@ 2022-03-31 16:04 ` Eli Zaretskii
  2022-04-04 19:16 ` Tom Tromey
  1 sibling, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2022-03-31 16:04 UTC (permalink / raw)
  To: Luis Machado; +Cc: gdb-patches

> Date: Thu, 31 Mar 2022 16:59:04 +0100
> From: Luis Machado via Gdb-patches <gdb-patches@sourceware.org>
> 
> Someone at IRC spotted a bug in qRcmd handling. This looks like an oversight
> or it is that way for historical reasons.
> 
> The code in gdb/remote.c:remote_target::rcmd uses isdigit instead of
> isxdigit. One could argue that we are expecting decimal numbers, but further
> below we use fromhex ().
> 
> Update the function to use isxdigit instead and also update the documentation.
> 
> I see there are lots of other cases of undocumented number format for error
> messages, mostly described as NN instead of nn. For now I'll just update
> this particular function.
> ---
>  gdb/doc/gdb.texinfo | 3 ++-
>  gdb/remote.c        | 2 +-
>  2 files changed, 3 insertions(+), 2 deletions(-)

The documentation part is fine, thanks.

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

* Re: [PATCH] Fix qRcmd error code parsing
  2022-03-31 15:59 [PATCH] Fix qRcmd error code parsing Luis Machado
  2022-03-31 16:04 ` Eli Zaretskii
@ 2022-04-04 19:16 ` Tom Tromey
  2022-04-05  7:45   ` Luis Machado
  1 sibling, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2022-04-04 19:16 UTC (permalink / raw)
  To: Luis Machado via Gdb-patches

>>>>> "Luis" == Luis Machado via Gdb-patches <gdb-patches@sourceware.org> writes:

Luis> The code in gdb/remote.c:remote_target::rcmd uses isdigit instead of
Luis> isxdigit. One could argue that we are expecting decimal numbers, but further
Luis> below we use fromhex ().

Luis> Update the function to use isxdigit instead and also update the documentation.

This is ok.  Thank you.

Luis> I see there are lots of other cases of undocumented number format for error
Luis> messages, mostly described as NN instead of nn. For now I'll just update
Luis> this particular function.

Errors aren't very well defined in the RSP, unfortunately.
There's also an extended error type used in like one packet.

Tom

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

* Re: [PATCH] Fix qRcmd error code parsing
  2022-04-04 19:16 ` Tom Tromey
@ 2022-04-05  7:45   ` Luis Machado
  0 siblings, 0 replies; 4+ messages in thread
From: Luis Machado @ 2022-04-05  7:45 UTC (permalink / raw)
  To: Tom Tromey, Luis Machado via Gdb-patches

On 4/4/22 20:16, Tom Tromey wrote:
>>>>>> "Luis" == Luis Machado via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Luis> The code in gdb/remote.c:remote_target::rcmd uses isdigit instead of
> Luis> isxdigit. One could argue that we are expecting decimal numbers, but further
> Luis> below we use fromhex ().
> 
> Luis> Update the function to use isxdigit instead and also update the documentation.
> 
> This is ok.  Thank you.
> 

Pushed now. Thanks!

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

end of thread, other threads:[~2022-04-05  7:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-31 15:59 [PATCH] Fix qRcmd error code parsing Luis Machado
2022-03-31 16:04 ` Eli Zaretskii
2022-04-04 19:16 ` Tom Tromey
2022-04-05  7:45   ` Luis Machado

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