aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2022-04-13 06:32:28 -0600
committerTom Tromey <tromey@adacore.com>2022-04-14 12:12:34 -0600
commit9da74023eb9378315d6b7e1bae02f52cfecc8bd1 (patch)
treec519554680c772ab554cbc6a4083000842dbda67 /gdb
parent3b1bdd53b5a9f0798a9315fa9309d2979045aeaf (diff)
downloadgdb-9da74023eb9378315d6b7e1bae02f52cfecc8bd1.zip
gdb-9da74023eb9378315d6b7e1bae02f52cfecc8bd1.tar.gz
gdb-9da74023eb9378315d6b7e1bae02f52cfecc8bd1.tar.bz2
Remove the byte order parameter to target_read_string
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.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/c-lang.c2
-rw-r--r--gdb/target.c3
-rw-r--r--gdb/valprint.c12
-rw-r--r--gdb/valprint.h1
4 files changed, 9 insertions, 9 deletions
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index a7ecf8f..be9ee07 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<gdb_byte> *buffer,
fetchlimit = UINT_MAX;
err = target_read_string (addr, *length, width, fetchlimit,
- byte_order, buffer, length);
+ buffer, length);
if (err != 0)
memory_error (TARGET_XFER_E_IO, addr);
}
diff --git a/gdb/target.c b/gdb/target.c
index 6542305..5a416d5 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 = &ignore;
/* Note that the endian-ness does not matter here. */
- int errcode = target_read_string (memaddr, -1, 1, len, BFD_ENDIAN_LITTLE,
- &buffer, bytes_read);
+ int errcode = target_read_string (memaddr, -1, 1, len, &buffer, bytes_read);
if (errcode != 0)
return {};
diff --git a/gdb/valprint.c b/gdb/valprint.c
index a4c0f7b..8f99547 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -2052,7 +2052,6 @@ partial_memory_read (CORE_ADDR memaddr, gdb_byte *myaddr,
int
target_read_string (CORE_ADDR addr, int len, int width,
unsigned int fetchlimit,
- enum bfd_endian byte_order,
gdb::unique_xmalloc_ptr<gdb_byte> *buffer,
int *bytes_read)
{
@@ -2122,12 +2121,15 @@ target_read_string (CORE_ADDR addr, int len, int width,
limit = bufptr + nfetch * width;
while (bufptr < limit)
{
- unsigned long c;
+ bool found_nonzero = false;
+
+ for (int i = 0; !found_nonzero && i < width; ++i)
+ if (bufptr[i] != 0)
+ found_nonzero = true;
- c = extract_unsigned_integer (bufptr, width, byte_order);
addr += width;
bufptr += width;
- if (c == 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 *encoding,
fetchlimit = (len == -1 ? options->print_max : std::min ((unsigned) len,
options->print_max));
- err = target_read_string (addr, len, width, fetchlimit, byte_order,
+ err = target_read_string (addr, len, width, fetchlimit,
&buffer, &bytes_read);
addr += bytes_read;
diff --git a/gdb/valprint.h b/gdb/valprint.h
index 2f4a502..b12495b 100644
--- a/gdb/valprint.h
+++ b/gdb/valprint.h
@@ -167,7 +167,6 @@ extern void print_function_pointer_address (const struct value_print_options *op
extern int target_read_string (CORE_ADDR addr, int len, int width,
unsigned int fetchlimit,
- enum bfd_endian byte_order,
gdb::unique_xmalloc_ptr<gdb_byte> *buffer,
int *bytes_read);