diff options
author | Ulrich Weigand <uweigand@de.ibm.com> | 2012-01-20 09:45:51 +0000 |
---|---|---|
committer | Ulrich Weigand <uweigand@de.ibm.com> | 2012-01-20 09:45:51 +0000 |
commit | 7313baad7c73664bed62b87481cbb078d71e84f4 (patch) | |
tree | 6b2214e0bc33bb629ea6abd5e4502ec494cc50b2 /gdb/target.h | |
parent | 901f991244d02f62d4e7a9c903de9f05175de2ac (diff) | |
download | gdb-7313baad7c73664bed62b87481cbb078d71e84f4.zip gdb-7313baad7c73664bed62b87481cbb078d71e84f4.tar.gz gdb-7313baad7c73664bed62b87481cbb078d71e84f4.tar.bz2 |
2012-01-20 Pedro Alves <palves@redhat.com>
Ulrich Weigand <ulrich.weigand@linaro.org>
* configure.ac [AC_CHECK_FUNCS]: Check for pread and pwrite.
* config.in, configure: Regenerate.
* target.h (struct target_ops): Add to_fileio_open, to_fileio_pwrite,
to_fileio_pread, to_fileio_close, to_fileio_unlink.
(target_fileio_open): Add prototype.
(target_fileio_pwrite): Likewise.
(target_fileio_pread): Likewise.
(target_fileio_close): Likewise.
(target_fileio_unlink): Likewise.
(target_fileio_read_alloc): Likewise.
(target_fileio_read_stralloc): Likewise.
* target.c: Include "gdb/fileio.h".
(target_read_stralloc): Accept trailing, but not embedded NUL bytes.
(default_fileio_target): New function.
(target_fileio_open): Likewise.
(target_fileio_pwrite): Likewise.
(target_fileio_pread): Likewise.
(target_fileio_close): Likewise.
(target_fileio_unlink): Likewise.
(target_fileio_close_cleanup): Likewise.
(target_fileio_read_alloc_1): Likewise.
(target_fileio_read_alloc): Likewise.
(target_fileio_read_stralloc): Likewise.
* inf-child.c: Include "gdb/fileio.h", <sys/types.h>, <sys/stat.h>,
<fcntl.h>, and <unistd.h>.
(inf_child_fileio_open_flags_to_host): New function.
(inf_child_errno_to_fileio_error): Likewise.
(inf_child_fileio_open): Likewise.
(inf_child_fileio_pwrite): Likewise.
(inf_child_fileio_pread): Likewise.
(inf_child_fileio_close): Likewise.
(inf_child_fileio_unlink): Likewise.
(inf_child_target): Install to_fileio routines.
* remote.c (init_remote_ops): Install to_fileio routines.
Diffstat (limited to 'gdb/target.h')
-rw-r--r-- | gdb/target.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/gdb/target.h b/gdb/target.h index 425c877..4bbf4de 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -681,6 +681,35 @@ struct target_ops struct address_space *(*to_thread_address_space) (struct target_ops *, ptid_t); + /* Target file operations. */ + + /* Open FILENAME on the target, using FLAGS and MODE. Return a + target file descriptor, or -1 if an error occurs (and set + *TARGET_ERRNO). */ + int (*to_fileio_open) (const char *filename, int flags, int mode, + int *target_errno); + + /* Write up to LEN bytes from WRITE_BUF to FD on the target. + Return the number of bytes written, or -1 if an error occurs + (and set *TARGET_ERRNO). */ + int (*to_fileio_pwrite) (int fd, const gdb_byte *write_buf, int len, + ULONGEST offset, int *target_errno); + + /* Read up to LEN bytes FD on the target into READ_BUF. + Return the number of bytes read, or -1 if an error occurs + (and set *TARGET_ERRNO). */ + int (*to_fileio_pread) (int fd, gdb_byte *read_buf, int len, + ULONGEST offset, int *target_errno); + + /* Close FD on the target. Return 0, or -1 if an error occurs + (and set *TARGET_ERRNO). */ + int (*to_fileio_close) (int fd, int *target_errno); + + /* Unlink FILENAME on the target. Return 0, or -1 if an error + occurs (and set *TARGET_ERRNO). */ + int (*to_fileio_unlink) (const char *filename, int *target_errno); + + /* Tracepoint-related operations. */ /* Prepare the target for a tracing run. */ @@ -1489,6 +1518,54 @@ extern int target_search_memory (CORE_ADDR start_addr, ULONGEST pattern_len, CORE_ADDR *found_addrp); +/* Target file operations. */ + +/* Open FILENAME on the target, using FLAGS and MODE. Return a + target file descriptor, or -1 if an error occurs (and set + *TARGET_ERRNO). */ +extern int target_fileio_open (const char *filename, int flags, int mode, + int *target_errno); + +/* Write up to LEN bytes from WRITE_BUF to FD on the target. + Return the number of bytes written, or -1 if an error occurs + (and set *TARGET_ERRNO). */ +extern int target_fileio_pwrite (int fd, const gdb_byte *write_buf, int len, + ULONGEST offset, int *target_errno); + +/* Read up to LEN bytes FD on the target into READ_BUF. + Return the number of bytes read, or -1 if an error occurs + (and set *TARGET_ERRNO). */ +extern int target_fileio_pread (int fd, gdb_byte *read_buf, int len, + ULONGEST offset, int *target_errno); + +/* Close FD on the target. Return 0, or -1 if an error occurs + (and set *TARGET_ERRNO). */ +extern int target_fileio_close (int fd, int *target_errno); + +/* Unlink FILENAME on the target. Return 0, or -1 if an error + occurs (and set *TARGET_ERRNO). */ +extern int target_fileio_unlink (const char *filename, int *target_errno); + +/* Read target file FILENAME. The return value will be -1 if the transfer + fails or is not supported; 0 if the object is empty; or the length + of the object otherwise. If a positive value is returned, a + sufficiently large buffer will be allocated using xmalloc and + returned in *BUF_P containing the contents of the object. + + This method should be used for objects sufficiently small to store + in a single xmalloc'd buffer, when no fixed bound on the object's + size is known in advance. */ +extern LONGEST target_fileio_read_alloc (const char *filename, + gdb_byte **buf_p); + +/* Read target file FILENAME. 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_fileio_read_stralloc (const char *filename); + + /* Tracepoint-related operations. */ #define target_trace_init() \ |