public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Gary Benson <gbenson@redhat.com>
To: gdb-patches@sourceware.org
Cc: "Eli Zaretskii" <eliz@gnu.org>, "Pedro Alves" <palves@redhat.com>,
	"Doug Evans" <dje@google.com>,
	"Iago López Galeiras" <iago@endocode.com>
Subject: [PATCH 5/9 v2] Add "inferior" argument to some target_fileio functions
Date: Thu, 30 Apr 2015 12:06:00 -0000	[thread overview]
Message-ID: <1430395542-16017-6-git-send-email-gbenson@redhat.com> (raw)
In-Reply-To: <1429186791-6867-1-git-send-email-gbenson@redhat.com>

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.
---
 gdb/ChangeLog    |   40 ++++++++++++++++++++
 gdb/gdb_bfd.c    |    9 +++--
 gdb/inf-child.c  |   10 +++--
 gdb/linux-tdep.c |   25 +++++++------
 gdb/remote.c     |   18 +++++----
 gdb/target.c     |   59 +++++++++++++++++++-----------
 gdb/target.h     |  106 ++++++++++++++++++++++++++++++++++--------------------
 7 files changed, 179 insertions(+), 88 deletions(-)

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 181a745..896c154 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;
   int fd;
@@ -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 9d75b66..52b2f0d 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 6820dc8..330fbeb 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -9883,8 +9883,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;
@@ -9992,7 +9992,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;
@@ -10011,7 +10012,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;
@@ -10127,7 +10129,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);
 
@@ -10247,7 +10249,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);
@@ -10333,7 +10335,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);
@@ -10388,7 +10390,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 (&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.  */
-- 
1.7.1

  parent reply	other threads:[~2015-04-30 12:06 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-16 12:19 [PATCH 0/7] GNU/Linux mount namespace support Gary Benson
2015-04-16 12:19 ` [PATCH 4/7] Remove linux_proc_pid_get_ns Gary Benson
2015-04-17  4:36   ` Doug Evans
2015-04-17 13:44     ` Gary Benson
2015-04-16 12:20 ` [PATCH 2/7] Introduce target_fileio_set_fs Gary Benson
2015-04-17  3:04   ` Doug Evans
2015-04-17 13:36     ` Gary Benson
2015-04-17 14:21       ` Pedro Alves
2015-04-17 17:28         ` Doug Evans
2015-04-17 17:46           ` Pedro Alves
2015-04-20 11:11             ` Gary Benson
2015-04-16 12:20 ` [PATCH 1/7] Move make_cleanup_close to common code Gary Benson
2015-04-17  2:47   ` Doug Evans
2015-04-16 12:27 ` [PATCH 6/7] Implement multiple-filesystem support for remote targets Gary Benson
2015-04-16 15:12   ` Eli Zaretskii
2015-04-17 15:06   ` Pedro Alves
2015-04-17 16:00     ` Gary Benson
2015-04-17 16:07       ` Pedro Alves
2015-04-17 16:20         ` Gary Benson
2015-04-17 15:31   ` Pedro Alves
2015-04-17 16:01     ` Gary Benson
2015-04-16 12:34 ` [PATCH 3/7] Introduce nat/linux-namespaces.[ch] Gary Benson
2015-04-17  4:26   ` Doug Evans
2015-04-17 13:41     ` Gary Benson
2015-04-17 14:52   ` Pedro Alves
2015-04-17 17:32     ` Doug Evans
2015-04-20 11:12       ` Gary Benson
2015-04-16 12:54 ` [PATCH 7/7] Implement vFile:setfs in gdbserver Gary Benson
2015-04-17 15:30   ` Pedro Alves
2015-04-17 16:47     ` Gary Benson
2015-04-17 16:29       ` Gary Benson
2015-04-17 17:09         ` Pedro Alves
2015-04-16 13:06 ` [PATCH 5/7] Implement multiple-filesystem support for Linux targets Gary Benson
2015-04-17 15:35 ` [PATCH 0/7] GNU/Linux mount namespace support Pedro Alves
2015-04-20 16:49 ` Iago López Galeiras
2015-04-21  7:56   ` Gary Benson
2015-04-30 12:06 ` [PATCH 6/9 v2] Implement mount namespace support for native Linux targets Gary Benson
2015-04-30 16:24   ` Eli Zaretskii
2015-04-30 18:05     ` Gary Benson
2015-05-21 14:59   ` Pedro Alves
2015-05-27 10:16     ` Gary Benson
2015-04-30 12:06 ` [PATCH 3/9 v2] Remove linux_proc_pid_get_ns Gary Benson
2015-05-21 14:56   ` Pedro Alves
2015-04-30 12:06 ` [PATCH 0/9 v2] GNU/Linux mount namespace support Gary Benson
2015-06-10 14:23   ` [pushed][PATCH " Gary Benson
2015-04-30 12:06 ` Gary Benson [this message]
2015-05-21 14:57   ` [PATCH 5/9 v2] Add "inferior" argument to some target_fileio functions Pedro Alves
2015-04-30 12:15 ` [PATCH 4/9 v2] Comment and whitespace changes Gary Benson
2015-05-21 14:57   ` Pedro Alves
2015-04-30 12:41 ` [PATCH 8/9 v2] Implement vFile:setfs in gdbserver Gary Benson
2015-05-21 15:00   ` Pedro Alves
2015-06-09 14:11     ` Gary Benson
2015-06-09 14:23       ` Pedro Alves
2015-06-10  9:01         ` Gary Benson
2015-06-10  9:41           ` Gary Benson
2015-06-10 14:53             ` Pedro Alves
2015-04-30 12:45 ` [PATCH 2/9 v2] Introduce nat/linux-namespaces.[ch] Gary Benson
     [not found]   ` <20150501000739.740.47967@domU-12-31-39-0A-A0-4F>
2015-05-01  9:28     ` Gary Benson
2015-05-01 13:18       ` Alban Crequy
2015-05-01 20:29         ` Gary Benson
2015-05-06 18:55           ` Alban Crequy
2015-05-07  8:42             ` Gary Benson
2015-05-07 10:39           ` Gary Benson
2015-05-21 14:56   ` Pedro Alves
2015-05-27 10:14     ` Gary Benson
2015-06-11  8:40     ` James Greenhalgh
2015-06-11 11:04       ` Pedro Alves
2015-06-11 12:42         ` [OB PATCH] Use pulongest for printing ssize_t Gary Benson
2015-06-15 15:02   ` [PATCH 2/9 v2] Introduce nat/linux-namespaces.[ch] Michael Eager
2015-06-15 22:12     ` Michael Eager
2015-06-16  8:40       ` Gary Benson
2015-06-16 14:19         ` Michael Eager
2015-06-17  9:51           ` Gary Benson
2016-01-08 10:49   ` Yao Qi
2016-01-11 16:40     ` Gary Benson
2016-01-18 11:44       ` [OB PATCH] Fix gdbserver build failure on targets without fork Gary Benson
2015-04-30 14:12 ` [PATCH 7/9 v2] Implement multiple-filesystem support for remote targets Gary Benson
2015-04-30 17:10   ` Eli Zaretskii
2015-05-21 15:04   ` Pedro Alves
2015-04-30 14:12 ` [PATCH 1/9 v2] Move make_cleanup_close to common code Gary Benson
2015-05-21 14:56   ` Pedro Alves
2015-05-27  9:52     ` Gary Benson
2015-04-30 14:14 ` [PATCH 9/9 v2] Announce new container-awareness features for GNU/Linux systems Gary Benson
2015-04-30 16:20   ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1430395542-16017-6-git-send-email-gbenson@redhat.com \
    --to=gbenson@redhat.com \
    --cc=dje@google.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=iago@endocode.com \
    --cc=palves@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).