From patchwork Thu May 3 22:36:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 27105 Received: (qmail 47962 invoked by alias); 3 May 2018 22:36:30 -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 47824 invoked by uid 89); 3 May 2018 22:36:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 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=packing, adr, 2398, mildly X-HELO: gateway31.websitewelcome.com Received: from gateway31.websitewelcome.com (HELO gateway31.websitewelcome.com) (192.185.143.31) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 03 May 2018 22:36:26 +0000 Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway31.websitewelcome.com (Postfix) with ESMTP id 5AC7417E27 for ; Thu, 3 May 2018 17:36:25 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id EMptfhctoQUwqEMptfR35q; Thu, 03 May 2018 17:36:25 -0500 X-Authority-Reason: nr=8 Received: from 97-122-176-117.hlrn.qwest.net ([97.122.176.117]:51190 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1fEMpt-003rsK-3t; Thu, 03 May 2018 17:36:25 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 5/6] Add validity bits for psymtab high and low fields Date: Thu, 3 May 2018 16:36:20 -0600 Message-Id: <20180503223621.22544-6-tom@tromey.com> In-Reply-To: <20180503223621.22544-1-tom@tromey.com> References: <20180503223621.22544-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1fEMpt-003rsK-3t X-Source-Sender: 97-122-176-117.hlrn.qwest.net (bapiya.Home) [97.122.176.117]:51190 X-Source-Auth: tom+tromey.com X-Email-Count: 6 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes 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. ChangeLog 2018-05-03 Tom Tromey * dbxread.c (end_psymtab): Use texthigh_valid and textlow_valid. * mdebugread.c (parse_partial_symbols): Use textlow_valid. (psymtab_to_symtab_1): Use texthigh_valid and textlow_valid. * psympriv.h (struct partial_symtab) : Update comment. : New fields. (set_psymtab_textlow, set_psymtab_texthigh): New inline functions. (SET_PSYMTAB_TEXTLOW, SET_PSYMTAB_TEXTHIGH): Redefine. * xcoffread.c (scan_xcoff_symtab): Use textlow_valid. --- gdb/ChangeLog | 12 ++++++++++++ gdb/dbxread.c | 6 ++---- gdb/mdebugread.c | 8 ++++---- gdb/psympriv.h | 33 ++++++++++++++++++++++++++++++--- gdb/xcoffread.c | 2 +- 5 files changed, 49 insertions(+), 12 deletions(-) diff --git a/gdb/dbxread.c b/gdb/dbxread.c index 810bdcf57b..da675abb68 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -2100,13 +2100,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 (PSYMTAB_TEXTHIGH (p1) == 0 && PSYMTAB_TEXTLOW (p1) != 0 - && p1 != pst) + if (!p1->texthigh_valid && p1->textlow_valid && p1 != pst) SET_PSYMTAB_TEXTHIGH (p1, PSYMTAB_TEXTLOW (pst)); } } diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 09bdb28088..fb8318a831 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -2764,7 +2764,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, /* Kludge for Irix 5.2 zero fh->adr. */ if (!relocatable - && (PSYMTAB_TEXTLOW (pst) == 0 + && (!pst->textlow_valid || procaddr < PSYMTAB_TEXTLOW (pst))) SET_PSYMTAB_TEXTLOW (pst, procaddr); if (high > PSYMTAB_TEXTHIGH (pst)) @@ -3543,7 +3543,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, /* Kludge for Irix 5.2 zero fh->adr. */ if (!relocatable - && (PSYMTAB_TEXTLOW (pst) == 0 + && (!pst->textlow_valid || procaddr < PSYMTAB_TEXTLOW (pst))) SET_PSYMTAB_TEXTLOW (pst, procaddr); @@ -3742,7 +3742,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, other cases. */ save_pst = fdr_to_pst[f_idx].pst; if (save_pst != NULL - && PSYMTAB_TEXTLOW (save_pst) != 0 + && save_pst->textlow_valid && !(objfile->flags & OBJF_REORDERED)) { ALL_OBJFILE_PSYMTABS (objfile, pst) @@ -3957,7 +3957,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 - && PSYMTAB_TEXTLOW (pst) == 0 && PSYMTAB_TEXTHIGH (pst) == 0) + && !pst->textlow_valid && !pst->texthigh_valid) return; /* Now read the symbols for this symtab. */ diff --git a/gdb/psympriv.h b/gdb/psympriv.h index fa175736ce..8ce3c6b2a9 100644 --- a/gdb/psympriv.h +++ b/gdb/psympriv.h @@ -125,7 +125,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 - accessor macros. */ + accessor macros. The validity of these fields is determined by the + textlow_valid and texthigh_valid fields; these are located later + in this structure for better packing. */ CORE_ADDR textlow_; CORE_ADDR texthigh_; @@ -211,6 +213,11 @@ struct partial_symtab ENUM_BITFIELD (psymtab_search_status) searched_flag : 2; + /* Validity of the textlow_ and texthigh_ fields. */ + + unsigned int textlow_valid : 1; + unsigned int texthigh_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. */ @@ -239,8 +246,28 @@ struct partial_symtab #define PSYMTAB_TEXTLOW(PST) ((PST)->textlow_ + 0) #define PSYMTAB_TEXTHIGH(PST) ((PST)->texthigh_ + 0) -#define SET_PSYMTAB_TEXTLOW(PST, V) (((PST)->textlow_) = (V)) -#define SET_PSYMTAB_TEXTHIGH(PST, V) (((PST)->texthigh_) = (V)) +/* Set the "textlow" field on the partial symbol table, and mark the + field as valid. */ + +static inline void +set_psymtab_textlow (struct partial_symtab *pst, CORE_ADDR low) +{ + pst->textlow_ = low; + pst->textlow_valid = 1; +} + +/* Set the "texthigh" field on the partial symbol table, and mark the + field as valid. */ + +static inline void +set_psymtab_texthigh (struct partial_symtab *pst, CORE_ADDR high) +{ + pst->texthigh_ = high; + pst->texthigh_valid = 1; +} + +#define SET_PSYMTAB_TEXTLOW(PST, V) set_psymtab_textlow ((PST), (V)) +#define SET_PSYMTAB_TEXTHIGH(PST, V) set_psymtab_texthigh ((PST), (V)) /* Add any kind of symbol to a partial_symbol vector. */ diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index 49716a56e5..25df119d51 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -2353,7 +2353,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, if (highval > PSYMTAB_TEXTHIGH (pst)) SET_PSYMTAB_TEXTHIGH (pst, highval); - if (PSYMTAB_TEXTLOW (pst) == 0 + if (!pst->textlow_valid || symbol.n_value < PSYMTAB_TEXTLOW (pst)) SET_PSYMTAB_TEXTLOW (pst, symbol.n_value); }