From patchwork Fri Aug 21 21:22:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 8362 Received: (qmail 110524 invoked by alias); 21 Aug 2015 21:22:14 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 110510 invoked by uid 89); 21 Aug 2015 21:22:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL, BAYES_40, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 21 Aug 2015 21:22:12 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 2803F83F92 for ; Fri, 21 Aug 2015 21:22:11 +0000 (UTC) Received: from host1.jankratochvil.net (ovpn-116-22.ams2.redhat.com [10.36.116.22]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t7LLM9s2019270 for ; Fri, 21 Aug 2015 17:22:10 -0400 Subject: [PATCH v12 14/32] Provide new gdb_bfd_open_from_target From: Jan Kratochvil To: gdb-patches@sourceware.org Date: Fri, 21 Aug 2015 23:22:09 +0200 Message-ID: <20150821212209.6673.966.stgit@host1.jankratochvil.net> In-Reply-To: <20150821212006.6673.35100.stgit@host1.jankratochvil.net> References: <20150821212006.6673.35100.stgit@host1.jankratochvil.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-IsSubscribed: yes 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 * 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 diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c index 64712da..10031f8 100644 --- a/gdb/gdb_bfd.c +++ b/gdb/gdb_bfd.c @@ -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); } diff --git a/gdb/gdb_bfd.h b/gdb/gdb_bfd.h index 8fbdf36..0e38d62 100644 --- a/gdb/gdb_bfd.h +++ b/gdb/gdb_bfd.h @@ -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. */