From patchwork Mon Jul 23 14:13:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 28572 Received: (qmail 69867 invoked by alias); 23 Jul 2018 14:14:08 -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 69699 invoked by uid 89); 23 Jul 2018 14:14:06 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=validity, Range, comparing, Validity X-HELO: gateway30.websitewelcome.com Received: from gateway30.websitewelcome.com (HELO gateway30.websitewelcome.com) (192.185.152.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Jul 2018 14:14:04 +0000 Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway30.websitewelcome.com (Postfix) with ESMTP id 423B5AA34 for ; Mon, 23 Jul 2018 09:14:03 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id hbabfcpNkPvAdhbavfh2G0; Mon, 23 Jul 2018 09:14:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: 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=fmbGsU4NWAYUdJsotegdT+xNNBMDQr1Zto7Wuz5dwBA=; b=FxWClJW/ctyFu82uDpx+vLGwSf JLAm02xbpmhqebGA8OBU0Z6MyfHbFdREiQo5By/14EXZ+joqc5pfxv5DgHjsNh0Mz++HvA7p7vAyg TpXIf9V6AK+kNU4Fk5sK3rOlQ; Received: from 75-166-85-72.hlrn.qwest.net ([75.166.85.72]:35152 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1fhbab-001dkE-Ka; Mon, 23 Jul 2018 09:13:29 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA v4 5/6] Add validity bits for psymtab high and low fields Date: Mon, 23 Jul 2018 08:13:25 -0600 Message-Id: <20180723141326.10275-6-tom@tromey.com> In-Reply-To: <20180723141326.10275-1-tom@tromey.com> References: <20180723141326.10275-1-tom@tromey.com> Right now some psymtab code checks whether a psymtab's textlow or texthigh fields are valid by comparing against 0. I imagine this is mildly wrong in the current environment, but once psymtabs are relocated dynamically, it will no longer be correct, because it will be much more normal to see a psymtab with a textlow of zero -- this will just mean it appears at the start of the text section. This patch introduces validity bits to handle this situation more nicely, and changes users of the code to follow. 2018-06-07 Tom Tromey * dbxread.c (end_psymtab): Use text_high_valid and text_low_valid. * mdebugread.c (parse_partial_symbols): Use text_low_valid. (psymtab_to_symtab_1): Use text_high_valid and text_low_valid. * psympriv.h (struct partial_symtab) : Update comment. : New fields. : Update. * xcoffread.c (scan_xcoff_symtab): Use text_low_valid. --- gdb/ChangeLog | 12 ++++++++++++ gdb/dbxread.c | 8 +++----- gdb/mdebugread.c | 8 ++++---- gdb/psympriv.h | 11 ++++++++++- gdb/xcoffread.c | 2 +- 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/gdb/dbxread.c b/gdb/dbxread.c index d5d4e083c5a..5409a727467 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -2002,7 +2002,7 @@ dbx_end_psymtab (struct objfile *objfile, struct partial_symtab *pst, a reliable texthigh by taking the address plus size of the last function in the file. */ - if (pst->text_high () == 0 && last_function_name + if (!pst->text_high_valid && last_function_name && gdbarch_sofun_address_maybe_missing (gdbarch)) { int n; @@ -2047,13 +2047,11 @@ dbx_end_psymtab (struct objfile *objfile, struct partial_symtab *pst, /* If we know our own starting text address, then walk through all other psymtabs for this objfile, and if any didn't know their ending text address, set it to our starting address. Take care to not set our - own ending address to our starting address, nor to set addresses on - `dependency' files that have both textlow and texthigh zero. */ + own ending address to our starting address. */ ALL_OBJFILE_PSYMTABS (objfile, p1) { - if (p1->text_high () == 0 && p1->text_low () != 0 - && p1 != pst) + if (!p1->text_high_valid && p1->text_low_valid && p1 != pst) p1->set_text_high (pst->text_low ()); } } diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 262c619d401..436ef95dd32 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -2736,7 +2736,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, /* Kludge for Irix 5.2 zero fh->adr. */ if (!relocatable - && (pst->text_low () == 0 + && (!pst->text_low_valid || procaddr < pst->text_low ())) pst->set_text_low (procaddr); if (high > pst->text_high ()) @@ -3512,7 +3512,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, /* Kludge for Irix 5.2 zero fh->adr. */ if (!relocatable - && (pst->text_low () == 0 + && (!pst->text_low_valid || procaddr < pst->text_low ())) pst->set_text_low (procaddr); @@ -3711,7 +3711,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, other cases. */ save_pst = fdr_to_pst[f_idx].pst; if (save_pst != NULL - && save_pst->text_low () != 0 + && save_pst->text_low_valid && !(objfile->flags & OBJF_REORDERED)) { ALL_OBJFILE_PSYMTABS (objfile, pst) @@ -3922,7 +3922,7 @@ psymtab_to_symtab_1 (struct objfile *objfile, /* Do nothing if this is a dummy psymtab. */ if (pst->n_global_syms == 0 && pst->n_static_syms == 0 - && pst->text_low () == 0 && pst->text_high () == 0) + && !pst->text_low_valid && !pst->text_high_valid) return; /* Now read the symbols for this symtab. */ diff --git a/gdb/psympriv.h b/gdb/psympriv.h index 7116a1a5957..b3bda82b7b3 100644 --- a/gdb/psympriv.h +++ b/gdb/psympriv.h @@ -114,12 +114,14 @@ struct partial_symtab void set_text_low (CORE_ADDR addr) { m_text_low = addr; + text_low_valid = 1; } /* Set the hight text address of this partial_symtab. */ void set_text_high (CORE_ADDR addr) { m_text_high = addr; + text_high_valid = 1; } @@ -144,7 +146,9 @@ struct partial_symtab /* Range of text addresses covered by this file; texthigh is the beginning of the next section. Do not use if PSYMTABS_ADDRMAP_SUPPORTED is set. Do not refer directly to these fields. Instead, use the - accessors. */ + accessors. The validity of these fields is determined by the + text_low_valid and text_high_valid fields; these are located later + in this structure for better packing. */ CORE_ADDR m_text_low; CORE_ADDR m_text_high; @@ -230,6 +234,11 @@ struct partial_symtab ENUM_BITFIELD (psymtab_search_status) searched_flag : 2; + /* Validity of the m_text_low and m_text_high fields. */ + + unsigned int text_low_valid : 1; + unsigned int text_high_valid : 1; + /* Pointer to compunit eventually allocated for this source file, 0 if !readin or if we haven't looked for the symtab after it was readin. */ diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index 1aa2e523db2..7ca4b3ef3b2 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -2344,7 +2344,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, if (highval > pst->text_high ()) pst->set_text_high (highval); - if (pst->text_low () == 0 + if (!pst->text_low_valid || symbol.n_value < pst->text_low ()) pst->set_text_low (symbol.n_value); }