aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdb_bfd.h
diff options
context:
space:
mode:
authorGary Benson <gbenson@redhat.com>2015-04-02 13:38:29 +0100
committerGary Benson <gbenson@redhat.com>2015-04-02 13:38:29 +0100
commitf08e97fed19e0722b6b36e7e638ee86a8aca7db5 (patch)
tree06019cc0794c1a621d978ee3be6fb00f98e7a505 /gdb/gdb_bfd.h
parent4bd7dc42558fcf53bb0c783f852f03dcac38866f (diff)
downloadgdb-f08e97fed19e0722b6b36e7e638ee86a8aca7db5.zip
gdb-f08e97fed19e0722b6b36e7e638ee86a8aca7db5.tar.gz
gdb-f08e97fed19e0722b6b36e7e638ee86a8aca7db5.tar.bz2
Make gdb_bfd_open able to open BFDs using target fileio
This commit updates gdb_bfd_open to access files using target fileio functions if the supplied path starts with "target:" and if the local and target filesystems are not the same. This allows users to specify "set sysroot target:" and have GDB access files locally or from the remote as appropriate. The new functions in gdb_bfd.c are copies of functions from remote.c. This duplication is intentional and will be removed by the next commit in this series. gdb/ChangeLog: * gdb/gdb_bfd.h (TARGET_SYSROOT_PREFIX): New definition. (is_target_filename): New declaration. (gdb_bfd_has_target_filename): Likewise. (gdb_bfd_open): Update documentation comment. * gdb_bfd.c (target.h): New include. (gdb/fileio.h): Likewise. (is_target_filename): New function. (gdb_bfd_has_target_filename): Likewise. (fileio_errno_to_host): Likewise. (gdb_bfd_iovec_fileio_open): Likewise. (gdb_bfd_iovec_fileio_pread): Likewise. (gdb_bfd_iovec_fileio_close): Likewise. (gdb_bfd_iovec_fileio_fstat): Likewise. (gdb_bfd_open): Use target fileio to access paths prefixed with "target:" where necessary.
Diffstat (limited to 'gdb/gdb_bfd.h')
-rw-r--r--gdb/gdb_bfd.h29
1 files changed, 25 insertions, 4 deletions
diff --git a/gdb/gdb_bfd.h b/gdb/gdb_bfd.h
index 05b6870..8fbdf36 100644
--- a/gdb/gdb_bfd.h
+++ b/gdb/gdb_bfd.h
@@ -24,11 +24,32 @@
DECLARE_REGISTRY (bfd);
+/* If supplied a path starting with this sequence, gdb_bfd_open will
+ open BFDs using target fileio operations. */
+
+#define TARGET_SYSROOT_PREFIX "target:"
+
+/* Returns nonzero if NAME starts with TARGET_SYSROOT_PREFIX, zero
+ otherwise. */
+
+int is_target_filename (const char *name);
+
+/* Returns nonzero if the filename associated with ABFD starts with
+ TARGET_SYSROOT_PREFIX, zero otherwise. */
+
+int gdb_bfd_has_target_filename (struct bfd *abfd);
+
/* Open a read-only (FOPEN_RB) BFD given arguments like bfd_fopen.
- Returns NULL on error. On success, returns a new reference to the
- BFD, which must be freed with gdb_bfd_unref. BFDs returned by this
- call are shared among all callers opening the same file. If FD is
- not -1, then after this call it is owned by BFD. */
+ If NAME starts with TARGET_SYSROOT_PREFIX then the BFD will be
+ opened using target fileio operations if necessary. Returns NULL
+ on error. On success, returns a new reference to the BFD, which
+ must be freed with gdb_bfd_unref. BFDs returned by this call are
+ shared among all callers opening the same file. If FD is not -1,
+ then after this call it is owned by BFD. If the BFD was not
+ accessed using target fileio operations then the filename
+ associated with the BFD and accessible with bfd_get_filename will
+ not be exactly NAME but rather NAME with TARGET_SYSROOT_PREFIX
+ stripped. */
struct bfd *gdb_bfd_open (const char *name, const char *target, int fd);