From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id CRJABSN74mkZvR8AWB0awg (envelope-from ) for ; Fri, 17 Apr 2026 14:25:39 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=WSYYaiYn; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 046A51E0D1; Fri, 17 Apr 2026 14:25:38 -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 vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (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 66B301E0B1 for ; Fri, 17 Apr 2026 14:25:29 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id E6C354CD2000 for ; Fri, 17 Apr 2026 18:25:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E6C354CD2000 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=WSYYaiYn Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) by sourceware.org (Postfix) with ESMTPS id 301834CD2019 for ; Fri, 17 Apr 2026 18:24:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 301834CD2019 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 301834CD2019 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::32b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776450250; cv=none; b=qhtKeWoXVtmnzbb0R+uKGHatxnXGvTqeI1K/hoWY3neW8LyUEHbrSZR3ye+aGYexKZ2CQn4jiDcnhRE582zQ+7Y+dVJSb9GgrSy4TFvY2npfOM18MHGGbNep8sgNs6ek+1/IPR17ePsFfS1iCxkSS58MRW2p/RKfsJQ/KwZIubQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776450250; c=relaxed/simple; bh=wZoLyq5HAM278GESufWlZQ5wtmh25FxN3z7TK/RMpNE=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=s/us0YjVcck+dp/+tfujmKZWTnwkzdjcevOFfwVTRGA5/zWw4zJc9vEGy+l1OXVqt6yaIkZYWCbfCRKDQTw2gD8rXOAXCpepWleP/cZNRyY2D+2ebP5sLKgDFLq6hy5LtR3jYLgzypt57ymBEPAiQksLIOBln6atmeA98LLkecg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 301834CD2019 Received: by mail-ot1-x32b.google.com with SMTP id 46e09a7af769-7dbcf927395so600191a34.0 for ; Fri, 17 Apr 2026 11:24:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1776450249; x=1777055049; darn=sourceware.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=NLbmCPveFlhXJT2kOsw1QtI5Rn0sjphrEDIZgLf1GMI=; b=WSYYaiYn2UcT2tLkxX13KNTMFrdjmiiuLo0S1mLbW/uXitHQcCBZWEVWk2ixKveNDp 3QA5Ml5fJbVmohTj+qFYYX/bjpASGBzqxcHWo45DNbbqHmxY9r6hS/3bHWCOZTdvnEtr Y3GQ5XV5EIF+cBunxkobcTjJ5FBYk/aI7KW9vULuQMJjSyVDn2yaBJx1DwHtiIFSktg6 0gjuyAzXH/M9PAoxzgUHBmucTw9+JDv52Z2wdEoeMOK/LbvkdiLEmgeLIZ2gU/AD4Dtb vs4uDL15RZeRN68O6L2CgGlxunpNuCSv5vk/DkORb8rvki+nWnSb3w5hoZBBz+cCSiXP Vwbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776450249; x=1777055049; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=NLbmCPveFlhXJT2kOsw1QtI5Rn0sjphrEDIZgLf1GMI=; b=YIn8V3W3n3Fecs8t5ZynV46s0A9GhICCQazxgGumiE3NZB+ca0LdLKTBBE42i5rP58 VFgo8zGBAf0Utdq/BDS//GfmpHDR3P6lUyr21XMoaeZ4TfWMv8z/oZmSK6UMmmkk55jG 0J58VyR/1wepkfpEITjIGDQUKV6EgxYL8ld0Q2Bh3vtq9aGVe3oSbFXHaSrGsuls2IZs Oh/RZ6N9u8+omFbaj4K3oPnRrU6PiEYdJGEwkZWsNVNHkqZ74lkK8quHCWE0QffOFCXm 8UOAa7jTlJuONLCfSVKjwy0ISfECWgSUYvdxiD0ZLmEgEDdkZzr6hjIGINf1eSNSbwR+ NMXw== X-Gm-Message-State: AOJu0Yw7MO1LeFgIpCUScxojBg6JJ34swdNmPqv151Kh85OL0IVhCQTh Us9w+266EIApelo9hDNazOV4p6iPpRY2LIM+3G8XC+xwEEHMSrTcg8Mo6nR6Rk1h9nigrXXTyuV Ctsc= X-Gm-Gg: AeBDiev4q0H1mMPfrSCEBOszUlBLRN4zL/Ic6cmZqd8D+CNiROwVJn7H/u1JszJ3OPv yFFOpioH7FKfKwg8NaTxRqwG7GEHHXZfMx6XdXyp+YNAi16ziqACGvyKEtEaVib7Z2n+hdGcWz9 Z8mJ6pbnszl7wgcYLqSWLH6gjQR0NtS5kDxl8RY6TuIIzk7Xc7uiptoX+tk9f5eFjIZLmHA/+Ym Q1rn1yUg2wG/I6k45K2FurlgunRpYysmFlych99enKVK86b6qc3W1eF1Wp2u1jdZNdF9zwsM9mk zTHB0OxGfQ6H2AOsWKeHzSmx8avzwMWNKr5DihJgdjFsguaDAjbkZW9T/YdFmfFnxXEDzQV3Gfq Mkd2L9eFkxd7MyQLz8cJ+KhAlKhVIvHkvhlgA/dmXbinNWCB+IsGIiJciPTMgDLpj1PJyUh24Cw /DnRd5rtruJUp6YEhdx9A4z4eHIfsHkkvi2DX5e5jnVODVJyL8Zo0lcrnnrTmXJ89D X-Received: by 2002:a05:6830:67d5:b0:7d7:d615:3040 with SMTP id 46e09a7af769-7dc951a8f7amr2582999a34.17.1776450249396; Fri, 17 Apr 2026 11:24:09 -0700 (PDT) Received: from [192.168.0.26] (75-166-225-82.hlrn.qwest.net. [75.166.225.82]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7dc9a7102b0sm1182475a34.0.2026.04.17.11.24.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Apr 2026 11:24:09 -0700 (PDT) From: Tom Tromey Date: Fri, 17 Apr 2026 12:24:08 -0600 Subject: [PATCH 6/6] Rename context_stack and make it private MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260417-list-in-scope-v1-6-0deb050fc03d@adacore.com> References: <20260417-list-in-scope-v1-0-0deb050fc03d@adacore.com> In-Reply-To: <20260417-list-in-scope-v1-0-0deb050fc03d@adacore.com> To: gdb-patches@sourceware.org Cc: Tom Tromey X-Mailer: b4 0.14.3 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 "context_stack" has been misnamed at least since the storage was changed to a std::vector, and arguably even since the very beginning. This patch renames it to "lexical_context", which is a bit closer to what is is for. This type is also no longer used outside of buildsym itself -- callers can now push and pop contexts, but they don't act on the context object itself. So, the type is made private. One benefit of this approach is that callers no longer need to be quite as careful -- previously there was at least a possibility that a context object pointer would be invalidated when pushing and popping the stack. --- gdb/buildsym.c | 2 +- gdb/buildsym.h | 60 +++++++++++++++++++++++++++++----------------------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/gdb/buildsym.c b/gdb/buildsym.c index f5cc7de324d..44621a4c776 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -947,7 +947,7 @@ buildsym_compunit::pop_context (CORE_ADDR end_addr, bool required) { gdb_assert (!m_context_stack.empty ()); - context_stack cstk = m_context_stack.back (); + lexical_context cstk = m_context_stack.back (); m_context_stack.pop_back (); block *result = nullptr; diff --git a/gdb/buildsym.h b/gdb/buildsym.h index 02c411b053d..c9010665bce 100644 --- a/gdb/buildsym.h +++ b/gdb/buildsym.h @@ -68,35 +68,6 @@ struct subfile using subfile_up = std::unique_ptr; -/* Stack representing unclosed lexical contexts (that will become - blocks, eventually). */ - -struct context_stack -{ - context_stack (std::vector locals, using_direct *local_using_directives, - pending_block *old_blocks, CORE_ADDR start_addr) - : locals (std::move (locals)), - local_using_directives (local_using_directives), - old_blocks (old_blocks), - start_addr (start_addr) - {} - - /* Outer locals at the time we entered. */ - std::vector locals; - - /* Pending using directives at the time we entered. */ - using_direct *local_using_directives; - - /* Pointer into blocklist as of entry. */ - pending_block *old_blocks; - - /* Name of function, if any, defining context. */ - symbol *name = nullptr; - - /* PC where this context starts. */ - CORE_ADDR start_addr; -}; - /* Flags associated with a linetable entry. */ enum linetable_entry_flag : unsigned @@ -340,9 +311,38 @@ struct buildsym_compunit /* Global "using" directives. */ struct using_direct *m_global_using_directives = nullptr; + /* Unclosed lexical contexts (that will become blocks, + eventually). */ + struct lexical_context + { + lexical_context (std::vector locals, + using_direct *local_using_directives, + pending_block *old_blocks, CORE_ADDR start_addr) + : locals (std::move (locals)), + local_using_directives (local_using_directives), + old_blocks (old_blocks), + start_addr (start_addr) + {} + + /* Outer locals at the time we entered. */ + std::vector locals; + + /* Pending using directives at the time we entered. */ + using_direct *local_using_directives; + + /* Pointer into blocklist as of entry. */ + pending_block *old_blocks; + + /* Name of function, if any, defining context. */ + symbol *name = nullptr; + + /* PC where this context starts. */ + CORE_ADDR start_addr; + }; + /* The stack of contexts that are pushed by push_context and popped by pop_context. */ - std::vector m_context_stack; + std::vector m_context_stack; struct subfile *m_current_subfile = nullptr; -- 2.53.0