From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id YCNGJ6TDfGhHdSoAWB0awg (envelope-from ) for ; Sun, 20 Jul 2025 06:23:32 -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=QazW0u5k; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 887771E11E; Sun, 20 Jul 2025 06:23:32 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.8 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_SBL_CSS,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 907851E0C2 for ; Sun, 20 Jul 2025 06:23:21 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 19C3B385DDFD for ; Sun, 20 Jul 2025 10:23:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 19C3B385DDFD 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=QazW0u5k 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 11BDA3858C48 for ; Sun, 20 Jul 2025 10:21:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 11BDA3858C48 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 11BDA3858C48 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=1753006867; cv=none; b=K9FFAVf+4nQNG+9JVe58jX2DIdN0Up6eqFbQBxl+qqZY4t4FQJ4e5fARFQD1QUlDbeiaobK7mP1DbmmOpvVtA+Gclv6D8M3QHPceF2m1GRIppOBaMK6vKYc7/Ams7S7Sqs1L7bIvvU7PoTZSj6xtKvYwUfyBYUps0OQv2ZTBWsw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1753006867; c=relaxed/simple; bh=JyAdBUswG7R2teUB6U+Ao3iAiJq8KNjB8Gbvi30U47A=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=AMMBs4OfcR6NBTLfohBKWIVR30/urqRa0Gcs4c/26iE9gwPVBGTTvRO9HMD1qX/31zSLuEOujhXj++aI24IZGd5LnGPx4BfxXtK6NZTbcY+Mfm/Bjd7HiDKHmmLVccGW+QBZp5nTYwRGRhVzO1nKbefshz1ufTmr7KuSYdG44jc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 11BDA3858C48 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753006866; 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=QazW0u5kmv8xzXO0r5mp1lbOtCU6m/cgFK8F5Wm2tJZiWZwwe0YmbQ+BF1rIJ9OBrsGHeO f0o/6FWYw8XzqBURsZh3cP1m4GMm5MyWz69ltz60YzdQFtTU4Ly+9o7ROaEOoSARHnjtN+ 9R0eh2AlOnd/XFifD6ANY3j+wxeegNE= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-611-eHC-A33BPJyBtZLm-ac-LA-1; Sun, 20 Jul 2025 06:21:05 -0400 X-MC-Unique: eHC-A33BPJyBtZLm-ac-LA-1 X-Mimecast-MFC-AGG-ID: eHC-A33BPJyBtZLm-ac-LA_1753006864 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3b61e53eea3so1218526f8f.0 for ; Sun, 20 Jul 2025 03:21:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753006863; x=1753611663; 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=rDe2zh5kPsborRW7KePQH9HpwOtXbd2Cu5YCMvbrIIFHjeV/CS1UFHkbJyv4eKBe1B koZ4VwSx3QwcJni1+WSR5S5gCh00SBWqXm8g4xP04U8ksvqGli+3K58Md3OJY7OzOjc3 SJu+POjYKlsIytQTNgTi4jtSP5PG5g0COnZJVs38SYSsE1ubAwv8jVppG3fx6L7JebnW y3xzia7snMJoT6i7jeyiXTbehT+x06+p+2qAgQMoI70mAFJjdnXAxrXWC56Jd05vRGun 3K3VNgGSwFIO+Qac8ScgjoR3ZfGwp/24ZdRXoEwkYpCZ73KEDnJcpneb4QR6p/xU+UOL Ccqg== X-Gm-Message-State: AOJu0Yz4USnNTRRRvFyIUJJrrvEKs+ES65UNEVnbqagSuHN4g1IFi6Nm 6QaiQO4R2NTpQWX4vfujX0DrrIT4db44yrpsVl/+ZL1ywhNwHxxMLnM3vMIe95bU6gbYxgDFM/1 UWChgf2qScCCU787UjgW7tlqTdZbGolpQhTgWcr87SU70XVgfkWUMMvJjjU4iVa7siy19s2UKqy WklxyjCu59osbM7xL43G645qnQwiT43i59z7IRHgGadsA6iBo= X-Gm-Gg: ASbGncvCK9c1dhD0dy7atXw1oejnxrw5IYAjh26FgizwOc9Xa6RfCKabRnxwuLGcnrl /XnplG1nYupY5g2C7a9ouLzP3EmNjxHJKXwTXQWDCK1iEmWRugJkzcPIt14Ej6JP2+0EHnVkZ/m 3BnKxZedl7TVd0m+AzMV6CHRGGUxFK2bPuzoTbesPCLnVMoKRMBw+88gVj7D6Q+gHLRE8S/lDXM gWfFKvV9ZxM9fGJH10Y9mbTd0KbcEg3m9+sJDmKbuA9zxZDkCNcwzkiWWOMJbDHxM3H5JzCQX1f 8trPG+02x4dzbFGrdD1R7tlAJaQaWKMyA1vv+NpYwsCuoGRmfHfevV7e0IxK2g== X-Received: by 2002:a05:6000:2308:b0:3a5:2ec5:35a3 with SMTP id ffacd0b85a97d-3b60e51d196mr12171925f8f.45.1753006862933; Sun, 20 Jul 2025 03:21:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGAzXE3ynRkVvR497CXeSzhCy5GkRFUE4tQOLyRT3OX7xmztfHj8Ni9sNjhnYSGa96M2WnVhw== X-Received: by 2002:a05:6000:2308:b0:3a5:2ec5:35a3 with SMTP id ffacd0b85a97d-3b60e51d196mr12171910f8f.45.1753006862401; Sun, 20 Jul 2025 03:21:02 -0700 (PDT) Received: from localhost (92.40.185.56.threembb.co.uk. [92.40.185.56]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b61ca2b803sm6971705f8f.19.2025.07.20.03.21.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Jul 2025 03:21:01 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 5/7] gdb: create address map after parsing all DIE Date: Sun, 20 Jul 2025 11:20:44 +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: 70L04Epw706KD39UVd_k2kJdg8qrfMd0aYp46pdglAc_1753006864 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