From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 2abcMBFE7WhcES8AWB0awg (envelope-from ) for ; Mon, 13 Oct 2025 14:25:21 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=labware.com header.i=@labware.com header.a=rsa-sha256 header.s=mimecast20220511 header.b=jtf5yiOw; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id C0E021E0B6; Mon, 13 Oct 2025 14:25:21 -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 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 CD9E91E047 for ; Mon, 13 Oct 2025 14:25:20 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DFE3A3858C2D for ; Mon, 13 Oct 2025 18:25:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DFE3A3858C2D Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=labware.com header.i=@labware.com header.a=rsa-sha256 header.s=mimecast20220511 header.b=jtf5yiOw Received: from us-smtp-delivery-114.mimecast.com (us-smtp-delivery-114.mimecast.com [170.10.133.114]) by sourceware.org (Postfix) with ESMTP id 204713858C53 for ; Mon, 13 Oct 2025 18:23:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 204713858C53 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=labware.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=labware.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 204713858C53 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.114 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1760379833; cv=none; b=WSKSqaKOpph5gtT9GJAOo8LgZhz21ODFz02phCnR5bOm53fT+5VBhoYF9FHdf/NZEo5IXkvjWutWYDK5G6LxuOIon+KpcLgcBWeAX+R8cTKCY73iUtWT2e6De8ezpeqMA6WM2hUtrmsed6PKuOXQKI2GV8jRE5P7UVDZhsprb+c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1760379833; c=relaxed/simple; bh=FNiTSEFFzsdOR67Do8k+ggvL38DEPMHem+eF9aYBNKQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=hig3ZZ7rVkXiDYb8syuU7siIIrgYEetQudtaCp1211VsNHyJEhKKKmuM+NMZiiDnZGi/fHEycnYUW2aT5GYqUNbLOhY5LOGByuD6dPnQ915QSzT5FFs/GboraI8pDJv1Cv2jpcgWk6L9R0UXVCH4rCgZyKm8ve14bcJY9awN128= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 204713858C53 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=labware.com; s=mimecast20220511; t=1760379832; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NEncAdqGYpvoKRmr0P1z79KZ/77X7Pxg0LbHvCbln34=; b=jtf5yiOwS/wOpusbV3v6SG1S3EQ2UBGelj54ajqqpSROOJmuCVO4aNpQ46k15WgK3hci2t TJrULaoYUM4mLUtFeuUWbFieIoC5kcBZsgsyD42np24uRP/t8obhhPY9ejlOkbOYa74dDo 22E+b3Jywal13fTevcNqyEFyKp4lZVM= Received: from SN4PR0501CU005.outbound.protection.outlook.com (mail-southcentralusazon11021092.outbound.protection.outlook.com [40.93.194.92]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-44-08pNuEgdOOix5HX7kIaYHw-1; Mon, 13 Oct 2025 14:23:51 -0400 X-MC-Unique: 08pNuEgdOOix5HX7kIaYHw-1 X-Mimecast-MFC-AGG-ID: 08pNuEgdOOix5HX7kIaYHw_1760379830 Received: from SA1PR17MB5365.namprd17.prod.outlook.com (2603:10b6:806:1d8::11) by CH4PR17MB7292.namprd17.prod.outlook.com (2603:10b6:610:231::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9228.9; Mon, 13 Oct 2025 18:23:48 +0000 Received: from SA1PR17MB5365.namprd17.prod.outlook.com ([fe80::9a:538a:fa42:730e]) by SA1PR17MB5365.namprd17.prod.outlook.com ([fe80::9a:538a:fa42:730e%3]) with mapi id 15.20.9228.005; Mon, 13 Oct 2025 18:23:48 +0000 From: Jan Vrany To: gdb-patches@sourceware.org CC: Jan Vrany Subject: [PATCH 2/2] gdb: use std::vector<> to hold on blocks in struct blockvector Date: Mon, 13 Oct 2025 19:23:18 +0100 Message-ID: <20251013182318.1045138-3-jan.vrany@labware.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251013182318.1045138-1-jan.vrany@labware.com> References: <20251013182318.1045138-1-jan.vrany@labware.com> X-ClientProxiedBy: LO4P123CA0178.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18a::21) To SA1PR17MB5365.namprd17.prod.outlook.com (2603:10b6:806:1d8::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR17MB5365:EE_|CH4PR17MB7292:EE_ X-MS-Office365-Filtering-Correlation-Id: b327ae7f-1bfa-4081-6d89-08de0a85a6b2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016 X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?v9WIlMPsu4YWDufMYVeoIcW3kUo1a8RqNoaLSNJkQXwra/xags0GlfZsyQ8u?= =?us-ascii?Q?O4pT8dBAIA1EnFLcDXPTc6sLAaZryopfnOPmUwVTLwACzoSLG2B3AsJtGx1o?= =?us-ascii?Q?3/qrpC4iBAsI5hBVSSuZw8F5xaxldES0tULDLBurRI6SDaSet1dOwvF31uz8?= =?us-ascii?Q?ZnJBVHw76IFaLXkIUW9gvsPj58LS0seo2xaeUvy+QH3pkZ9qugvtara/za9l?= =?us-ascii?Q?QwWTJ+ShZSOfyzWRUEH+j6E0CCmsenctDj7JsHkQx3LaP6xRBQw26sZ5vF5X?= =?us-ascii?Q?6w3ZlBDdebk+Va8MdJFZpXiv9PdNwxcnRVB7pwpRBvlvaV6BGOUUl2jbq4BM?= =?us-ascii?Q?SEzLzy3b1wom0mw2w9Xf3Stf+QibWa9M2mRdzT35pq0ncJp4dY0mS7ZVyyYD?= =?us-ascii?Q?7B9xmQuID7DKldo0Mc8860HLpMe8fZlszvG3guV4FAlMUEmhPHX54HXzjMgU?= =?us-ascii?Q?1AqbIBwIeVCgwMcy8BcTF1n2aDaSsbU6hhV+rtVY4d8XdwCjwEe6+W2HkOop?= =?us-ascii?Q?GHfyknMybo2mDBXxXHdKYIhWZ1YR1Vw7IuckABOn1qUUTn9Io1hmXAZtP6ec?= =?us-ascii?Q?8KexQ8J30KFKZsq7PD1q55ZMHKe83GPQU4WzuaiwYgvg6q9NqNFBWAXlQBet?= =?us-ascii?Q?bHIXrK+NNLHhhDtqPSiX52tz1n3qhEI8QOW962wJkftpXGxG+sFYo9h0YCC2?= =?us-ascii?Q?bt+p05zCt0irRC6RBfmq6FX7U4jxGsXQoBMzMvydcucEZG8BohtsYULMKgMU?= =?us-ascii?Q?X6siilzuR99v0MR4QjML5DHoXmHPpff56ie+ofD8Pdb+OYCpIMerKVF6B/Uw?= =?us-ascii?Q?zJEKWbPTExSurdwlikuVWhDTLBcgwiLX6Qnm6YfroLk9e2dE+s2Lk1COWto/?= =?us-ascii?Q?nSH91zKdEJDe8EhKja1/qQJe2o6zEin8gbwa+Zr1L54X8Nf5c1D9PFNBPNO3?= =?us-ascii?Q?dfthXWAyqk8+aASAB7I1GU6MSdTJtw2BJBvnVz1n6sq9jT5bAXy2ZwVOpq+x?= =?us-ascii?Q?UztgwJ+8hRZAoK+ST7XKi2UoerawTmUNvw2IXW68B91tR3xo57d3l4OMhIbE?= =?us-ascii?Q?j7xGcqa5FzQ93HU5jLdR6wcouQJXvaAd19z1rwco+zP51+qyoGDDv7KkeELR?= =?us-ascii?Q?rdeZuY7+sFuHzEYb3F+1tpHVcoyYGzlNHWEdUC6eH8Xp5KtoVlD6xHBV4fUn?= =?us-ascii?Q?yq9fcDr6uNgJOWuxRrjK1PG2tmh2WDGgBWFhuRiJLpjX6gKyu7/UkzStyHW1?= =?us-ascii?Q?Jx7ey3d7ZcC9mVV4ysR7HVIC6trOu0NavtCXd7guVBDfUCg+yFAz/83EzcS7?= =?us-ascii?Q?xYavFhyixMtL/iRh9uWANnJ1i6teIAiDQvEVUgGKyA3kJMDWTPUiA/cZJvx1?= =?us-ascii?Q?F3fCbv+yxkry8PFdbgSpZupg6als0oMpIMybMVTg5M501KuA2Wc3FWDujM57?= =?us-ascii?Q?lZQQiao6wEjwvIDq9t79io/VH+fdwub8?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SA1PR17MB5365.namprd17.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(1800799024)(366016); DIR:OUT; SFP:1102 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?TeKh55tEn57Z4uzXVAij+0GF7yse/3LLL1bmOSfqJEEqF7/LJGylHqFQ7z+c?= =?us-ascii?Q?k2pQUB45XqtklO7Gws8P0DN2H80QrMcRP5YMYWQjoq6iQMrvUo8waJng6Vv+?= =?us-ascii?Q?2ZAqVKcuemZ4GmGF6inbWzBPrgN7uJuqH4yDZpE/9bISTftZ5nHzG3wbeaQN?= =?us-ascii?Q?zVuQPFXU/Phh5jx2wboAueH4mNi+iywQywknpnBJI/Jv7OgtN31tZ/udXlzQ?= =?us-ascii?Q?6pnjvCnx8btFb400APY0cgCL5OR7NjifPi0mdIqVbCHYaQN0LuctvuDkqFg8?= =?us-ascii?Q?fTP6ZRJAODHiZhNSPJ8uH349ELRZ9kECPcOx9SYoJkG33iGtvMEaesGTLS+O?= =?us-ascii?Q?KIo2E8JNR3nbcFuOo5H81xP7KWdbjSwp/Hp1qx93+XCwDrXL7TI+EcTAlZGv?= =?us-ascii?Q?n3RRWQqej/8xJQxdKdwL1AyvX9pav7wFHp4E/Ij/ruTyQVSQ324HrfBiP+pa?= =?us-ascii?Q?M1bayGAVV4E+YGe2gSgjeAA4Dkh2A2wiwncINADW9U2nmSgWpUdlGFnT1Bm/?= =?us-ascii?Q?R2RiKpvGSkLwFIm1K8jshUV+ZnUD3iLUJcGILm+EDBDTSDb7zx3//yQoIdGy?= =?us-ascii?Q?5IMkI5ccasYIoIiLTxWIYH8V555noT1zo0MPdR6pBWH41Te9foePA0nS8kb/?= =?us-ascii?Q?0wZL1lbu7ZfPQ/7RNHfBYxpCyEp8yVwyxmDSWURhLUvr3XMQK9s0e/9eg+u3?= =?us-ascii?Q?NWIgUPLwNsFHvaw/QdiFJ7ux4vmGGz5mTiYIAJoubEn02P13U526OaPoxX75?= =?us-ascii?Q?m6DS4BggnsmpuUVagz7uNVnSgfwz0iS9ihq6Ct3rJmNSB7QHrKfuetMvKm6v?= =?us-ascii?Q?TBHyScxSfcP5fxOWSoGq8N/YLHpLGGei7hfUI4CZubFkA82y51ETmsdoRJrX?= =?us-ascii?Q?hJ8iaoUn9nPJSTHFSEHDJmhsaNqRCmNQkk5Y3YW76g47W6xPxmdDHmZVyanQ?= =?us-ascii?Q?UDTq+ADmadsMV6/alYGZubvlLbigzrADGhzLFhvXxlvfrP77KmfmJByS8p9N?= =?us-ascii?Q?6Y4nd/JsGda38cnKgJDxbjJCnPtYJiltnXS/nrG81ZZMON0Er3idKlSPXokk?= =?us-ascii?Q?NSGSBRZjhY9mj5oQiMwTIQyiHeL/dZz6JKaKvOri5lS72rEWD8dqafPHSFqJ?= =?us-ascii?Q?gyn0e61IsPYHq7OaJlesLxv9i5FMMjBRkHjenDxSy+yYdgi1FBA2D0cZKMH0?= =?us-ascii?Q?ZqIICHBD/6Ul3xibFRNhhtrBjRvFseNz1rOlpTA/DGuHD8N04rmhxC7nDovb?= =?us-ascii?Q?ML63/lbUQgHCDYvPgjGleku0CWD8qKykSpQeXk0QDpAhAMG+ns8i0vE6WO20?= =?us-ascii?Q?gJP9CDKv/AccWm41CZUvPRlMDqhSV75jo+hnNuiPEifDuJ7CWpF/kZpyvbzg?= =?us-ascii?Q?qFRKw3uJi208l1X8vCDtL/ciawpgKWOGpH6OzbdCltEh1Xp8CNQQnVdSOqiq?= =?us-ascii?Q?Awkmu6W3Spr0W2iJJsITeGavtNouuBliA8GPqYOfo4fzPmFsjTnD5H1xidYz?= =?us-ascii?Q?XOdmPwbGlc4uygnJsVtFy++cNiRYfD92CfLt02OtwvYJiyI7JKW2ofJ36qBg?= =?us-ascii?Q?MY+0CsGm+UUI8ayACivTveZRRcuGbdjNGnzeOKIT?= X-OriginatorOrg: labware.com X-MS-Exchange-CrossTenant-Network-Message-Id: b327ae7f-1bfa-4081-6d89-08de0a85a6b2 X-MS-Exchange-CrossTenant-AuthSource: SA1PR17MB5365.namprd17.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2025 18:23:47.9518 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b5db0322-1aa0-4c0a-859c-ad0f96966f4c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: QiDN7BW23Liv5y62Ke8bbo/8384U6z2o5uli4Q7jbYFaU3ymclMpdJMjtwS4QuENQc3dc14JYXaIv2Fk961fFg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH4PR17MB7292 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: dn2CH_IQvfIGk_Jei8L7ot2UuBjD0MCXDwLXCTXqi3E_1760379830 X-Mimecast-Originator: labware.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=WINDOWS-1252 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 This commit changes internal implementation of struct blockvector to use std::vector<> rather than flexible array, allowing one to easily add blocks to existing blockvector. This is needed to for lazy CU expansion and for Python API to build objfiles, compunits and symtabs dynamically (similarly to JIT reader API). To avoid extensive reallocation when adding a lot of blocks, ctor takes initial number of blocks to be stored in blockvector. While at is, it also adds blockvector::add_block() to add new blocks and changes mdebugread.c to use it. The downside is higher memory consumption. The size of std::vector with obstack allocator is 32 bytes (GCC 14) compared to 8 bytes used currently to store the number of blocks (m_num_blocks). Stopping gdb at its main(), followed by "maint expand-symtabs" results in 4593 compunit symtabs so in this case the overhead is 24*4593 =3D 110232 bytes which I hope is acceptable. --- gdb/block.c | 36 +++++++++++++++++++++++++++++ gdb/block.h | 59 +++++++++++++++++++++++------------------------- gdb/buildsym.c | 2 +- gdb/jit.c | 2 +- gdb/mdebugread.c | 30 +++--------------------- 5 files changed, 69 insertions(+), 60 deletions(-) diff --git a/gdb/block.c b/gdb/block.c index e09bccdcf86..a9191c3fdff 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . = */ =20 +#include #include "block.h" #include "symtab.h" #include "symfile.h" @@ -809,6 +810,41 @@ make_blockranges (struct objfile *objfile, return blr; } =20 +static bool +block_ordering_predicate (struct block *b1, struct block *b2) +{ + CORE_ADDR start1 =3D b1->start (); + CORE_ADDR start2 =3D b2->start (); + + if (start1 !=3D start2) + return start1 < start2; + return (b2->end () < b1->end ()); +} + +/* See block.h. */ + +void +blockvector::add_block (struct block *block) +{ + if (num_blocks () <=3D FIRST_LOCAL_BLOCK) + { + /* No blocks (except global and static block). */ + m_blocks.push_back (block); + } + else + { + /* blockvector already contains some blocks. Insert new block + to a correct place. */ + auto first =3D m_blocks.begin () + FIRST_LOCAL_BLOCK; + auto last =3D m_blocks.end (); + + auto insert_before =3D std::upper_bound (first, last, block, +=09=09=09=09=09 block_ordering_predicate); + + m_blocks.insert (insert_before, block); + } +} + /* Implement 'maint info blocks' command. If passed an argument then print a list of all blocks at the given address. With no arguments then list all blocks at the current address of the current inferior. *= / diff --git a/gdb/block.h b/gdb/block.h index d1ca41d7482..c86650753a4 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -20,6 +20,7 @@ #ifndef GDB_BLOCK_H #define GDB_BLOCK_H =20 +#include #include "dictionary.h" #include "gdbsupport/array-view.h" #include "gdbsupport/next-iterator.h" @@ -420,59 +421,58 @@ struct global_block : public block =20 struct blockvector { - void *operator new (size_t size, size_t num_blocks) - { - size_t size_in_bytes =3D size + (num_blocks - 1) * (sizeof (struct blo= ck *)); - return std::malloc (size_in_bytes); - } - - void operator delete (void *memory) - { - std::free (memory); - } - blockvector (int nblocks) : m_map (nullptr), - m_num_blocks (nblocks) - { - std::memset (m_blocks, 0, nblocks * sizeof (struct block *)); - } + m_blocks (nblocks, nullptr) + {} =20 /* Return a view on the blocks of this blockvector. */ gdb::array_view blocks () { - return gdb::array_view (m_blocks, m_num_blocks); + return gdb::array_view (m_blocks.data (), +=09=09=09=09=09 m_blocks.size ()); } =20 /* Const version of the above. */ gdb::array_view blocks () const { - const struct block **blocks =3D (const struct block **) m_blocks; - return gdb::array_view (blocks, m_num_block= s); + const struct block **blocks =3D (const struct block **) m_blocks.data = (); + return gdb::array_view (blocks, +=09=09=09=09=09=09 m_blocks.size ()); } =20 /* Return the block at index I. */ struct block *block (size_t i) - { return this->blocks ()[i]; } + { + return m_blocks[i]; + } =20 /* Const version of the above. */ const struct block *block (size_t i) const - { return this->blocks ()[i]; } + { + return m_blocks[i]; + } =20 /* Set the block at index I. */ void set_block (int i, struct block *block) { m_blocks[i] =3D block; } =20 - /* Set the number of blocks of this blockvector. - - The storage of blocks is done using a flexible array member, so the n= umber - of blocks set here must agree with what was effectively allocated. *= / - void set_num_blocks (int num_blocks) - { m_num_blocks =3D num_blocks; } + /* Add BLOCK, making sure blocks are ordered by code-addresses + as required. Update global and static block start and end + adresses accordingly. */ + void add_block (struct block *block); =20 /* Return the number of blocks in this blockvector. */ int num_blocks () const - { return m_num_blocks; } + { + return m_blocks.size (); + } + + /* Set the number of blocks of this blockvector. */ + void set_num_blocks (int num_blocks) + { + m_blocks.resize (num_blocks, nullptr); + } =20 /* Return the global block of this blockvector. */ struct global_block *global_block () @@ -511,11 +511,8 @@ struct blockvector enough. */ addrmap_fixed *m_map; =20 - /* Number of blocks in the list. */ - int m_num_blocks; - /* The blocks themselves. */ - struct block *m_blocks[1]; + std::vector m_blocks; }; =20 extern const struct blockvector *blockvector_for_pc (CORE_ADDR, diff --git a/gdb/buildsym.c b/gdb/buildsym.c index a61ef68ada1..8daa68d296b 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -427,7 +427,7 @@ buildsym_compunit::make_blockvector () { } =20 - blockvector =3D new (i) struct blockvector (i); + blockvector =3D new struct blockvector (i); =20 /* Copy the blocks into the blockvector. This is done in reverse order, which happens to put the blocks into the proper order diff --git a/gdb/jit.c b/gdb/jit.c index d95fe542a29..4e3abd1802c 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -553,7 +553,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfil= e *objfile) filetab->set_linetable (new_table); } =20 - bv =3D new (actual_nblocks) blockvector (actual_nblocks); + bv =3D new blockvector (actual_nblocks); cust->set_blockvector (bv); =20 /* At the end of this function, (begin, end) will contain the PC range t= his diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 3cedf0e4fc2..90bbcd81ed2 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -256,8 +256,6 @@ static legacy_psymtab *new_psymtab (const char *, psymt= ab_storage *, static void mdebug_expand_psymtab (legacy_psymtab *pst, =09=09=09=09 struct objfile *objfile); =20 -static void add_block (struct block *, struct symtab *); - static void add_symbol (struct symbol *, struct symtab *, struct block *); =20 static int add_line (struct linetable *, int, CORE_ADDR, int); @@ -808,7 +806,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh= , int bigend, b->set_start (sh->value); b->set_end (sh->value); b->set_superblock (top_stack->cur_block); - add_block (b, top_stack->cur_st); + top_stack->cur_st->compunit ()->blockvector ()->add_block (b); =20 /* Not if we only have partial info. */ if (SC_IS_UNDEF (sh->sc) || sh->sc =3D=3D scNil) @@ -1136,7 +1134,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_= sh, int bigend, b->set_start (sh->value + top_stack->procadr); b->set_superblock (top_stack->cur_block); top_stack->cur_block =3D b; - add_block (b, top_stack->cur_st); + top_stack->cur_st->compunit ()->blockvector ()->add_block (b); break; =20 case stEnd:=09=09/* end (of anything) */ @@ -4492,28 +4490,6 @@ add_symbol (struct symbol *s, struct symtab *symtab,= struct block *b) mdict_add_symbol (b->multidict (), s); } =20 -/* Add a new block B to a symtab S. */ - -static void -add_block (struct block *b, struct symtab *s) -{ - /* Cast away "const", but that's ok because we're building the - symtab and blockvector here. */ - struct blockvector *old_bv - =3D (struct blockvector *) s->compunit ()->blockvector (); - - struct blockvector *new_bv =3D new (old_bv->num_blocks () + 1) - blockvector (old_bv->num_blocks () + 1); - - s->compunit ()->set_blockvector (old_bv); - - for (int i =3D 0; i < old_bv->num_blocks (); i++) - new_bv->set_block (i, old_bv->block (i)); - new_bv->set_block (new_bv->num_blocks () - 1, b); - - delete old_bv; -} - /* Add a new linenumber entry (LINENO,ADR) to a linevector LT. MIPS' linenumber encoding might need more than one byte to describe it, LAST is used to detect these continuation lines. @@ -4635,7 +4611,7 @@ new_symtab (const char *name, int maxlines, struct ob= jfile *objfile) lang =3D cust->language (); =20 /* All symtabs must have at least two blocks. */ - bv =3D new (2) blockvector (2); + bv =3D new blockvector (2); bv->set_block (GLOBAL_BLOCK, new_block (objfile, NON_FUNCTION_BLOCK, lan= g)); bv->set_block (STATIC_BLOCK, new_block (objfile, NON_FUNCTION_BLOCK, lan= g)); bv->static_block ()->set_superblock (bv->global_block ()); --=20 2.51.0