mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-05-28 22:21:26 +08:00
* target.h (target_read_stralloc): New prototype.
* target.c (target_read_alloc_1): Renamed from target_read_alloc. Take new PADDING argument. (target_read_alloc): Use it. (target_read_stralloc): New function.
This commit is contained in:
@ -1,3 +1,11 @@
|
|||||||
|
2006-07-27 Daniel Jacobowitz <dan@codesourcery.com>
|
||||||
|
|
||||||
|
* target.h (target_read_stralloc): New prototype.
|
||||||
|
* target.c (target_read_alloc_1): Renamed from target_read_alloc.
|
||||||
|
Take new PADDING argument.
|
||||||
|
(target_read_alloc): Use it.
|
||||||
|
(target_read_stralloc): New function.
|
||||||
|
|
||||||
2006-07-26 Daniel Jacobowitz <dan@codesourcery.com>
|
2006-07-26 Daniel Jacobowitz <dan@codesourcery.com>
|
||||||
|
|
||||||
* remote.c (remote_protocol_features): Correct qPart to qXfer.
|
* remote.c (remote_protocol_features): Correct qPart to qXfer.
|
||||||
|
66
gdb/target.c
66
gdb/target.c
@ -1406,22 +1406,15 @@ target_write (struct target_ops *ops,
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wrapper to perform a full read of unknown size. OBJECT/ANNEX will
|
/* Read OBJECT/ANNEX using OPS. Store the result in *BUF_P and return
|
||||||
be read using OPS. The return value will be -1 if the transfer
|
the size of the transferred data. PADDING additional bytes are
|
||||||
fails or is not supported; 0 if the object is empty; or the length
|
available in *BUF_P. This is a helper function for
|
||||||
of the object otherwise. If a positive value is returned, a
|
target_read_alloc; see the declaration of that function for more
|
||||||
sufficiently large buffer will be allocated using xmalloc and
|
information. */
|
||||||
returned in *BUF_P containing the contents of the object.
|
|
||||||
|
|
||||||
This method should be used for objects sufficiently small to store
|
static LONGEST
|
||||||
in a single xmalloc'd buffer, when no fixed bound on the object's
|
target_read_alloc_1 (struct target_ops *ops, enum target_object object,
|
||||||
size is known in advance. Don't try to read TARGET_OBJECT_MEMORY
|
const char *annex, gdb_byte **buf_p, int padding)
|
||||||
through this function. */
|
|
||||||
|
|
||||||
LONGEST
|
|
||||||
target_read_alloc (struct target_ops *ops,
|
|
||||||
enum target_object object,
|
|
||||||
const char *annex, gdb_byte **buf_p)
|
|
||||||
{
|
{
|
||||||
size_t buf_alloc, buf_pos;
|
size_t buf_alloc, buf_pos;
|
||||||
gdb_byte *buf;
|
gdb_byte *buf;
|
||||||
@ -1442,7 +1435,7 @@ target_read_alloc (struct target_ops *ops,
|
|||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
n = target_read_partial (ops, object, annex, &buf[buf_pos],
|
n = target_read_partial (ops, object, annex, &buf[buf_pos],
|
||||||
buf_pos, buf_alloc - buf_pos);
|
buf_pos, buf_alloc - buf_pos - padding);
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
{
|
{
|
||||||
/* An error occurred. */
|
/* An error occurred. */
|
||||||
@ -1472,6 +1465,47 @@ target_read_alloc (struct target_ops *ops,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Read OBJECT/ANNEX using OPS. Store the result in *BUF_P and return
|
||||||
|
the size of the transferred data. See the declaration in "target.h"
|
||||||
|
function for more information about the return value. */
|
||||||
|
|
||||||
|
LONGEST
|
||||||
|
target_read_alloc (struct target_ops *ops, enum target_object object,
|
||||||
|
const char *annex, gdb_byte **buf_p)
|
||||||
|
{
|
||||||
|
return target_read_alloc_1 (ops, object, annex, buf_p, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read OBJECT/ANNEX using OPS. The result is NUL-terminated and
|
||||||
|
returned as a string, allocated using xmalloc. If an error occurs
|
||||||
|
or the transfer is unsupported, NULL is returned. Empty objects
|
||||||
|
are returned as allocated but empty strings. A warning is issued
|
||||||
|
if the result contains any embedded NUL bytes. */
|
||||||
|
|
||||||
|
char *
|
||||||
|
target_read_stralloc (struct target_ops *ops, enum target_object object,
|
||||||
|
const char *annex)
|
||||||
|
{
|
||||||
|
gdb_byte *buffer;
|
||||||
|
LONGEST transferred;
|
||||||
|
|
||||||
|
transferred = target_read_alloc_1 (ops, object, annex, &buffer, 1);
|
||||||
|
|
||||||
|
if (transferred < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (transferred == 0)
|
||||||
|
return xstrdup ("");
|
||||||
|
|
||||||
|
buffer[transferred] = 0;
|
||||||
|
if (strlen (buffer) < transferred)
|
||||||
|
warning (_("target object %d, annex %s, "
|
||||||
|
"contained unexpected null characters"),
|
||||||
|
(int) object, annex ? annex : "(none)");
|
||||||
|
|
||||||
|
return (char *) buffer;
|
||||||
|
}
|
||||||
|
|
||||||
/* Memory transfer methods. */
|
/* Memory transfer methods. */
|
||||||
|
|
||||||
void
|
void
|
||||||
|
10
gdb/target.h
10
gdb/target.h
@ -236,6 +236,16 @@ extern LONGEST target_read_alloc (struct target_ops *ops,
|
|||||||
enum target_object object,
|
enum target_object object,
|
||||||
const char *annex, gdb_byte **buf_p);
|
const char *annex, gdb_byte **buf_p);
|
||||||
|
|
||||||
|
/* Read OBJECT/ANNEX using OPS. The result is NUL-terminated and
|
||||||
|
returned as a string, allocated using xmalloc. If an error occurs
|
||||||
|
or the transfer is unsupported, NULL is returned. Empty objects
|
||||||
|
are returned as allocated but empty strings. A warning is issued
|
||||||
|
if the result contains any embedded NUL bytes. */
|
||||||
|
|
||||||
|
extern char *target_read_stralloc (struct target_ops *ops,
|
||||||
|
enum target_object object,
|
||||||
|
const char *annex);
|
||||||
|
|
||||||
/* Wrappers to target read/write that perform memory transfers. They
|
/* Wrappers to target read/write that perform memory transfers. They
|
||||||
throw an error if the memory transfer fails.
|
throw an error if the memory transfer fails.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user