aboutsummaryrefslogtreecommitdiff
path: root/gdb/target.h
diff options
context:
space:
mode:
authorGary Benson <gbenson@redhat.com>2015-06-10 14:28:43 +0100
committerGary Benson <gbenson@redhat.com>2015-06-10 14:28:43 +0100
commit07c138c8ae2b11d417c9799202363a95a2d06881 (patch)
treef9e4e351dd13738a439fbf69f75c06b5e9c38dc3 /gdb/target.h
parent12e2a5fdccfc6857c57d2e0a1c1e5fd136a94025 (diff)
downloadgdb-07c138c8ae2b11d417c9799202363a95a2d06881.zip
gdb-07c138c8ae2b11d417c9799202363a95a2d06881.tar.gz
gdb-07c138c8ae2b11d417c9799202363a95a2d06881.tar.bz2
Add "inferior" argument to some target_fileio functions
This commit adds a new argument to all target_fileio functions with filename arguments to allow the desired inferior to be specified. This allows GDB to support systems where processes do not necessarily share a common filesystem. gdb/ChangeLog: * target.h (struct inferior): New forward declaration. (struct target_ops) <to_filesystem_is_local>: Update comment. (struct target_ops) <to_fileio_open>: New argument inf. Update comment. All implementations updated. (struct target_ops) <to_fileio_unlink>: Likewise. (struct target_ops) <to_fileio_readlink>: Likewise. (target_filesystem_is_local): Update comment. (target_fileio_open): New argument inf. Update comment. (target_fileio_unlink): Likewise. (target_fileio_readlink): Likewise. (target_fileio_read_alloc): Likewise. (target_fileio_read_stralloc): Likewise. * target.c (target_fileio_open): New argument inf. Pass inf to implementation. Update debug printing. (target_fileio_unlink): Likewise. (target_fileio_readlink): Likewise. (target_fileio_read_alloc_1): New argument inf. Pass inf to target_fileio_open. (target_fileio_read_alloc): New argument inf. Pass inf to target_fileio_read_alloc_1. (target_fileio_read_stralloc): Likewise. * gdb_bfd.c (inferior.h): New include. (gdb_bfd_iovec_fileio_open): Replace unused "open_closure" argument with new argument "inferior". Pass inferior to target_fileio_open. (gdb_bfd_open): Supply inferior argument to gdb_bfd_iovec_fileio_open. * linux-tdep.c (linux_info_proc): Supply inf argument to relevant target_fileio calls. (linux_find_memory_regions_full): Likewise. (linux_fill_prpsinfo): Likewise. * remote.c (remote_filesystem_is_local): Supply inf argument to remote_hostio_open. (remote_file_put): Likewise. (remote_file_get): Likewise. (remote_file_delete): Supply inf argument to remote_hostio_unlink.
Diffstat (limited to 'gdb/target.h')
-rw-r--r--gdb/target.h106
1 files changed, 67 insertions, 39 deletions
diff --git a/gdb/target.h b/gdb/target.h
index 3a0ae7b..909cc1d 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -38,6 +38,7 @@ struct static_tracepoint_marker;
struct traceframe_info;
struct expression;
struct dcache_struct;
+struct inferior;
#include "infrun.h" /* For enum exec_direction_kind. */
@@ -830,18 +831,19 @@ struct target_ops
/* Target file operations. */
- /* Return nonzero if the filesystem accessed by the
- target_fileio_* methods is the local filesystem,
- zero otherwise. */
+ /* Return nonzero if the filesystem seen by the current inferior
+ is the local filesystem, zero otherwise. */
int (*to_filesystem_is_local) (struct target_ops *)
TARGET_DEFAULT_RETURN (1);
- /* Open FILENAME on the target, using FLAGS and MODE. Return a
- target file descriptor, or -1 if an error occurs (and set
- *TARGET_ERRNO). */
+ /* Open FILENAME on the target, in the filesystem as seen by INF,
+ using FLAGS and MODE. If INF is NULL, use the filesystem seen
+ by the debugger (GDB or, for remote targets, the remote stub).
+ Return a target file descriptor, or -1 if an error occurs (and
+ set *TARGET_ERRNO). */
int (*to_fileio_open) (struct target_ops *,
- const char *filename, int flags, int mode,
- int *target_errno);
+ struct inferior *inf, 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
@@ -867,16 +869,24 @@ struct target_ops
(and set *TARGET_ERRNO). */
int (*to_fileio_close) (struct target_ops *, int fd, int *target_errno);
- /* Unlink FILENAME on the target. Return 0, or -1 if an error
- occurs (and set *TARGET_ERRNO). */
+ /* Unlink FILENAME on the target, in the filesystem as seen by
+ INF. If INF is NULL, use the filesystem seen by the debugger
+ (GDB or, for remote targets, the remote stub). Return 0, or
+ -1 if an error occurs (and set *TARGET_ERRNO). */
int (*to_fileio_unlink) (struct target_ops *,
- const char *filename, int *target_errno);
-
- /* Read value of symbolic link FILENAME on the target. Return a
- null-terminated string allocated via xmalloc, or NULL if an error
- occurs (and set *TARGET_ERRNO). */
+ struct inferior *inf,
+ const char *filename,
+ int *target_errno);
+
+ /* Read value of symbolic link FILENAME on the target, in the
+ filesystem as seen by INF. If INF is NULL, use the filesystem
+ seen by the debugger (GDB or, for remote targets, the remote
+ stub). Return a null-terminated string allocated via xmalloc,
+ or NULL if an error occurs (and set *TARGET_ERRNO). */
char *(*to_fileio_readlink) (struct target_ops *,
- const char *filename, int *target_errno);
+ struct inferior *inf,
+ const char *filename,
+ int *target_errno);
/* Implement the "info proc" command. */
@@ -1935,16 +1945,19 @@ extern int target_search_memory (CORE_ADDR start_addr,
/* Target file operations. */
-/* Return nonzero if the filesystem accessed by the target_fileio_*
- methods is the local filesystem, zero otherwise. */
+/* Return nonzero if the filesystem seen by the current inferior
+ is the local filesystem, zero otherwise. */
#define target_filesystem_is_local() \
current_target.to_filesystem_is_local (&current_target)
-/* 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);
+/* Open FILENAME on the target, in the filesystem as seen by INF,
+ using FLAGS and MODE. If INF is NULL, use the filesystem seen
+ by the debugger (GDB or, for remote targets, the remote stub).
+ Return a target file descriptor, or -1 if an error occurs (and
+ set *TARGET_ERRNO). */
+extern int target_fileio_open (struct inferior *inf,
+ 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
@@ -1968,33 +1981,48 @@ extern int target_fileio_fstat (int fd, struct stat *sb,
(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
+/* Unlink FILENAME on the target, in the filesystem as seen by INF.
+ If INF is NULL, use the filesystem seen by the debugger (GDB or,
+ for remote targets, the remote stub). Return 0, or -1 if an error
occurs (and set *TARGET_ERRNO). */
-extern int target_fileio_unlink (const char *filename, int *target_errno);
-
-/* Read value of symbolic link FILENAME on the target. Return a
- null-terminated string allocated via xmalloc, or NULL if an error
- occurs (and set *TARGET_ERRNO). */
-extern char *target_fileio_readlink (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.
+extern int target_fileio_unlink (struct inferior *inf,
+ const char *filename,
+ int *target_errno);
+
+/* Read value of symbolic link FILENAME on the target, in the
+ filesystem as seen by INF. If INF is NULL, use the filesystem seen
+ by the debugger (GDB or, for remote targets, the remote stub).
+ Return a null-terminated string allocated via xmalloc, or NULL if
+ an error occurs (and set *TARGET_ERRNO). */
+extern char *target_fileio_readlink (struct inferior *inf,
+ const char *filename,
+ int *target_errno);
+
+/* Read target file FILENAME, in the filesystem as seen by INF. If
+ INF is NULL, use the filesystem seen by the debugger (GDB or, for
+ remote targets, the remote stub). 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,
+extern LONGEST target_fileio_read_alloc (struct inferior *inf,
+ const char *filename,
gdb_byte **buf_p);
-/* Read target file FILENAME. The result is NUL-terminated and
+/* Read target file FILENAME, in the filesystem as seen by INF. If
+ INF is NULL, use the filesystem seen by the debugger (GDB or, for
+ remote targets, the remote stub). 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);
+extern char *target_fileio_read_stralloc (struct inferior *inf,
+ const char *filename);
/* Tracepoint-related operations. */