From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 42A5D3858C54; Thu, 14 Apr 2022 18:21:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 42A5D3858C54 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Remove the byte order parameter to target_read_string X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 3b1bdd53b5a9f0798a9315fa9309d2979045aeaf X-Git-Newrev: 9da74023eb9378315d6b7e1bae02f52cfecc8bd1 Message-Id: <20220414182131.42A5D3858C54@sourceware.org> Date: Thu, 14 Apr 2022 18:21:31 +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: Thu, 14 Apr 2022 18:21:31 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D9da74023eb93= 78315d6b7e1bae02f52cfecc8bd1 commit 9da74023eb9378315d6b7e1bae02f52cfecc8bd1 Author: Tom Tromey Date: Wed Apr 13 06:32:28 2022 -0600 Remove the byte order parameter to target_read_string =20 target_read_string takes a byte order parameter, but only uses this to check whether a given character is zero. This is readily done without requiring the parameter, so remove it. Diff: --- gdb/c-lang.c | 2 +- gdb/target.c | 3 +-- gdb/valprint.c | 12 +++++++----- gdb/valprint.h | 1 - 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gdb/c-lang.c b/gdb/c-lang.c index a7ecf8f91da..be9ee073f58 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -353,7 +353,7 @@ c_get_string (struct value *value, gdb::unique_xmalloc_= ptr *buffer, fetchlimit =3D UINT_MAX; =20 err =3D target_read_string (addr, *length, width, fetchlimit, - byte_order, buffer, length); + buffer, length); if (err !=3D 0) memory_error (TARGET_XFER_E_IO, addr); } diff --git a/gdb/target.c b/gdb/target.c index 6542305f0d0..5a416d5ee3a 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -1406,8 +1406,7 @@ target_read_string (CORE_ADDR memaddr, int len, int *= bytes_read) bytes_read =3D &ignore; =20 /* Note that the endian-ness does not matter here. */ - int errcode =3D target_read_string (memaddr, -1, 1, len, BFD_ENDIAN_LITT= LE, - &buffer, bytes_read); + int errcode =3D target_read_string (memaddr, -1, 1, len, &buffer, bytes_= read); if (errcode !=3D 0) return {}; =20 diff --git a/gdb/valprint.c b/gdb/valprint.c index a4c0f7b343d..8f9954778c5 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -2052,7 +2052,6 @@ partial_memory_read (CORE_ADDR memaddr, gdb_byte *mya= ddr, int target_read_string (CORE_ADDR addr, int len, int width, unsigned int fetchlimit, - enum bfd_endian byte_order, gdb::unique_xmalloc_ptr *buffer, int *bytes_read) { @@ -2122,12 +2121,15 @@ target_read_string (CORE_ADDR addr, int len, int wi= dth, limit =3D bufptr + nfetch * width; while (bufptr < limit) { - unsigned long c; + bool found_nonzero =3D false; + + for (int i =3D 0; !found_nonzero && i < width; ++i) + if (bufptr[i] !=3D 0) + found_nonzero =3D true; =20 - c =3D extract_unsigned_integer (bufptr, width, byte_order); addr +=3D width; bufptr +=3D width; - if (c =3D=3D 0) + if (!found_nonzero) { /* We don't care about any error which happened after the NUL terminator. */ @@ -2733,7 +2735,7 @@ val_print_string (struct type *elttype, const char *e= ncoding, fetchlimit =3D (len =3D=3D -1 ? options->print_max : std::min ((unsigned= ) len, options->print_max)); =20 - err =3D target_read_string (addr, len, width, fetchlimit, byte_order, + err =3D target_read_string (addr, len, width, fetchlimit, &buffer, &bytes_read); =20 addr +=3D bytes_read; diff --git a/gdb/valprint.h b/gdb/valprint.h index 2f4a5022b3e..b12495b10c1 100644 --- a/gdb/valprint.h +++ b/gdb/valprint.h @@ -167,7 +167,6 @@ extern void print_function_pointer_address (const struc= t value_print_options *op =20 extern int target_read_string (CORE_ADDR addr, int len, int width, unsigned int fetchlimit, - enum bfd_endian byte_order, gdb::unique_xmalloc_ptr *buffer, int *bytes_read);