summaryrefslogtreecommitdiff
path: root/gdb/target.h
diff options
context:
space:
mode:
authorUlrich Weigand <uweigand@de.ibm.com>2012-01-20 09:45:49 +0000
committerUlrich Weigand <uweigand@de.ibm.com>2012-01-20 09:45:49 +0000
commite275619a2e8d64964b675b0e85bb7c69e2a7dad0 (patch)
tree623ae67bab63c8a8451ab63f4f172f08c690453b /gdb/target.h
parentf8cdeea569d34d96c29b22f12dcc0c82bef1bd5a (diff)
downloadgdb-e275619a2e8d64964b675b0e85bb7c69e2a7dad0.tar.gz
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.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/gdb/target.h b/gdb/target.h
index 425c877077c..4bbf4de88d1 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() \