aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSterling Augustine <saugustine@google.com>2013-11-22 13:55:32 -0800
committerSterling Augustine <saugustine@google.com>2013-11-22 13:58:55 -0800
commitf380848e84613364a17008f04e91bfef09eaf158 (patch)
treef1895451f074f7ba5278d728ada8f06a80a46e9d
parentc0621699ffdbeea387ea37a90258939540b26424 (diff)
downloadgdb-f380848e84613364a17008f04e91bfef09eaf158.zip
gdb-f380848e84613364a17008f04e91bfef09eaf158.tar.gz
gdb-f380848e84613364a17008f04e91bfef09eaf158.tar.bz2
2013-11-22 Sterling Augustine <saugustine@google.com>
PR gdb/16196: * valprint.c (read_string): Set new variable fetchlen based on fetchlimit and size. Use it in call to partial_memory_read. Update comment.
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/valprint.c18
2 files changed, 18 insertions, 7 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 0b8683d..cd2a136 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2013-11-22 Sterling Augustine <saugustine@google.com>
+
+ PR backtrace/16196:
+ * valprint.c (read_string): Set new variable fetchlen based on
+ fetchlimit and size. Use it in call to partial_memory_read.
+ Update comment.
+
2013-11-22 Tom Tromey <tromey@redhat.com>
PR backtrace/16155:
diff --git a/gdb/valprint.c b/gdb/valprint.c
index ea877f3..ecc3411 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -1757,11 +1757,13 @@ partial_memory_read (CORE_ADDR memaddr, gdb_byte *myaddr,
free, and BYTES_READ will be set to the number of bytes read. Returns 0 on
success, or a target_xfer_error on failure.
- If LEN > 0, reads exactly LEN characters (including eventual NULs in
- the middle or end of the string). If LEN is -1, stops at the first
- null character (not necessarily the first null byte) up to a maximum
- of FETCHLIMIT characters. Set FETCHLIMIT to UINT_MAX to read as many
- characters as possible from the string.
+ If LEN > 0, reads the lesser of LEN or FETCHLIMIT characters
+ (including eventual NULs in the middle or end of the string).
+
+ If LEN is -1, stops at the first null character (not necessarily
+ the first null byte) up to a maximum of FETCHLIMIT characters. Set
+ FETCHLIMIT to UINT_MAX to read as many characters as possible from
+ the string.
Unless an exception is thrown, BUFFER will always be allocated, even on
failure. In this case, some characters might have been read before the
@@ -1807,10 +1809,12 @@ read_string (CORE_ADDR addr, int len, int width, unsigned int fetchlimit,
if (len > 0)
{
- *buffer = (gdb_byte *) xmalloc (len * width);
+ unsigned int fetchlen = min (len, fetchlimit);
+
+ *buffer = (gdb_byte *) xmalloc (fetchlen * width);
bufptr = *buffer;
- nfetch = partial_memory_read (addr, bufptr, len * width, &errcode)
+ nfetch = partial_memory_read (addr, bufptr, fetchlen * width, &errcode)
/ width;
addr += nfetch * width;
bufptr += nfetch * width;