From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1585) id 635043858D37; Tue, 5 Apr 2022 07:44:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 635043858D37 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Luis Machado To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Fix qRcmd error code parsing X-Act-Checkin: binutils-gdb X-Git-Author: Luis Machado X-Git-Refname: refs/heads/master X-Git-Oldrev: 27f9f649753b8c4bd4c40bde0f49d916c222a16a X-Git-Newrev: d5ce6f2dcacf9809fb7a29a69c4b98e0320c3c94 Message-Id: <20220405074438.635043858D37@sourceware.org> Date: Tue, 5 Apr 2022 07:44:38 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Apr 2022 07:44:38 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dd5ce6f2dcacf= 9809fb7a29a69c4b98e0320c3c94 commit d5ce6f2dcacf9809fb7a29a69c4b98e0320c3c94 Author: Luis Machado Date: Thu Mar 31 16:45:53 2022 +0100 Fix qRcmd error code parsing =20 Someone at IRC spotted a bug in qRcmd handling. This looks like an over= sight or it is that way for historical reasons. =20 The code in gdb/remote.c:remote_target::rcmd uses isdigit instead of isxdigit. One could argue that we are expecting decimal numbers, but fu= rther below we use fromhex (). =20 Update the function to use isxdigit instead and also update the documen= tation. =20 I see there are lots of other cases of undocumented number format for e= rror messages, mostly described as NN instead of nn. For now I'll just update this particular function. Diff: --- 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 b7da5e1173b..e50618fe9ab 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -42157,7 +42157,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 122f204fe12..b002f041734 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -11565,7 +11565,7 @@ remote_target::rcmd (const char *command, struct ui= _file *outbuf) if (strcmp (buf, "OK") =3D=3D 0) break; if (strlen (buf) =3D=3D 3 && buf[0] =3D=3D 'E' - && isdigit (buf[1]) && isdigit (buf[2])) + && isxdigit (buf[1]) && isxdigit (buf[2])) { error (_("Protocol error with Rcmd")); }