[v12,14/32] Provide new gdb_bfd_open_from_target
Commit Message
Hi,
later code needs to call the gdb_bfd_openr_iovec part of gdb_bfd_open with more
special parameters. So it is refactored out first (and extended later in the
next patches).
Jan
gdb/ChangeLog
2015-08-18 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb_bfd.c (gdb_bfd_open_from_target): New function from ...
(gdb_bfd_open): ... here. Call it.
* gdb_bfd.h (gdb_bfd_open_from_target): New prototype.
---
0 files changed
@@ -353,6 +353,25 @@ gdb_bfd_iovec_fileio_fstat (struct bfd *abfd, void *stream,
return result;
}
+/* Open a read-only (FOPEN_RB) BFD using target fileio operations given
+ arguments like bfd_fopen. Return value matches that of
+ gdb_bfd_openr_iovec. */
+
+struct bfd *
+gdb_bfd_open_from_target (const char *name, const char *target, int fd)
+{
+ gdb_assert (is_target_filename (name));
+ gdb_assert (!target_filesystem_is_local ());
+ gdb_assert (fd == -1);
+
+ return gdb_bfd_openr_iovec (name, target,
+ gdb_bfd_iovec_fileio_open,
+ current_inferior (),
+ gdb_bfd_iovec_fileio_pread,
+ gdb_bfd_iovec_fileio_close,
+ gdb_bfd_iovec_fileio_fstat);
+}
+
/* See gdb_bfd.h. */
struct bfd *
@@ -367,16 +386,7 @@ gdb_bfd_open (const char *name, const char *target, int fd)
if (is_target_filename (name))
{
if (!target_filesystem_is_local ())
- {
- gdb_assert (fd == -1);
-
- return gdb_bfd_openr_iovec (name, target,
- gdb_bfd_iovec_fileio_open,
- current_inferior (),
- gdb_bfd_iovec_fileio_pread,
- gdb_bfd_iovec_fileio_close,
- gdb_bfd_iovec_fileio_fstat);
- }
+ return gdb_bfd_open_from_target (name, target, fd);
name += strlen (TARGET_SYSROOT_PREFIX);
}
@@ -53,6 +53,9 @@ int gdb_bfd_has_target_filename (struct bfd *abfd);
struct bfd *gdb_bfd_open (const char *name, const char *target, int fd);
+struct bfd *gdb_bfd_open_from_target (const char *name, const char *target,
+ int fd);
+
/* Increment the reference count of ABFD. It is fine for ABFD to be
NULL; in this case the function does nothing. */