From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id yU6iAGwx8WgUNTkAWB0awg (envelope-from ) for ; Thu, 16 Oct 2025 13:54:52 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Rl6wwm12; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id EEB9F1E047; Thu, 16 Oct 2025 13:54:51 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,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 43EF71E047 for ; Thu, 16 Oct 2025 13:54:51 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DC3BD385842E for ; Thu, 16 Oct 2025 17:54:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DC3BD385842E Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Rl6wwm12 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 445B3385828B for ; Thu, 16 Oct 2025 17:50:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 445B3385828B Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 445B3385828B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1760637012; cv=none; b=nD5Jbl9CdOAVV/brt0yDeXD7/6JJsQ7XowMLRP1JpcxIiU56mv6mL70PTx8FtHUir5Pv8zY81QA/Fz23Ro6X+Ucnwax07d9beD3Yz9fgCN7CgsriAOIfEo/UAH4Aeh6HIGCl1L30zIsgdi+6XJp63AkQiFNiGsJmI+ce3B1PeYw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1760637012; c=relaxed/simple; bh=HgAGB9xwGNsEI45dE9e3nJ362ZOhT3rxFstKcFprOic=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=wGxcAkZGeFmRLOktf6qIfRTsfGX+lWX2ZyHG1mTOAd8fKeQC0VOyy5w3n5EE9ozrRRIsl8w+qLwRwZiPEX0qKUBkTIl9Ro5ILhALuVnHyFL0qce4Dcd9TcBMpeJNJr0JtJ7nWev6ftq9WLmPLfyRZuLsS9tM7gJLoRxnH593uMQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 445B3385828B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760637011; 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=RtPJfleLG0ti70Jd6TY26r+KISRZNPft+3X6oyM8Hdw=; b=Rl6wwm122YTi/pV/RFQfQaKfjzU6UHI466Ar6xC9VSch4CCjZDIaOKm2w/FRg1+xGbxtRX t4lCKk+EOns1QifweNd76pIL22DEkgTifgdujouW8v/ZWOdY7dbZC72z3l7tgnyxN0OTRv A+nDdAxr4LFZUPy++AtjZHGC+ODeDxQ= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-299-EO1sEu2mM32ppReCsbbJfw-1; Thu, 16 Oct 2025 13:50:06 -0400 X-MC-Unique: EO1sEu2mM32ppReCsbbJfw-1 X-Mimecast-MFC-AGG-ID: EO1sEu2mM32ppReCsbbJfw_1760637005 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-426feed0016so526729f8f.3 for ; Thu, 16 Oct 2025 10:50:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760637004; x=1761241804; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RtPJfleLG0ti70Jd6TY26r+KISRZNPft+3X6oyM8Hdw=; b=US1FB7pT/Q7U90+HzuR8LD8SkSZdWZH2dsq0NfHuiK75yFlQpRI1/w83WipeSnEt/J 1ORjMy9dqLtPdVekoLPlcP2+g9Gjd2iLcuOxQgbTN/0XzEs5Sy20KwRaBA8525PaVtrC wDHqjW3A5uFt0lxMBJZC+0+M+2L19AHHVmUdPQM+AvvABlV8E6Efz3j4ZECCQwDiDrbV i1CpcfasX743KM3CBlDAvzwqfIz7BtSEfr0/lYuFIac7BxCHfputcM1gLFsFgsCeet0j TT2pucHKh3w4onM6I02hD5aPFxAUO42likAOkZ9wfvOrdNDhs3JQCf4RrdZe0gGb4392 jGUA== X-Gm-Message-State: AOJu0Yyw92gOV6HiUKPNurt5g5hUy8IU2uFmpcYFBzwTCxXYZtOiEowS aK3ThGJz84PD7REhUAcpPv/UBzAxCb/cqxL0YsnFfJEnNAeE+1C/PWqUF+k8JXnMiMwx3VIj26y OJq1sK5Tz/DKccZS7NcjY/o94Bg2QaRvrCQxmTxrmQ4ZivKLFcoMpt73UWbtSIsKrYKolP5RHyI k+QUqwOZZR7M5GhykFWjOKkQEdr445hFEetAQ3IIhdyC2l5iY= X-Gm-Gg: ASbGncsxAdRcL/TfAswW8Vxafr/Nk0c/WAh6g0ZX3jdjH0CYEHufoaR6fp3CQHamAqa +3uoyQh2DWDiKbD0OnRMnihF5lM8ydu9A9yNNd1JahXce/5EadxBCNmwaspg9sQIBtIjQODHzWO dIr5Zu81TwLx5Ib9dwq5eM3wpyVsVYccI6j/tcX9/5p/DBajA2kN3Cbw7DBftudeOdPvZ9f1s6o j7hkZ5dbizKmrX2naYc1L4If2CSYleXTnUAxndQB6ZivVhMoP7BSZ5FIrbLSV21Vw7qkB15CsgG 2Ikz60pKjhnhDj0vwpFKiJLApR8Qkgc1rpOpQgHHVksTIRgxMy0rwnIKnBnxI7lRufM6RA== X-Received: by 2002:a05:6000:2c05:b0:3ce:bf23:3c32 with SMTP id ffacd0b85a97d-42704d551c2mr780159f8f.22.1760637004596; Thu, 16 Oct 2025 10:50:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFcBoFb6i1bAN1o9tTRKNOoifZmcq9oaN7SpXV6gjgTPBYBySGhIi4OYKYaEA24mSUmHwkS+w== X-Received: by 2002:a05:6000:2c05:b0:3ce:bf23:3c32 with SMTP id ffacd0b85a97d-42704d551c2mr780132f8f.22.1760637004050; Thu, 16 Oct 2025 10:50:04 -0700 (PDT) Received: from localhost ([31.111.84.207]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426e50ef821sm21822826f8f.38.2025.10.16.10.50.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Oct 2025 10:50:03 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv3 5/7] gdb: create address map after parsing all DIE Date: Thu, 16 Oct 2025 18:49:51 +0100 Message-ID: X-Mailer: git-send-email 2.47.1 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 3wznCmLp2wPytbtgvp4A5xQQYc8xKIzRRJhw4A7aPBM_1760637005 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true 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 Continuing the work done in the last two commits, this commit defers building the addrmap for a blockvector until after all the DIE have been read, and the line table processed. The benefit of this is that any changes to a block's ranges done during line table processing (see the next commit) will be reflected in the blockvector's addrmap. The alternative to this is to build the addrmap as we initially see each block, but then adjust the addrmap if we later decide to modify a block. I think defering the addrmap creation is cleaner, and is less work overall. The addrmap requires that we add the most inner blocks first. I achieve this by walking the blockvector backward, as we always add parent blocks before their more inner child blocks. There should be no user visible changes after this commit. --- gdb/buildsym.c | 42 +++++++++++++++++++++++++++++++++++++----- gdb/buildsym.h | 13 ++++--------- 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 2a8e95e078b..6c46d75621b 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -410,8 +410,6 @@ buildsym_compunit::record_block_range (struct block *block, if (start != block->start () || end_inclusive + 1 != block->end ()) m_pending_addrmap_interesting = true; - - m_pending_addrmap.set_empty (start, end_inclusive, block); } struct blockvector * @@ -447,9 +445,43 @@ buildsym_compunit::make_blockvector () /* If we needed an address map for this symtab, record it in the blockvector. */ if (m_pending_addrmap_interesting) - blockvector->set_map - (new (&m_objfile->objfile_obstack) addrmap_fixed - (&m_objfile->objfile_obstack, &m_pending_addrmap)); + { + struct addrmap_mutable pending_addrmap; + int num_blocks = blockvector->num_blocks (); + + /* If M_PENDING_ADDRMAP_INTERESTING is true then we must have seen + an interesting block. If we see one block, then we should at a + minimum have a global block, and a static block. */ + gdb_assert (num_blocks > 1); + + /* Assert our understanding of how the blocks are laid out. */ + gdb_assert (blockvector->block (0)->is_global_block ()); + gdb_assert (blockvector->block (1)->is_static_block ()); + + /* The 'J > 1' here is so that we don't place the global block into + the map. For CU with gaps, the static block will reflect the + gaps, while the global block will just reflect the full extent of + the range. */ + for (int j = num_blocks; j > 1; ) + { + --j; + struct block *b = blockvector->block (j); + + gdb_assert (!b->is_global_block ()); + + if (b->is_contiguous ()) + pending_addrmap.set_empty (b->start (), (b->end () - 1), b); + else + { + for (const auto &br : b->ranges ()) + pending_addrmap.set_empty (br.start (), (br.end () - 1), b); + } + } + + blockvector->set_map + (new (&m_objfile->objfile_obstack) addrmap_fixed + (&m_objfile->objfile_obstack, &pending_addrmap)); + } else blockvector->set_map (nullptr); diff --git a/gdb/buildsym.h b/gdb/buildsym.h index 5d4b582349a..0ce460b0448 100644 --- a/gdb/buildsym.h +++ b/gdb/buildsym.h @@ -421,15 +421,10 @@ struct buildsym_compunit struct subfile *m_current_subfile = nullptr; - /* The mutable address map for the compilation unit whose symbols - we're currently reading. The symtabs' shared blockvector will - point to a fixed copy of this. */ - struct addrmap_mutable m_pending_addrmap; - - /* True if we recorded any ranges in the addrmap that are different - from those in the blockvector already. We set this to false when - we start processing a symfile, and if it's still false at the - end, then we just toss the addrmap. */ + /* If there are gaps in the address range of any block associated with + this buildsym_compunit, then we need to create an address map, this + flag is set true to indicate the addrmap must be created. If this + remains false, then no addrmap will be created. */ bool m_pending_addrmap_interesting = false; /* An obstack used for allocating pending blocks. */ -- 2.47.1