From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 0fiMHRF74mkZvR8AWB0awg (envelope-from ) for ; Fri, 17 Apr 2026 14:25:21 -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=XuhkvtZd; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 71D1F1E0B1; Fri, 17 Apr 2026 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 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 C22261E04F for ; Fri, 17 Apr 2026 14:25:20 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 665A84CD2006 for ; Fri, 17 Apr 2026 18:25:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 665A84CD2006 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=XuhkvtZd Received: from mail-ot1-x32d.google.com (mail-ot1-x32d.google.com [IPv6:2607:f8b0:4864:20::32d]) by sourceware.org (Postfix) with ESMTPS id 954184CD2000 for ; Fri, 17 Apr 2026 18:24:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 954184CD2000 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 954184CD2000 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::32d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776450249; cv=none; b=TJc8/9/Px2RTHp7fzXx9c3bCYR+6WkZ2IzIpqgp87tlPdGj9YhzDvL9EX/tN9EHRAHOCxnL221KzgCC1CGRdC18GOeunSHgW0OvkN5K4Qwp7rtmAqMj/NGW0b4D/t5/531gsyFxMgaMvk7hEFrWeF/0t1rWUx87qQX5M6JPw/jg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776450249; c=relaxed/simple; bh=DDSJl8fwImY5uDlSdfFXVrJ9/L/ankJTvH0Own2XTGc=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=EtoPglHNdVjgIViLRJFu412QshrgjdGr4y5k/mDXSjnqcA8OlL2TphMvZobzheRAqKn8UivjJOwvFlArWGHPrwF6BVnHpdaqDS5fxyJQMx6D3RjSowgFdbL0PIaiHHveVRfbWMAfdCNn1sa8bHxqTXKnnf9xZ8uOLTgUwfwdGxE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 954184CD2000 Received: by mail-ot1-x32d.google.com with SMTP id 46e09a7af769-7dc35728a57so825826a34.0 for ; Fri, 17 Apr 2026 11:24:09 -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=k12IzA04rg8PmVNox4J4Oaf1m5xHZsRp9crDIGrZ9+o=; b=XuhkvtZdF8G+uY/M1tXXWOSqF6zqIkSTFNcfW6b81OGw6zqpxfBhLAFO1IA74Arfre 07ZNHe6Nv3hvfcDbspNrV7s6wzbbgcKMmxOiRYQhc7coeipFeyQled7YGAf8g8qMcnJ5 9hJF7Ix+C0vFcRiyOGIwWt6QtmV1/2Dq2nmkgDW9rpgy46awtsGHX28vDiBYD/I1t35h Otchx2ymcPPZYisVf8Dl5gPup91rYP2oC8Edk+pErkUzUwV1oGFhBqxO9UbmPGFxI98e D7c8PgqmgOpcuXUa7a1SvfynUWz86yckQitdg3XN4vhAJ2lgonB6IFKgJZ3bDjA23z6K mkUg== 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=k12IzA04rg8PmVNox4J4Oaf1m5xHZsRp9crDIGrZ9+o=; b=M0sLaesDz73AeHmB5VjZGl89bgrEFahVZWRApHznV+eGIAevzDVwudOdGs5zQYfqvl QNuXBC2p9GO4CtFoOtrffIR4Wp4deFKfGMj1r/LjfGXaAUk6pJv9FlZYFRyVXi64DCmY QTd1Fbbb/o5y1GKsSgB/ZMxx3giqo9uAPjTHm279gL0MYv/KT6rkoi3ldQsw9I16t2kl mXxfzEwdt6gm19qjV0oLPo32NCJ+rmbizxec7zL3FXCGJ9nnq/lfFL5fzy2Jv3i/ER6k m9nDhZMx54WGYm0+c3eVcpxb/8zP3h9LNT7amZn/hLQsc/Bv5Dz3LPiV8AzRjKqZ3mvy f4aA== X-Gm-Message-State: AOJu0YzCrbL+YYk/F0EW7Ddp87Anv5emhly93a8j4a6z7qjgkW+uJ/TN 6VcC7BswbtEK+adCsPkMb1D7uMfZ/Mg8uGKmDMDzzCEOQe8EDPwfz7xpzMUvmyeaByudgOwZ9kr RFZQ= X-Gm-Gg: AeBDievdRFifhj9X2GzqUXtGeWwjwQVosRDbVgzY1zIg+oYEoiTileI1aIXpBH5PXyr sKYa/57FmuONo0PXJQc1jD51OOQZdS5qzfOj7EKu4xT/adu4IslrStFeK/+XbqG1SnR/WMyE/Td 1FzxDpeGV72jODggG2PftlzwSU79XNaE75FPTD8e6MHovzDn4E2RVSHRtdmxImnxJEpu7oOFI4S DTkghJAUndKkn+wayNWui3Z9HW3bTBuT50fkoZ12/M7rybWuQzZCgNyyWuex9eKxwzTGe0aqm/j CBBgHGmtR5zyywxxNGp7SEBuFico+nat8v44WmsBs2qEdv2yVpgmCAXqlNz3c8YD0tbkTHLf9pG X2xsMSMKHpIhW1nxXhvWeh3nn/Yh7oGD1BXnUMLXQeEDowNj4VyHiEM63ZOPxRg1DgnWDIlTb7O UjDgUvWMH1ksn9P6bdRBfR2Bvb1TJlRQ8+04lGXXtGdJHi6irnbpgm4jfkig1BYeqy X-Received: by 2002:a05:6830:3818:b0:7d7:fb11:b669 with SMTP id 46e09a7af769-7dc94fa637dmr2624665a34.1.1776450248802; Fri, 17 Apr 2026 11:24:08 -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:08 -0700 (PDT) From: Tom Tromey Date: Fri, 17 Apr 2026 12:24:07 -0600 Subject: [PATCH 5/6] Return void from buildsym_compunit::push_context MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260417-list-in-scope-v1-5-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 There is one caller that uses the result of buildsym_compunit::push_context. This patch changes this method to return void and changes that spot to instead call a new methods on buildsym_compunit. This patch also removes the get_current_context_stack method in favor of a new method that checks the exact condition needed by the one caller. This patch enables a subsequent cleanup; in particular now the 'context_stack' type isn't used outside of buildsym. --- gdb/buildsym.c | 12 ++++-------- gdb/buildsym.h | 21 ++++++++++++++++----- gdb/dwarf2/read.c | 15 +++++++-------- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 592bcf8bcf0..f5cc7de324d 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -930,17 +930,13 @@ buildsym_compunit::augment_type_symtab () /* Push a context block. VALU is the starting PC address of this context. */ -context_stack & +void buildsym_compunit::push_context (CORE_ADDR valu) { - context_stack &ctx - = m_context_stack.emplace_back (std::move (m_local_symbols), - m_local_using_directives, - m_pending_blocks, valu); - + m_context_stack.emplace_back (std::move (m_local_symbols), + m_local_using_directives, + m_pending_blocks, valu); m_local_using_directives = nullptr; - - return ctx; } /* See buildsym.h. */ diff --git a/gdb/buildsym.h b/gdb/buildsym.h index d1199735abb..02c411b053d 100644 --- a/gdb/buildsym.h +++ b/gdb/buildsym.h @@ -199,11 +199,22 @@ struct buildsym_compunit return m_context_stack.empty (); } - struct context_stack *get_current_context_stack () + /* Return true if the lexical context currently being constructed + has a symbol, false otherwise. */ + bool current_context_has_function () const { - if (m_context_stack.empty ()) - return nullptr; - return &m_context_stack.back (); + return (!m_context_stack.empty () + && m_context_stack.back ().name != nullptr); + } + + /* Set the symbol on the lexical context currently being + constructed. */ + void set_current_context_function (symbol *fun) + { + gdb_assert (!m_context_stack.empty ()); + gdb_assert (m_context_stack.back ().name == nullptr); + gdb_assert (fun != nullptr); + m_context_stack.back ().name = fun; } struct subfile *get_current_subfile () @@ -236,7 +247,7 @@ struct buildsym_compunit m_producer = producer; } - context_stack &push_context (CORE_ADDR valu); + void push_context (CORE_ADDR valu); /* Pop a context and create the corresponding block. Returns the block. END_ADDR is the final address of the block. STATIC_LINK, diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 4447923ae3e..2a330655c48 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -7799,10 +7799,11 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) } } - gdb_assert (cu->get_builder () != nullptr); - context_stack &ctx = cu->get_builder ()->push_context (lowpc); + buildsym_compunit *builder = cu->get_builder (); + gdb_assert (builder != nullptr); + builder->push_context (lowpc); symbol *func_sym = new_symbol (die, read_type_die (die, cu), cu, templ_func); - ctx.name = func_sym; + builder->set_current_context_function (func_sym); if (dwarf2_func_is_main_p (die, cu)) set_objfile_main_name (objfile, func_sym->linkage_name (), @@ -7825,7 +7826,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) scoped_restore save_scope = make_scoped_restore (&cu->list_in_scope, - &cu->get_builder ()->get_local_symbols ()); + &builder->get_local_symbols ()); for (die_info *child_die : die->children ()) { @@ -7864,7 +7865,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) } } - block *block = cu->get_builder ()->pop_context (highpc, static_link); + block *block = builder->pop_context (highpc, static_link); /* For C++, set the block's scope. */ if ((cu->lang () == language_cplus @@ -15785,9 +15786,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, pretend it's a local variable in that case so that the user can still see it. */ sym->set_domain (VAR_DOMAIN); - struct context_stack *curr - = cu->get_builder ()->get_current_context_stack (); - if (curr != nullptr && curr->name != nullptr) + if (cu->get_builder ()->current_context_has_function ()) sym->set_is_argument (true); attr = dwarf2_attr (die, DW_AT_location, cu); if (attr != nullptr) -- 2.53.0