From patchwork Fri Aug 21 21:23:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 8374 Received: (qmail 119322 invoked by alias); 21 Aug 2015 21:23:40 -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 119306 invoked by uid 89); 21 Aug 2015 21:23:40 -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:23:39 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id AA3958E4F4 for ; Fri, 21 Aug 2015 21:23:37 +0000 (UTC) Received: from host1.jankratochvil.net (ovpn-116-22.ams2.redhat.com [10.36.116.22]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t7LLNaHM032632 for ; Fri, 21 Aug 2015 17:23:37 -0400 Subject: [PATCH v12 26/32] solib_bfd_open: Optimize opening twice From: Jan Kratochvil To: gdb-patches@sourceware.org Date: Fri, 21 Aug 2015 23:23:36 +0200 Message-ID: <20150821212336.6673.18922.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, this is one of the optimizations allowed by file_location that prevents opening file twice when target build-id is known and it needs to be verified. Jan gdb/ChangeLog 2015-08-20 Jan Kratochvil * solib.c (solib_bfd_fopen): Replace solib_find and solib_bfd_fopen by solib_find_file. --- 0 files changed diff --git a/gdb/solib.c b/gdb/solib.c index a425e4d..906cc5c 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -620,25 +620,30 @@ solib_bfd_fopen (char *pathname, int fd) bfd * solib_bfd_open (char *pathname, size_t build_idsz, const gdb_byte *build_id) { - char *found_pathname; - int found_file; + struct file_location file; bfd *abfd; const struct bfd_arch_info *b; /* Search for shared library file. */ - found_pathname = solib_find (pathname, build_idsz, build_id, &found_file); - if (found_pathname == NULL) + file = solib_find_file (pathname, OPF_IS_BFD, build_idsz, build_id); + if (!file_location_is_valid (&file)) { /* Return failure if the file could not be found, so that we can accumulate messages about missing libraries. */ - if (errno == ENOENT) - return NULL; + if (file.file_errno == ENOENT) + { + file_location_free (&file); + return NULL; + } + file_location_free (&file); perror_with_name (pathname); } /* Open bfd for shared library. */ - abfd = solib_bfd_fopen (found_pathname, found_file); + gdb_bfd_ref (file.abfd); + abfd = file.abfd; + file_location_free (&file); /* Check bfd format. */ if (!bfd_check_format (abfd, bfd_object))