From patchwork Fri Aug 21 21:22:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 8363 Received: (qmail 111289 invoked by alias); 21 Aug 2015 21:22:21 -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 111280 invoked by uid 89); 21 Aug 2015 21:22:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=AWL, BAYES_00, 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:19 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id E1C3E8E77E for ; Fri, 21 Aug 2015 21:22:17 +0000 (UTC) Received: from host1.jankratochvil.net (ovpn-116-22.ams2.redhat.com [10.36.116.22]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t7LLMGJ8030331 for ; Fri, 21 Aug 2015 17:22:17 -0400 Subject: [PATCH v12 15/32] gdb_bfd_open_from_target: Support real fd From: Jan Kratochvil To: gdb-patches@sourceware.org Date: Fri, 21 Aug 2015 23:22:16 +0200 Message-ID: <20150821212216.6673.80745.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, gdb_bfd_open_from_target is extended so that it can be now passed also some non-(-1) fd. non-(-1) fd was not supported for remote files in mainline. Jan gdb/ChangeLog 2015-08-18 Jan Kratochvil * gdb_bfd.c (gdb_bfd_iovec_fileio_open_fd): New function. (gdb_bfd_open_from_target): Conditionally use it. --- 0 files changed diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c index 10031f8..51395f9 100644 --- a/gdb/gdb_bfd.c +++ b/gdb/gdb_bfd.c @@ -278,6 +278,19 @@ gdb_bfd_iovec_fileio_open (struct bfd *abfd, void *inferior) return stream; } +/* Helper for gdb_bfd_open_from_target when file descriptor is passed as + user data. */ + +static void * +gdb_bfd_iovec_fileio_open_fd (struct bfd *abfd, void *fdp_voidp) +{ + int *stream, *fdp = fdp_voidp; + + stream = XCNEW (int); + *stream = *fdp; + return stream; +} + /* Wrapper for target_fileio_pread suitable for passing as the PREAD_FUNC argument to gdb_bfd_openr_iovec. */ @@ -362,11 +375,12 @@ 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 (), + (fd == -1 ? gdb_bfd_iovec_fileio_open + : gdb_bfd_iovec_fileio_open_fd), + (fd == -1 ? (void *) current_inferior () + : (void *) &fd), gdb_bfd_iovec_fileio_pread, gdb_bfd_iovec_fileio_close, gdb_bfd_iovec_fileio_fstat);