diff options
author | Gary Benson <gbenson@redhat.com> | 2015-06-10 14:28:43 +0100 |
---|---|---|
committer | Gary Benson <gbenson@redhat.com> | 2015-06-10 14:28:43 +0100 |
commit | 07c138c8ae2b11d417c9799202363a95a2d06881 (patch) | |
tree | f9e4e351dd13738a439fbf69f75c06b5e9c38dc3 | |
parent | 12e2a5fdccfc6857c57d2e0a1c1e5fd136a94025 (diff) | |
download | fsf-binutils-gdb-07c138c8ae2b11d417c9799202363a95a2d06881.zip fsf-binutils-gdb-07c138c8ae2b11d417c9799202363a95a2d06881.tar.gz fsf-binutils-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.
-rw-r--r-- | gdb/ChangeLog | 40 | ||||
-rw-r--r-- | gdb/gdb_bfd.c | 9 | ||||
-rw-r--r-- | gdb/inf-child.c | 10 | ||||
-rw-r--r-- | gdb/linux-tdep.c | 25 | ||||
-rw-r--r-- | gdb/remote.c | 18 | ||||
-rw-r--r-- | gdb/target.c | 59 | ||||
-rw-r--r-- | gdb/target.h | 106 |
7 files changed, 179 insertions, 88 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d076e3b..5cbc8d8 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,45 @@ 2015-06-10 Gary Benson <gbenson@redhat.com> + * 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. + +2015-06-10 Gary Benson <gbenson@redhat.com> + * inf-child.c (inf_child_fileio_open): Replace comment. (inf_child_fileio_pwrite): Likewise. (inf_child_fileio_pread): Likewise. diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c index 2cd91ef..1781d80 100644 --- a/gdb/gdb_bfd.c +++ b/gdb/gdb_bfd.c @@ -32,6 +32,7 @@ #endif #include "target.h" #include "gdb/fileio.h" +#include "inferior.h" typedef bfd *bfdp; DEF_VEC_P (bfdp); @@ -213,7 +214,7 @@ fileio_errno_to_host (int errnum) OPEN_CLOSURE is unused. */ static void * -gdb_bfd_iovec_fileio_open (struct bfd *abfd, void *open_closure) +gdb_bfd_iovec_fileio_open (struct bfd *abfd, void *inferior) { const char *filename = bfd_get_filename (abfd); int fd, target_errno; @@ -221,7 +222,8 @@ gdb_bfd_iovec_fileio_open (struct bfd *abfd, void *open_closure) gdb_assert (is_target_filename (filename)); - fd = target_fileio_open (filename + strlen (TARGET_SYSROOT_PREFIX), + fd = target_fileio_open ((struct inferior *) inferior, + filename + strlen (TARGET_SYSROOT_PREFIX), FILEIO_O_RDONLY, 0, &target_errno); if (fd == -1) @@ -327,7 +329,8 @@ gdb_bfd_open (const char *name, const char *target, int fd) gdb_assert (fd == -1); return gdb_bfd_openr_iovec (name, target, - gdb_bfd_iovec_fileio_open, NULL, + gdb_bfd_iovec_fileio_open, + current_inferior (), gdb_bfd_iovec_fileio_pread, gdb_bfd_iovec_fileio_close, gdb_bfd_iovec_fileio_fstat); diff --git a/gdb/inf-child.c b/gdb/inf-child.c index 92134de..0326a93 100644 --- a/gdb/inf-child.c +++ b/gdb/inf-child.c @@ -208,8 +208,8 @@ inf_child_pid_to_exec_file (struct target_ops *self, int pid) static int inf_child_fileio_open (struct target_ops *self, - const char *filename, int flags, int mode, - int *target_errno) + struct inferior *inf, const char *filename, + int flags, int mode, int *target_errno) { int nat_flags; mode_t nat_mode; @@ -318,7 +318,8 @@ inf_child_fileio_close (struct target_ops *self, int fd, int *target_errno) static int inf_child_fileio_unlink (struct target_ops *self, - const char *filename, int *target_errno) + struct inferior *inf, const char *filename, + int *target_errno) { int ret; @@ -333,7 +334,8 @@ inf_child_fileio_unlink (struct target_ops *self, static char * inf_child_fileio_readlink (struct target_ops *self, - const char *filename, int *target_errno) + struct inferior *inf, const char *filename, + int *target_errno) { /* We support readlink only on systems that also provide a compile-time maximum path length (PATH_MAX), at least for now. */ diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index 8ce2f34..f0cdc9c 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -719,7 +719,7 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args, if (cmdline_f) { xsnprintf (filename, sizeof filename, "/proc/%ld/cmdline", pid); - data = target_fileio_read_stralloc (filename); + data = target_fileio_read_stralloc (NULL, filename); if (data) { struct cleanup *cleanup = make_cleanup (xfree, data); @@ -732,7 +732,7 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args, if (cwd_f) { xsnprintf (filename, sizeof filename, "/proc/%ld/cwd", pid); - data = target_fileio_readlink (filename, &target_errno); + data = target_fileio_readlink (NULL, filename, &target_errno); if (data) { struct cleanup *cleanup = make_cleanup (xfree, data); @@ -745,7 +745,7 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args, if (exe_f) { xsnprintf (filename, sizeof filename, "/proc/%ld/exe", pid); - data = target_fileio_readlink (filename, &target_errno); + data = target_fileio_readlink (NULL, filename, &target_errno); if (data) { struct cleanup *cleanup = make_cleanup (xfree, data); @@ -758,7 +758,7 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args, if (mappings_f) { xsnprintf (filename, sizeof filename, "/proc/%ld/maps", pid); - data = target_fileio_read_stralloc (filename); + data = target_fileio_read_stralloc (NULL, filename); if (data) { struct cleanup *cleanup = make_cleanup (xfree, data); @@ -819,7 +819,7 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args, if (status_f) { xsnprintf (filename, sizeof filename, "/proc/%ld/status", pid); - data = target_fileio_read_stralloc (filename); + data = target_fileio_read_stralloc (NULL, filename); if (data) { struct cleanup *cleanup = make_cleanup (xfree, data); @@ -832,7 +832,7 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args, if (stat_f) { xsnprintf (filename, sizeof filename, "/proc/%ld/stat", pid); - data = target_fileio_read_stralloc (filename); + data = target_fileio_read_stralloc (NULL, filename); if (data) { struct cleanup *cleanup = make_cleanup (xfree, data); @@ -1134,7 +1134,8 @@ linux_find_memory_regions_full (struct gdbarch *gdbarch, { xsnprintf (coredumpfilter_name, sizeof (coredumpfilter_name), "/proc/%d/coredump_filter", pid); - coredumpfilterdata = target_fileio_read_stralloc (coredumpfilter_name); + coredumpfilterdata = target_fileio_read_stralloc (NULL, + coredumpfilter_name); if (coredumpfilterdata != NULL) { sscanf (coredumpfilterdata, "%x", &filterflags); @@ -1143,12 +1144,12 @@ linux_find_memory_regions_full (struct gdbarch *gdbarch, } xsnprintf (mapsfilename, sizeof mapsfilename, "/proc/%d/smaps", pid); - data = target_fileio_read_stralloc (mapsfilename); + data = target_fileio_read_stralloc (NULL, mapsfilename); if (data == NULL) { /* Older Linux kernels did not support /proc/PID/smaps. */ xsnprintf (mapsfilename, sizeof mapsfilename, "/proc/%d/maps", pid); - data = target_fileio_read_stralloc (mapsfilename); + data = target_fileio_read_stralloc (NULL, mapsfilename); } if (data != NULL) @@ -1755,7 +1756,7 @@ linux_fill_prpsinfo (struct elf_internal_linux_prpsinfo *p) /* Obtaining PID and filename. */ pid = ptid_get_pid (inferior_ptid); xsnprintf (filename, sizeof (filename), "/proc/%d/cmdline", (int) pid); - fname = target_fileio_read_stralloc (filename); + fname = target_fileio_read_stralloc (NULL, filename); if (fname == NULL || *fname == '\0') { @@ -1788,7 +1789,7 @@ linux_fill_prpsinfo (struct elf_internal_linux_prpsinfo *p) p->pr_psargs[sizeof (p->pr_psargs) - 1] = '\0'; xsnprintf (filename, sizeof (filename), "/proc/%d/stat", (int) pid); - proc_stat = target_fileio_read_stralloc (filename); + proc_stat = target_fileio_read_stralloc (NULL, filename); make_cleanup (xfree, proc_stat); if (proc_stat == NULL || *proc_stat == '\0') @@ -1869,7 +1870,7 @@ linux_fill_prpsinfo (struct elf_internal_linux_prpsinfo *p) /* Finally, obtaining the UID and GID. For that, we read and parse the contents of the `/proc/PID/status' file. */ xsnprintf (filename, sizeof (filename), "/proc/%d/status", (int) pid); - proc_status = target_fileio_read_stralloc (filename); + proc_status = target_fileio_read_stralloc (NULL, filename); make_cleanup (xfree, proc_status); if (proc_status == NULL || *proc_status == '\0') diff --git a/gdb/remote.c b/gdb/remote.c index e6bc3fc..f8682b4 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -10217,8 +10217,8 @@ remote_hostio_send_command (int command_bytes, int which_packet, static int remote_hostio_open (struct target_ops *self, - const char *filename, int flags, int mode, - int *remote_errno) + struct inferior *inf, const char *filename, + int flags, int mode, int *remote_errno) { struct remote_state *rs = get_remote_state (); char *p = rs->buf; @@ -10326,7 +10326,8 @@ remote_hostio_close (struct target_ops *self, int fd, int *remote_errno) static int remote_hostio_unlink (struct target_ops *self, - const char *filename, int *remote_errno) + struct inferior *inf, const char *filename, + int *remote_errno) { struct remote_state *rs = get_remote_state (); char *p = rs->buf; @@ -10345,7 +10346,8 @@ remote_hostio_unlink (struct target_ops *self, static char * remote_hostio_readlink (struct target_ops *self, - const char *filename, int *remote_errno) + struct inferior *inf, const char *filename, + int *remote_errno) { struct remote_state *rs = get_remote_state (); char *p = rs->buf; @@ -10461,7 +10463,7 @@ remote_filesystem_is_local (struct target_ops *self) /* Try opening a file to probe support. The supplied filename is irrelevant, we only care about whether the stub recognizes the packet or not. */ - fd = remote_hostio_open (self, "just probing", + fd = remote_hostio_open (self, NULL, "just probing", FILEIO_O_RDONLY, 0700, &remote_errno); @@ -10581,7 +10583,7 @@ remote_file_put (const char *local_file, const char *remote_file, int from_tty) perror_with_name (local_file); back_to = make_cleanup_fclose (file); - fd = remote_hostio_open (find_target_at (process_stratum), + fd = remote_hostio_open (find_target_at (process_stratum), NULL, remote_file, (FILEIO_O_WRONLY | FILEIO_O_CREAT | FILEIO_O_TRUNC), 0700, &remote_errno); @@ -10667,7 +10669,7 @@ remote_file_get (const char *remote_file, const char *local_file, int from_tty) if (!rs->remote_desc) error (_("command can only be used with remote target")); - fd = remote_hostio_open (find_target_at (process_stratum), + fd = remote_hostio_open (find_target_at (process_stratum), NULL, remote_file, FILEIO_O_RDONLY, 0, &remote_errno); if (fd == -1) remote_hostio_error (remote_errno); @@ -10722,7 +10724,7 @@ remote_file_delete (const char *remote_file, int from_tty) error (_("command can only be used with remote target")); retcode = remote_hostio_unlink (find_target_at (process_stratum), - remote_file, &remote_errno); + NULL, remote_file, &remote_errno); if (retcode == -1) remote_hostio_error (remote_errno); diff --git a/gdb/target.c b/gdb/target.c index c0acaa9..5935716 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -2759,8 +2759,8 @@ release_fileio_fd (int fd, fileio_fh_t *fh) /* See target.h. */ int -target_fileio_open (const char *filename, int flags, int mode, - int *target_errno) +target_fileio_open (struct inferior *inf, const char *filename, + int flags, int mode, int *target_errno) { struct target_ops *t; @@ -2768,7 +2768,8 @@ target_fileio_open (const char *filename, int flags, int mode, { if (t->to_fileio_open != NULL) { - int fd = t->to_fileio_open (t, filename, flags, mode, target_errno); + int fd = t->to_fileio_open (t, inf, filename, flags, mode, + target_errno); if (fd < 0) fd = -1; @@ -2777,7 +2778,9 @@ target_fileio_open (const char *filename, int flags, int mode, if (targetdebug) fprintf_unfiltered (gdb_stdlog, - "target_fileio_open (%s,0x%x,0%o) = %d (%d)\n", + "target_fileio_open (%d,%s,0x%x,0%o)" + " = %d (%d)\n", + inf == NULL ? 0 : inf->num, filename, flags, mode, fd, fd != -1 ? 0 : *target_errno); return fd; @@ -2882,7 +2885,8 @@ target_fileio_close (int fd, int *target_errno) /* See target.h. */ int -target_fileio_unlink (const char *filename, int *target_errno) +target_fileio_unlink (struct inferior *inf, const char *filename, + int *target_errno) { struct target_ops *t; @@ -2890,12 +2894,15 @@ target_fileio_unlink (const char *filename, int *target_errno) { if (t->to_fileio_unlink != NULL) { - int ret = t->to_fileio_unlink (t, filename, target_errno); + int ret = t->to_fileio_unlink (t, inf, filename, + target_errno); if (targetdebug) fprintf_unfiltered (gdb_stdlog, - "target_fileio_unlink (%s) = %d (%d)\n", - filename, ret, ret != -1 ? 0 : *target_errno); + "target_fileio_unlink (%d,%s)" + " = %d (%d)\n", + inf == NULL ? 0 : inf->num, filename, + ret, ret != -1 ? 0 : *target_errno); return ret; } } @@ -2907,7 +2914,8 @@ target_fileio_unlink (const char *filename, int *target_errno) /* See target.h. */ char * -target_fileio_readlink (const char *filename, int *target_errno) +target_fileio_readlink (struct inferior *inf, const char *filename, + int *target_errno) { struct target_ops *t; @@ -2915,11 +2923,14 @@ target_fileio_readlink (const char *filename, int *target_errno) { if (t->to_fileio_readlink != NULL) { - char *ret = t->to_fileio_readlink (t, filename, target_errno); + char *ret = t->to_fileio_readlink (t, inf, filename, + target_errno); if (targetdebug) fprintf_unfiltered (gdb_stdlog, - "target_fileio_readlink (%s) = %s (%d)\n", + "target_fileio_readlink (%d,%s)" + " = %s (%d)\n", + inf == NULL ? 0 : inf->num, filename, ret? ret : "(nil)", ret? 0 : *target_errno); return ret; @@ -2939,14 +2950,16 @@ target_fileio_close_cleanup (void *opaque) target_fileio_close (fd, &target_errno); } -/* Read target file FILENAME. Store the result in *BUF_P and - return the size of the transferred data. PADDING additional bytes are - available in *BUF_P. This is a helper function for - target_fileio_read_alloc; see the declaration of that function for more - information. */ +/* 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). Store the result in *BUF_P and + return the size of the transferred data. PADDING additional bytes + are available in *BUF_P. This is a helper function for + target_fileio_read_alloc; see the declaration of that function for + more information. */ static LONGEST -target_fileio_read_alloc_1 (const char *filename, +target_fileio_read_alloc_1 (struct inferior *inf, const char *filename, gdb_byte **buf_p, int padding) { struct cleanup *close_cleanup; @@ -2956,7 +2969,8 @@ target_fileio_read_alloc_1 (const char *filename, int fd; int target_errno; - fd = target_fileio_open (filename, FILEIO_O_RDONLY, 0700, &target_errno); + fd = target_fileio_open (inf, filename, FILEIO_O_RDONLY, 0700, + &target_errno); if (fd == -1) return -1; @@ -3006,21 +3020,22 @@ target_fileio_read_alloc_1 (const char *filename, /* See target.h. */ LONGEST -target_fileio_read_alloc (const char *filename, gdb_byte **buf_p) +target_fileio_read_alloc (struct inferior *inf, const char *filename, + gdb_byte **buf_p) { - return target_fileio_read_alloc_1 (filename, buf_p, 0); + return target_fileio_read_alloc_1 (inf, filename, buf_p, 0); } /* See target.h. */ char * -target_fileio_read_stralloc (const char *filename) +target_fileio_read_stralloc (struct inferior *inf, const char *filename) { gdb_byte *buffer; char *bufstr; LONGEST i, transferred; - transferred = target_fileio_read_alloc_1 (filename, &buffer, 1); + transferred = target_fileio_read_alloc_1 (inf, filename, &buffer, 1); bufstr = (char *) buffer; if (transferred < 0) 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 (¤t_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. */ |