From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id qPZ4NICZ7mguPDIAWB0awg (envelope-from ) for ; Tue, 14 Oct 2025 14:42:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1760467328; bh=lleK+XT/FVUSxqdIkOWITeNGFx/DtrqftWuk4r4Y5YI=; h=Date:Subject:To:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=BtqFfRtOR6h/TXYInLJuSUG1heFrY6dWA4Qoyhbr0phxuNxPYqzpaT+ofTpBo0Heh Tvmd25JXMw2GSeLiF3KkxVXYPoTcJWUIAT/DZVBw+2kDWnAcRt5Rm/205M0YrWukp9 ppDg97Spps/zC+7268eEQS0lYLtuzLrpcOAsQivs= Received: by simark.ca (Postfix, from userid 112) id C4E201E0B6; Tue, 14 Oct 2025 14:42:08 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=Zo3GaSF9; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 09E491E047 for ; Tue, 14 Oct 2025 14:42:08 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9E728385841E for ; Tue, 14 Oct 2025 18:42:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9E728385841E Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=Zo3GaSF9 Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id BE8C13858D35 for ; Tue, 14 Oct 2025 18:41:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BE8C13858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BE8C13858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1760467293; cv=none; b=ZYlHbD506jj/+3AYBF8kf6RxgfD19FzJpHCuA4RCpYPRpoN3NoH6z64wlrTtZKLWB3oXsdyCx5o/eUX2MeEgXP4hGuChevJOiF1AdSIatmU6AhJyiaYHd5tUZWyHK3I9RMqpafG34Ix/muD0d9t6+xVcnDWMxaKwZ1thzgG/vGg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1760467293; c=relaxed/simple; bh=lleK+XT/FVUSxqdIkOWITeNGFx/DtrqftWuk4r4Y5YI=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=x8B1QmOFC8xH+i+1ij1kC8NP3qa3FbM/EC1NkYuQgPpDL40+l+32kJ68NJ3tbbZ7rvB1C6i8ial2SMcWA1RzaGe5Dr8zjNuxbOrpfLwWZZrhspC81X6otozxIfenrN97ntj567/bCmXhgiPNX97k2YLqiLR2S+fOa7IFD5Ow8o4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BE8C13858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1760467293; bh=lleK+XT/FVUSxqdIkOWITeNGFx/DtrqftWuk4r4Y5YI=; h=Date:Subject:To:References:From:In-Reply-To:From; b=Zo3GaSF9qIJ9Xw/1HIaDfSlBpvDt+0g+Gf4p9tDP/Ac5Tv3qzaPnaW7s1nv1bVsTq e8qbwfWpukZDMeINRmmkRG9Dwutv+tIG0FIQIUiDokjJZf0F8CoRF9pSbuzAUX9W4T 1qsBZjR7xRzVQDSaWavBhImtsVr2udRyvu6VxTSs= Received: by simark.ca (Postfix) id 21D661E047; Tue, 14 Oct 2025 14:41:33 -0400 (EDT) Message-ID: <4178904d-9d3e-406d-9446-9ca2ce8b4a8d@simark.ca> Date: Tue, 14 Oct 2025 14:41:32 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/2] gdb: allocate blockvector on heap To: Jan Vrany , gdb-patches@sourceware.org References: <20251013182318.1045138-1-jan.vrany@labware.com> <20251013182318.1045138-2-jan.vrany@labware.com> Content-Language: fr From: Simon Marchi In-Reply-To: <20251013182318.1045138-2-jan.vrany@labware.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 10/13/25 2:23 PM, Jan Vrany wrote: > This patch changes blockvector to be allocated on the heap, using > 'new'. > > The code is little awkward since blockvector uses flexible array member > to hold on blocks. So in order to make it working, this commit overloads > 'new' and 'delete' operators to take the number of blocks as parameter > and allocates/deallocates memory using std::malloc and std::free. > This will go away in following commit that will change blockvector to > use std::vector rather than flexible array member. It's already written, so if it works, I don't mind, but otherwise I think you could have made the switch to 'new' and to std::vector in the same patch, since they are not very large changes. > --- > gdb/block.h | 18 ++++++++++++++++++ > gdb/buildsym.c | 5 +---- > gdb/jit.c | 8 +------- > gdb/mdebugread.c | 38 +++++++++++--------------------------- > 4 files changed, 31 insertions(+), 38 deletions(-) > > diff --git a/gdb/block.h b/gdb/block.h > index 8a3ea822d04..d1ca41d7482 100644 > --- a/gdb/block.h > +++ b/gdb/block.h > @@ -420,6 +420,24 @@ struct global_block : public block > > struct blockvector > { > + void *operator new (size_t size, size_t num_blocks) > + { > + size_t size_in_bytes = size + (num_blocks - 1) * (sizeof (struct block *)); > + return std::malloc (size_in_bytes); > + } > + > + void operator delete (void *memory) > + { > + std::free (memory); > + } > + > + blockvector (int nblocks) explicit > + : m_map (nullptr), Can you initialize m_map inline? addrmap_fixed *m_map = nullptr; Otherwise, LGTM. Approved-By: Simon Marchi Simon