aboutsummaryrefslogtreecommitdiff
path: root/gdb/target/target.h
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/target/target.h')
-rw-r--r--gdb/target/target.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/gdb/target/target.h b/gdb/target/target.h
index 818c8c6..a5b0dd3 100644
--- a/gdb/target/target.h
+++ b/gdb/target/target.h
@@ -48,6 +48,37 @@ extern int target_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr,
extern int target_read_uint32 (CORE_ADDR memaddr, uint32_t *result);
+/* Read a string from target memory at address MEMADDR. The string
+ will be at most LEN bytes long (note that excess bytes may be read
+ in some cases -- but these will not be returned). Returns nullptr
+ on error. */
+
+extern gdb::unique_xmalloc_ptr<char> target_read_string
+ (CORE_ADDR memaddr, int len, int *bytes_read = nullptr);
+
+/* Read a string from the inferior, at ADDR, with LEN characters of
+ WIDTH bytes each. Fetch at most FETCHLIMIT characters. BUFFER
+ will be set to a newly allocated buffer containing the string, and
+ BYTES_READ will be set to the number of bytes read. Returns 0 on
+ success, or a target_xfer_status on failure.
+
+ 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
+ failure happened. Check BYTES_READ to recognize this situation. */
+
+extern int target_read_string (CORE_ADDR addr, int len, int width,
+ unsigned int fetchlimit,
+ gdb::unique_xmalloc_ptr<gdb_byte> *buffer,
+ int *bytes_read);
+
/* Write LEN bytes from MYADDR to target memory at address MEMADDR.
Return zero for success, nonzero if any error occurs. This
function must be provided by the client. Implementations of this