From patchwork Fri Jan 20 21:46:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 63534 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7334838A8163 for ; Fri, 20 Jan 2023 21:48:26 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from alt-proxy28.mail.unifiedlayer.com (alt-proxy28.mail.unifiedlayer.com [74.220.216.123]) by sourceware.org (Postfix) with ESMTPS id 8FC3B385828E for ; Fri, 20 Jan 2023 21:46:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8FC3B385828E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway1.mail.pro1.eigbox.com (Postfix) with ESMTP id C48D51003FA98 for ; Fri, 20 Jan 2023 21:46:42 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IzDepfnStNX2aIzDepTG3R; Fri, 20 Jan 2023 21:46:42 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NMAQR22g c=1 sm=1 tr=0 ts=63cb0bc2 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=mamhUVz35NT_mB4T-c0A:9 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:Cc:To:From:Sender:Reply-To: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=l47ZZgWoL08aqu0MZsOPmfp2IjP1Vj609mU5ZmdyDyY=; b=wFxwCobECSykdGolHYRHi4b+kZ 1Zt2ynfM/2UJZMp+OS3Z9+P41u9hLDc2+A/4ne1vbOVdl+Xjrp3yxbpOrWRa0DQUjyrGEF1qsJU1q cIAIOGeFS3EOC8OneYvje2W7f; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:60144 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIzDe-001GNx-Fp; Fri, 20 Jan 2023 14:46:42 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 23/27] Use 'new' for block and global_block Date: Fri, 20 Jan 2023 14:46:14 -0700 Message-Id: <20230120214618.3236224-24-tom@tromey.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120214618.3236224-1-tom@tromey.com> References: <20230120214618.3236224-1-tom@tromey.com> MIME-Version: 1.0 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.76.186 X-Source-L: No X-Exim-ID: 1pIzDe-001GNx-Fp X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:60144 X-Source-Auth: tom+tromey.com X-Email-Count: 24 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.9 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_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" This changes block and global_block to add initializers, and then to use 'new' for allocation. --- gdb/block.c | 6 ++---- gdb/block.h | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/gdb/block.c b/gdb/block.c index 0870793dcd4..8f15cdf23f8 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -389,9 +389,7 @@ block::global_block () const struct block * allocate_block (struct obstack *obstack) { - struct block *bl = OBSTACK_ZALLOC (obstack, struct block); - - return bl; + return new (obstack) struct block; } /* Allocate a global block. */ @@ -399,7 +397,7 @@ allocate_block (struct obstack *obstack) struct block * allocate_global_block (struct obstack *obstack) { - struct global_block *bl = OBSTACK_ZALLOC (obstack, struct global_block); + struct global_block *bl = new (obstack) struct global_block; return &bl->block; } diff --git a/gdb/block.h b/gdb/block.h index 6ccf3766d8f..9a60140581d 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -105,7 +105,7 @@ struct blockranges This implies that within the body of one function the blocks appear in the order of a depth-first tree walk. */ -struct block +struct block : public allocate_on_obstack { /* Return this block's start address. */ CORE_ADDR start () const @@ -273,13 +273,13 @@ struct block /* Addresses in the executable code that are in this block. */ - CORE_ADDR m_start; - CORE_ADDR m_end; + CORE_ADDR m_start = 0; + CORE_ADDR m_end = 0; /* The symbol that names this block, if the block is the body of a function (real or inlined); otherwise, zero. */ - struct symbol *m_function; + struct symbol *m_function = nullptr; /* The `struct block' for the containing block, or 0 if none. @@ -287,22 +287,22 @@ struct block case of C) is the STATIC_BLOCK. The superblock of the STATIC_BLOCK is the GLOBAL_BLOCK. */ - const struct block *m_superblock; + const struct block *m_superblock = nullptr; /* This is used to store the symbols in the block. */ - struct multidictionary *m_multidict; + struct multidictionary *m_multidict = nullptr; /* Contains information about namespace-related info relevant to this block: using directives and the current namespace scope. */ - struct block_namespace_info *m_namespace_info; + struct block_namespace_info *m_namespace_info = nullptr; /* Address ranges for blocks with non-contiguous ranges. If this is NULL, then there is only one range which is specified by startaddr and endaddr above. */ - struct blockranges *m_ranges; + struct blockranges *m_ranges = nullptr; private: @@ -314,7 +314,7 @@ struct block /* The global block is singled out so that we can provide a back-link to the compunit symtab. */ -struct global_block +struct global_block : public allocate_on_obstack { /* The block. */ @@ -322,7 +322,7 @@ struct global_block /* This holds a pointer to the compunit symtab holding this block. */ - struct compunit_symtab *compunit_symtab; + struct compunit_symtab *compunit_symtab = nullptr; }; struct blockvector