From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway33.websitewelcome.com (gateway33.websitewelcome.com [192.185.146.119]) by sourceware.org (Postfix) with ESMTPS id 80D3C386F442 for ; Sat, 16 May 2020 15:10:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 80D3C386F442 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 cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway33.websitewelcome.com (Postfix) with ESMTP id D9710B7410 for ; Sat, 16 May 2020 10:10:22 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id ZySEjnG30AGTXZySEj2V3Q; Sat, 16 May 2020 10:10:22 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=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: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=iglJPZCUDRiJ7ffgMq1twediv4b+5r+sfdM6CldXDSw=; b=V9AH2cmZ3qD8eBy3Fi8fm6L4vi f7CIG/mxek6oTNTF4XxIncKzkldr9xN57SbkSk083F23+4Jzv9jBQWG6Xi/BkSPjqm+X+cfYFSJPz jKpILaqXfdTHNzFzOHovYepwn; Received: from 174-16-104-48.hlrn.qwest.net ([174.16.104.48]:56264 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1jZySE-0036WG-KX; Sat, 16 May 2020 09:10:22 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Make BLOCK_START and BLOCK_END into rvalues Date: Sat, 16 May 2020 09:10:21 -0600 Message-Id: <20200516151021.7080-1-tom@tromey.com> X-Mailer: git-send-email 2.17.2 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: 174.16.104.48 X-Source-L: No X-Exim-ID: 1jZySE-0036WG-KX X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 174-16-104-48.hlrn.qwest.net (bapiya.Home) [174.16.104.48]:56264 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_STOCKGEN, RCVD_IN_BARRACUDACENTRAL, 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: Sat, 16 May 2020 15:10:26 -0000 This changes the BLOCK_START and BLOCK_END macros to expand to rvalues, and then updates some code to assign to these fields directly. I considered adding setters here, but that seemed a bit needless, given that these are "open" structures. However, I can do that if it's preferable. Note that when the time comes to remove the BLOCK_START and BLOCK_END macros, I think they will be replaced with methods, because that will make it simpler to achieve objfile independence for blocks. This patch is one of a set of small cleanups related to objfile-splitting that I've had kicking around for years. I figured I should start putting them in piecemeal rather than wait for the whole series to be finished, as that seems very difficult. gdb/ChangeLog 2020-05-16 Tom Tromey * mips-tdep.c (mips_make_symbol_special): Update. * objfiles.c (objfile_relocate1): Update. * mdebugread.c (parse_symbol, mdebug_expand_psymtab) (sort_blocks): Update. * jit.c (finalize_symtab): Update. * buildsym.c (buildsym_compunit::finish_block_internal): Update. * block.h (BLOCK_START, BLOCK_END): Expand to rvalue. --- gdb/ChangeLog | 10 ++++++++++ gdb/block.h | 4 ++-- gdb/buildsym.c | 10 +++++----- gdb/jit.c | 8 ++++---- gdb/mdebugread.c | 28 ++++++++++++++-------------- gdb/mips-tdep.c | 2 +- gdb/objfiles.c | 4 ++-- 7 files changed, 38 insertions(+), 28 deletions(-) diff --git a/gdb/block.h b/gdb/block.h index 50ab049f8e6..395f72d1bc9 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -139,8 +139,8 @@ struct global_block struct compunit_symtab *compunit_symtab; }; -#define BLOCK_START(bl) (bl)->startaddr -#define BLOCK_END(bl) (bl)->endaddr +#define BLOCK_START(bl) (((bl)->startaddr) + 0) +#define BLOCK_END(bl) (((bl)->endaddr) + 0) #define BLOCK_FUNCTION(bl) (bl)->function #define BLOCK_SUPERBLOCK(bl) (bl)->superblock #define BLOCK_MULTIDICT(bl) (bl)->multidict diff --git a/gdb/buildsym.c b/gdb/buildsym.c index b9bcc33080a..b13857b0dda 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -242,8 +242,8 @@ buildsym_compunit::finish_block_internal } } - BLOCK_START (block) = start; - BLOCK_END (block) = end; + block->startaddr = start = start; + block->endaddr = end; /* Put the block in as the value of the symbol that names it. */ @@ -329,7 +329,7 @@ buildsym_compunit::finish_block_internal paddress (gdbarch, BLOCK_START (block))); } /* Better than nothing. */ - BLOCK_END (block) = BLOCK_START (block); + block->endaddr = BLOCK_START (block); } /* Install this block as the superblock of all blocks made since the @@ -368,9 +368,9 @@ buildsym_compunit::finish_block_internal paddress (gdbarch, BLOCK_END (block))); } if (BLOCK_START (pblock->block) < BLOCK_START (block)) - BLOCK_START (pblock->block) = BLOCK_START (block); + pblock->block->startaddr = BLOCK_START (block); if (BLOCK_END (pblock->block) > BLOCK_END (block)) - BLOCK_END (pblock->block) = BLOCK_END (block); + pblock->block->endaddr = BLOCK_END (block); } BLOCK_SUPERBLOCK (pblock->block) = block; } diff --git a/gdb/jit.c b/gdb/jit.c index 1b5ef46469e..c099d23e5e2 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -664,8 +664,8 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile) BLOCK_MULTIDICT (new_block) = mdict_create_linear (&objfile->objfile_obstack, NULL); /* The address range. */ - BLOCK_START (new_block) = (CORE_ADDR) gdb_block_iter.begin; - BLOCK_END (new_block) = (CORE_ADDR) gdb_block_iter.end; + new_block->startaddr = (CORE_ADDR) gdb_block_iter.begin; + new_block->endaddr = (CORE_ADDR) gdb_block_iter.end; /* The name. */ SYMBOL_DOMAIN (block_name) = VAR_DOMAIN; @@ -704,8 +704,8 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile) BLOCK_SUPERBLOCK (new_block) = block_iter; block_iter = new_block; - BLOCK_START (new_block) = (CORE_ADDR) begin; - BLOCK_END (new_block) = (CORE_ADDR) end; + new_block->startaddr = (CORE_ADDR) begin; + new_block->endaddr = (CORE_ADDR) end; BLOCKVECTOR_BLOCK (bv, i) = new_block; diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index ba53512636e..2a3f9492897 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -792,7 +792,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, b = new_block (FUNCTION_BLOCK, s->language ()); SYMBOL_BLOCK_VALUE (s) = b; BLOCK_FUNCTION (b) = s; - BLOCK_START (b) = BLOCK_END (b) = sh->value; + b->startaddr = b->endaddr = sh->value; BLOCK_SUPERBLOCK (b) = top_stack->cur_block; add_block (b, top_stack->cur_st); @@ -1121,7 +1121,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, top_stack->blocktype = stBlock; b = new_block (NON_FUNCTION_BLOCK, psymtab_language); - BLOCK_START (b) = sh->value + top_stack->procadr; + b->startaddr = sh->value + top_stack->procadr; BLOCK_SUPERBLOCK (b) = top_stack->cur_block; top_stack->cur_block = b; add_block (b, top_stack->cur_st); @@ -1145,7 +1145,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, struct type *ftype = top_stack->cur_type; int i; - BLOCK_END (top_stack->cur_block) += sh->value; /* size */ + top_stack->cur_block->endaddr += sh->value; /* size */ /* Make up special symbol to contain procedure specific info. */ s = new_symbol (MDEBUG_EFI_SYMBOL_NAME); @@ -1169,8 +1169,8 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, && BLOCK_START (b_bad) == top_stack->procadr && BLOCK_END (b_bad) == top_stack->procadr) { - BLOCK_START (b_bad) = BLOCK_START (cblock); - BLOCK_END (b_bad) = BLOCK_END (cblock); + b_bad->startaddr = BLOCK_START (cblock); + b_bad->endaddr = BLOCK_END (cblock); } } @@ -1211,7 +1211,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, /* End of (code) block. The value of the symbol is the displacement from the procedure`s start address of the end of this block. */ - BLOCK_END (top_stack->cur_block) = sh->value + top_stack->procadr; + top_stack->cur_block->endaddr = sh->value + top_stack->procadr; } else if (sh->sc == scText && top_stack->blocktype == stNil) { @@ -4081,8 +4081,8 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile) top_stack->cur_st = COMPUNIT_FILETABS (cust); top_stack->cur_block = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), STATIC_BLOCK); - BLOCK_START (top_stack->cur_block) = pst->text_low (objfile); - BLOCK_END (top_stack->cur_block) = 0; + top_stack->cur_block->startaddr = pst->text_low (objfile); + top_stack->cur_block->endaddr = 0; top_stack->blocktype = stFile; top_stack->cur_type = 0; top_stack->procadr = 0; @@ -4555,9 +4555,9 @@ sort_blocks (struct symtab *s) { /* Cosmetic */ if (BLOCK_END (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)) == 0) - BLOCK_START (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)) = 0; + BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)->startaddr = 0; if (BLOCK_END (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) == 0) - BLOCK_START (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) = 0; + BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)->endaddr = 0; return; } /* @@ -4578,15 +4578,15 @@ sort_blocks (struct symtab *s) for (i = FIRST_LOCAL_BLOCK; i < j; i++) if (high < BLOCK_END (BLOCKVECTOR_BLOCK (bv, i))) high = BLOCK_END (BLOCKVECTOR_BLOCK (bv, i)); - BLOCK_END (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)) = high; + BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)->endaddr = high; } - BLOCK_START (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)) = + BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)->startaddr = BLOCK_START (BLOCKVECTOR_BLOCK (bv, FIRST_LOCAL_BLOCK)); - BLOCK_START (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) = + BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)->startaddr = BLOCK_START (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)); - BLOCK_END (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) = + BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)->endaddr = BLOCK_END (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)); } diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index df59f416b8e..399b5c0c8d7 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -473,7 +473,7 @@ mips_make_symbol_special (struct symbol *sym, struct objfile *objfile) msym = lookup_minimal_symbol_by_pc (compact_block_start); if (msym.minsym && !msymbol_is_mips (msym.minsym)) { - BLOCK_START (block) = compact_block_start; + block->startaddr = compact_block_start; } } } diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 3aa7973e0d5..a1c6a44145a 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -690,8 +690,8 @@ objfile_relocate1 (struct objfile *objfile, struct mdict_iterator miter; b = BLOCKVECTOR_BLOCK (bv, i); - BLOCK_START (b) += delta[block_line_section]; - BLOCK_END (b) += delta[block_line_section]; + b->startaddr += delta[block_line_section]; + b->endaddr += delta[block_line_section]; if (BLOCK_RANGES (b) != nullptr) for (int j = 0; j < BLOCK_NRANGES (b); j++) -- 2.17.2