From patchwork Fri Aug 21 21:22:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 8369 Received: (qmail 115524 invoked by alias); 21 Aug 2015 21:23:05 -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 115425 invoked by uid 89); 21 Aug 2015 21:23:05 -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:02 +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 AB0D48CF7E for ; Fri, 21 Aug 2015 21:23:00 +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 t7LLMx6l019543 for ; Fri, 21 Aug 2015 17:23:00 -0400 Subject: [PATCH v12 21/32] build_id_to_debug_bfd: Make it also non-.debug capable From: Jan Kratochvil To: gdb-patches@sourceware.org Date: Fri, 21 Aug 2015 23:22:59 +0200 Message-ID: <20150821212259.6673.65261.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, generalize the function by adding 'suffix' parameter. To be reused later. Jan gdb/ChangeLog 2015-08-20 Jan Kratochvil * build-id.c (build_id_to_debug_bfd): Rename to ... (build_id_to_bfd): ... here, add parameter suffix. (build_id_to_debug_bfd): New function. --- 0 files changed diff --git a/gdb/build-id.c b/gdb/build-id.c index 0b069fd..8b45fec 100644 --- a/gdb/build-id.c +++ b/gdb/build-id.c @@ -80,10 +80,13 @@ build_id_verify (bfd *abfd, size_t check_len, const bfd_byte *check) return retval; } -/* See build-id.h. */ +/* Find and open a BFD given a build-id. If no BFD can be found, + return NULL. Use "" or ".debug" for SUFFIX. The returned reference to the + BFD must be released by the caller. */ -bfd * -build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id) +static bfd * +build_id_to_bfd (size_t build_id_len, const bfd_byte *build_id, + const char *suffix) { char *link, *debugdir; VEC (char_ptr) *debugdir_vec; @@ -93,7 +96,7 @@ build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id) /* DEBUG_FILE_DIRECTORY/.build-id/ab/cdef */ link = alloca (strlen (debug_file_directory) + (sizeof "/.build-id/" - 1) + 1 - + 2 * build_id_len + (sizeof ".debug" - 1) + 1); + + 2 * build_id_len + strlen (suffix) + 1); /* Keep backward compatibility so that DEBUG_FILE_DIRECTORY being "" will cause "/.build-id/..." lookups. */ @@ -122,7 +125,7 @@ build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id) *s++ = '/'; while (size-- > 0) s += sprintf (s, "%02x", (unsigned) *data++); - strcpy (s, ".debug"); + strcpy (s, suffix); /* lrealpath() is expensive even for the usually non-existent files. */ if (access (link, F_OK) == 0) @@ -152,6 +155,14 @@ build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id) /* See build-id.h. */ +bfd * +build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id) +{ + return build_id_to_bfd (build_id_len, build_id, ".debug"); +} + +/* See build-id.h. */ + char * find_separate_debug_file_by_buildid (struct objfile *objfile) {