From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id yKQuCieDjGiifgEAWB0awg (envelope-from ) for ; Fri, 01 Aug 2025 05:04:39 -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=WVXQhQpd; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 25A7D1E102; Fri, 1 Aug 2025 05:04:39 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-10.1 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, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE 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 A6BC01E089 for ; Fri, 1 Aug 2025 05:04:38 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 50A603858D1E for ; Fri, 1 Aug 2025 09:04:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 50A603858D1E 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=WVXQhQpd 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 92AFC385840E for ; Fri, 1 Aug 2025 08:58:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 92AFC385840E 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 92AFC385840E 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=1754038723; cv=none; b=JrTxWhmfHqES7VFIjKzaRoxPZgQ9farPaTUCPb3DNO3rrQgVS7/WCsiRxiOjHUFXVl6mh4a/DZw4gBrO4khH6ASos8W7u3g8p5JiX+6njGFe+lEI7eKIBA+OFPT4DQUO5U7Bpeos2j3QvF+1e8TSOG2qKe5lsjOOft7pQ1ncPj4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1754038723; c=relaxed/simple; bh=JyAdBUswG7R2teUB6U+Ao3iAiJq8KNjB8Gbvi30U47A=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=hSfpexU/zps1Nj8jO3hyPqPqlO+ZlQiQGySM12DlseaAeFvYYtJNozfZ2dotaIIjcPbGPLrY4XhEK6MvJrWpuOIsWLYCBhaHHv+uQUudBJb3F/+g0st7hU6ROzwXpssGwBrpQKqV8FQfKIMIcgAVYeCJnhfKiQvWUiziSJAhAn4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 92AFC385840E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1754038723; 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=D44+JAmt3f+/CHAdpES8HVvpeulEazOuS2K3qfZyzJY=; b=WVXQhQpd5N99ISa4J2KxPKXH7myC0hrlznOpSlUleHmFr+vj4vumsNsrV5tLlJ52F5CKWw acaqYheDtMaYSOlGbVrAnQU9y73XJb5NGVE0jQo7Enx8LfKS8cq1zJoqCNAGcwYSE6GHH1 nKyyAMQI9yqvDExQIpgsAiVYxtDv49A= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-323-oiP4SZ9fOrWWrW8xO-yQjg-1; Fri, 01 Aug 2025 04:58:41 -0400 X-MC-Unique: oiP4SZ9fOrWWrW8xO-yQjg-1 X-Mimecast-MFC-AGG-ID: oiP4SZ9fOrWWrW8xO-yQjg_1754038720 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-458a321153dso2884045e9.0 for ; Fri, 01 Aug 2025 01:58:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754038720; x=1754643520; 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=D44+JAmt3f+/CHAdpES8HVvpeulEazOuS2K3qfZyzJY=; b=T5jCSzXBSRbhu4wB7IqTl+32pUIKZKSW0GwOIKyK7YFRYgFx93KbuXBB8+YvtpMDAN fPNXWce0m+bvSUmzWhkw83a/X8QnQlYBcqt0gWkhD4JyR6u4XyUg9JoRpMhMzYzzsPhp wdV4j4yOuo052HauNkWRdjqsNtnHU9L38wtWMe9BU4q6gBbrcMS71WoaDC7YZdl2kLb7 RUt78HCgs1c56j8hrHhr0pc1tl0p1zyYlDU6iMBbghvU1p7yhOpR3pWaFRC/RMfdZFO2 ZRjmVnP/K4R5UclFAjs5Rt3T0VS6BEOIVfuaAf1uq1IyQcIPGRccCkpQ3avY0LPUgUBU 8dlQ== X-Gm-Message-State: AOJu0Ywnc+zPesfjIL5K6e3ocXzA65rr/FraJF/7jFAZiq3aSatuIn9M aB7ZtwiMI/Nb0xc3H/UQhV3qikMkxeaQA5DA/8McRf2grWWxf+1XxxMThgxQhziFBzlGiETY0OU aZVnrczBnB4uBwDXhYXMrZ5YpAuVW8wyloWOGvtVROXQKK+f+ZxySCR4Div5QmloUDZSD0QblIB kvc8tZmIl22UViXyC9CbM5RVo/Quf6MXdnCELJW2JQtxsb434= X-Gm-Gg: ASbGnct81ftmpZVwSxwifCcjlEjCnqDZeMuLRPgoDGPDs/DgQClpDjDMosjEYDL4o4d 26R2MxBTTLji8455cLykqf4RlazPImFhnJcAxzNx1y7myrXPQX/LAg4f7Ok972913PvUYxCtQEJ bP1eM5Lvk0b5Bb6K057TXv75KTB8bSNES5ujtpLEEtDp9UimhWieQ6IxW5jwLZhnjTsvw9cWO3R 9GomBdheWkJe4qaaw5dbrbhwIMP+HHJTrwYRrL1ZmCLunAO/zoCSS7h9a+tbUmgJN9SiEzgri6w Vt+o/WZ3VpWb/tQ6j/hCIISmRSEmXyvnkjO14vAjN3+ie1g393vJgz7Pizc= X-Received: by 2002:a05:600c:64c7:b0:456:1752:2b44 with SMTP id 5b1f17b1804b1-45892bd2722mr84676835e9.23.1754038719918; Fri, 01 Aug 2025 01:58:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGDtSl3megHOnY3D+g2abijZzk/Kv+zOUObkhO50FjGdlJI7xHR5k9orBAwdPnrAYZ8uZu0hQ== X-Received: by 2002:a05:600c:64c7:b0:456:1752:2b44 with SMTP id 5b1f17b1804b1-45892bd2722mr84676575e9.23.1754038719444; Fri, 01 Aug 2025 01:58:39 -0700 (PDT) Received: from localhost (27.81.93.209.dyn.plus.net. [209.93.81.27]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4589edfc930sm57208195e9.8.2025.08.01.01.58.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Aug 2025 01:58:37 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv2 5/7] gdb: create address map after parsing all DIE Date: Fri, 1 Aug 2025 09:58:18 +0100 Message-ID: <044702d9a3dfe49454c7dc821f955bb0a4658e66.1754038556.git.aburgess@redhat.com> 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: dqZ_45Pm9UCQS-gJiLZYxM_uS9dxFDWPPz1CmA6waFE_1754038720 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 block vector 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 6dc079f29b1..ef50a3d8c18 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -412,8 +412,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 * @@ -449,9 +447,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 8f38131ec55..4fd9b61fb5d 100644 --- a/gdb/buildsym.h +++ b/gdb/buildsym.h @@ -418,15 +418,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