From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway34.websitewelcome.com (gateway34.websitewelcome.com [192.185.148.214]) by sourceware.org (Postfix) with ESMTPS id 34574384240B for ; Sun, 28 Feb 2021 20:38:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 34574384240B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway34.websitewelcome.com (Postfix) with ESMTP id B8F5F201830 for ; Sun, 28 Feb 2021 14:38:08 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id GSpMlhRMDiQiZGSpMlueLk; Sun, 28 Feb 2021 14:38:08 -0600 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=p4xQJcdW/T2VT9Hcy4kX+44osF5PCyuO5kyUye71sfg=; b=F6SuG1DufhaiFbyDKYrKgP1KNQ QSEkgk7RhD37XbdyoWNntJSnchKHsmVEThUC1uo2cSdFfjbNLIU3+Zu8uJwDymXJyRCjtNeSuGwTK eKLBf/y2ib42G8bBV084dOxBg; Received: from 97-122-70-152.hlrn.qwest.net ([97.122.70.152]:36730 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1lGSpM-000Xf8-Dw for gdb-patches@sourceware.org; Sun, 28 Feb 2021 13:38:08 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Subject: [PATCH 03/26] Change objfile_has_partial_symbols to a method Date: Sun, 28 Feb 2021 13:37:40 -0700 Message-Id: <20210228203803.1693413-4-tom@tromey.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210228203803.1693413-1-tom@tromey.com> References: <20210228203803.1693413-1-tom@tromey.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.70.152 X-Source-L: No X-Exim-ID: 1lGSpM-000Xf8-Dw X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-70-152.hlrn.qwest.net (localhost.localdomain) [97.122.70.152]:36730 X-Source-Auth: tom+tromey.com X-Email-Count: 4 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3034.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Feb 2021 20:38:10 -0000 This changes objfile_has_partial_symbols to be a method on objfile. There are some other functions that could benefit from this sort of change, but this was the only one that was relevant to this series. gdb/ChangeLog 2021-02-28 Tom Tromey * symfile.c (read_symbols): Update. * objfiles.h (struct objfile) : New method. (objfile_has_partial_symbols): Don't declare. * objfiles.c (objfile::has_partial_symbols): Rename from objfile_has_partial_symbols. (objfile_has_symbols, have_partial_symbols): Update. * elfread.c (elf_symfile_read): Update. * dwarf2/read.c (dwarf2_has_info): Update. * coffread.c (coff_symfile_read): Update. --- gdb/ChangeLog | 12 ++++++++++++ gdb/coffread.c | 2 +- gdb/dwarf2/read.c | 2 +- gdb/elfread.c | 6 +++--- gdb/objfiles.c | 16 ++++++++-------- gdb/objfiles.h | 5 +++-- gdb/symfile.c | 2 +- 7 files changed, 29 insertions(+), 16 deletions(-) diff --git a/gdb/coffread.c b/gdb/coffread.c index d15ba6593fc..badcb5a6084 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -708,7 +708,7 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) dwarf2_build_frame_info (objfile); /* Try to add separate debug file if no symbols table found. */ - if (!objfile_has_partial_symbols (objfile)) + if (!objfile->has_partial_symbols ()) { std::string debugfile = find_separate_debug_file_by_buildid (objfile); diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 3c25f4efba6..02176e8da8f 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -1953,7 +1953,7 @@ dwarf2_has_info (struct objfile *objfile, /* We can share a "dwarf2_per_bfd" with other objfiles if the BFD doesn't require relocations and if there aren't partial symbols from some other reader. */ - if (!objfile_has_partial_symbols (objfile) + if (!objfile->has_partial_symbols () && !gdb_bfd_requires_relocations (objfile->obfd)) { /* See if one has been created for this BFD yet. */ diff --git a/gdb/elfread.c b/gdb/elfread.c index 8f06c8edc79..439f5cc29a0 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -1266,7 +1266,7 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) /* elf_sym_fns_gdb_index cannot handle simultaneous non-DWARF debug information present in OBJFILE. If there is such debug info present never use an index. */ - if (!objfile_has_partial_symbols (objfile) + if (!objfile->has_partial_symbols () && dwarf2_initialize_objfile (objfile, &index_kind)) { switch (index_kind) @@ -1293,14 +1293,14 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) SYMTABS/PSYMTABS. `.gnu_debuglink' may no longer be present with `.note.gnu.build-id'. - .gnu_debugdata is !objfile_has_partial_symbols because it contains only + .gnu_debugdata is !objfile::has_partial_symbols because it contains only .symtab, not .debug_* section. But if we already added .gnu_debugdata as an objfile via find_separate_debug_file_in_section there was no separate debug info available. Therefore do not attempt to search for another one, objfile->separate_debug_objfile->separate_debug_objfile GDB guarantees to be NULL and we would possibly violate it. */ - else if (!objfile_has_partial_symbols (objfile) + else if (!objfile->has_partial_symbols () && objfile->separate_debug_objfile == NULL && objfile->separate_debug_objfile_backlink == NULL) { diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 2a513d82f1a..53ca66d17e6 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -810,23 +810,23 @@ objfile_rebase (struct objfile *objfile, CORE_ADDR slide) breakpoint_re_set (); } -/* Return non-zero if OBJFILE has partial symbols. */ +/* See objfiles.h. */ int -objfile_has_partial_symbols (struct objfile *objfile) +objfile::has_partial_symbols () { - if (!objfile->sf) + if (!sf) return 0; /* If we have not read psymbols, but we have a function capable of reading them, then that is an indication that they are in fact available. Without this function the symbols may have been already read in but they also may not be present in this objfile. */ - if ((objfile->flags & OBJF_PSYMTABS_READ) == 0 - && objfile->sf->sym_read_psymbols != NULL) + if ((flags & OBJF_PSYMTABS_READ) == 0 + && sf->sym_read_psymbols != NULL) return 1; - return objfile->sf->qf->has_symbols (objfile); + return sf->qf->has_symbols (this); } /* Return non-zero if OBJFILE has full symbols. */ @@ -844,7 +844,7 @@ int objfile_has_symbols (struct objfile *objfile) { for (::objfile *o : objfile->separate_debug_objfiles ()) - if (objfile_has_partial_symbols (o) || objfile_has_full_symbols (o)) + if (o->has_partial_symbols () || objfile_has_full_symbols (o)) return 1; return 0; } @@ -859,7 +859,7 @@ have_partial_symbols (void) { for (objfile *ofp : current_program_space->objfiles ()) { - if (objfile_has_partial_symbols (ofp)) + if (ofp->has_partial_symbols ()) return 1; } return 0; diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 052f109db4d..0568e16ae4c 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -548,6 +548,9 @@ struct objfile return per_bfd->gdbarch; } + /* Return true if OBJFILE has partial symbols. */ + + int has_partial_symbols (); /* The object file's original name as specified by the user, made absolute, and tilde-expanded. However, it is not canonicalized @@ -738,8 +741,6 @@ extern void free_objfile_separate_debug (struct objfile *); extern void objfile_relocate (struct objfile *, const section_offsets &); extern void objfile_rebase (struct objfile *, CORE_ADDR); -extern int objfile_has_partial_symbols (struct objfile *objfile); - extern int objfile_has_full_symbols (struct objfile *objfile); extern int objfile_has_symbols (struct objfile *objfile); diff --git a/gdb/symfile.c b/gdb/symfile.c index ec5d34ac783..34d6363a91a 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -775,7 +775,7 @@ read_symbols (struct objfile *objfile, symfile_add_flags add_flags) /* find_separate_debug_file_in_section should be called only if there is single binary with no existing separate debug info file. */ - if (!objfile_has_partial_symbols (objfile) + if (!objfile->has_partial_symbols () && objfile->separate_debug_objfile == NULL && objfile->separate_debug_objfile_backlink == NULL) { -- 2.26.2