45 for (errcode = 0, nread = 0; len > 0 && errcode == 0; nread++, len--)
66 unsigned int fetchlimit,
67 gdb::unique_xmalloc_ptr<gdb_byte> *buffer,
78 buffer->reset (
nullptr);
84 unsigned int fetchlen = std::min ((
unsigned) len, fetchlimit);
86 buffer->reset ((gdb_byte *)
xmalloc (fetchlen * width));
87 bufptr = buffer->get ();
91 addr += nfetch * width;
92 bufptr += nfetch * width;
96 unsigned long bufsize = 0;
97 unsigned int chunksize;
108 chunksize = std::min (8u, fetchlimit);
112 nfetch = std::min ((
unsigned long) chunksize, fetchlimit - bufsize);
115 buffer->reset ((gdb_byte *)
xmalloc (nfetch * width));
117 buffer->reset ((gdb_byte *)
xrealloc (buffer->release (),
118 (nfetch + bufsize) * width));
120 bufptr = buffer->get () + bufsize * width;
133 limit = bufptr + nfetch * width;
134 while (bufptr < limit)
136 bool found_nonzero =
false;
138 for (
int i = 0; !found_nonzero && i < width; ++i)
140 found_nonzero =
true;
155 && bufptr - buffer->get () < fetchlimit * width
161 buffer->reset ((gdb_byte *)
xmalloc (1));
162 bufptr = buffer->get ();
168 *bytes_read = bufptr - buffer->get ();
178 gdb::unique_xmalloc_ptr<gdb_byte> buffer;
181 if (bytes_read ==
nullptr)
182 bytes_read = &ignore;
189 return gdb::unique_xmalloc_ptr<char> ((
char *) buffer.release ());
int target_read_string(CORE_ADDR addr, int len, int width, unsigned int fetchlimit, gdb::unique_xmalloc_ptr< gdb_byte > *buffer, int *bytes_read)