From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id cbwuE+N64mkZvR8AWB0awg (envelope-from ) for ; Fri, 17 Apr 2026 14:24:35 -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=Hws9xOSX; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 4AF431E04F; Fri, 17 Apr 2026 14:24:35 -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 8D6C41E04F for ; Fri, 17 Apr 2026 14:24:34 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id EAEE34CD2019 for ; Fri, 17 Apr 2026 18:24:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EAEE34CD2019 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=Hws9xOSX Received: from mail-ot1-x32e.google.com (mail-ot1-x32e.google.com [IPv6:2607:f8b0:4864:20::32e]) by sourceware.org (Postfix) with ESMTPS id 724FD4BAD142 for ; Fri, 17 Apr 2026 18:24:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 724FD4BAD142 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 724FD4BAD142 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::32e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776450246; cv=none; b=ELZEtk+MrezZkAuXcPEJm8IZeC/SAIn9+yXYPe7IvIsxlm1ssolz+FlEG97nF484PssBBkvvTBEbMr1cEVp8BsBvS7fWTSkwyuliaYLcyE2L3bfFUHkq+UPH501anF5EyoWGR6JSnFXXOvNKSO7eaODV0Z0dcgXpbzcpxIPreyA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776450246; c=relaxed/simple; bh=+MB4cfcQlPPqI97/dflZNHdlH256Q8YX+9EpNkBCCaQ=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=YmSL9bKvQk8xJa9k7P7Z6pUrqAE11uJj1jz6dDED398YjCckSHs7v1v74r+d+y9YkktKe8es+yVG0HWJx/zMsh33s3dWvfDRV+6wmdPLu/FlunENSlRmlJUuJCTfviu/saODQz7qA7hD5+Esv7NoGLRstZghifJB9Qblex4jn+E= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 724FD4BAD142 Received: by mail-ot1-x32e.google.com with SMTP id 46e09a7af769-7d4be94eeacso913804a34.2 for ; Fri, 17 Apr 2026 11:24:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1776450246; x=1777055046; 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=KgGX4XS8Temox4vfhv6hsdyZzJaAN2NPlmSA7btIDd4=; b=Hws9xOSXUUUtQSQ+MjHwlbACzh8KIVkfJeJETjTDjgbnYhoW3bOhn1A4At2f2q4pyU Phx+gRCR6nKSS+2jfi5VFf2nK029taMzrnP/knaQcA22JM09QtnTH6wZ+AX5ntrmKFIW aqFbXOcouu7mqlbIV66177538+h4kWLgncGyr/O5IH33g9UE6v4p/WW9mIjcqstY5CBF 9FL6NWltfkvL1ccmHRbWcXDPNeriAPS2rxgCHwfDSUHqYxP0pFUo6s7FRWLaMYlM657n jf25uXoChGySAWRZ8fehBqlq5yTR22Q+UGPv0cuybqtPrZlZpXScpizAPYu8OiPjtLT6 rtGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776450246; x=1777055046; 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=KgGX4XS8Temox4vfhv6hsdyZzJaAN2NPlmSA7btIDd4=; b=Qhmf2Py0GOCylY1rm8hym0MdntdnsF9FNfyZG9X6bvYO8UpeHqvTfZXpgztccT6IhR BG/cqi76Ew6k0Soy0xibguC09sxih+d+C+rnrfmYtgSDpV1UokghFgGhceAOfBBFzU04 qGMoncz+2NBoyds52Llfm+l+KlNbS90ivCHuAAKLGN4wBfmYC1kR76fGDvetA4149R5t EY4vjToZScsAvzqhV3pbHr7Y+WJ7y9hFQf0lkqVekyifZ3DDcOMDGowA4K9IQACiaVDH XqtLkqTS1uX98eFXwLkzzRIUlNyV8CbWsiAXVRxe9xvjix95xaGR+q34Rsqp9fq9UppL b1hA== X-Gm-Message-State: AOJu0YxgrBYC/Dpkmr/WrfoOo7XsCafFm0G2SIwOeH3Tb5DEqHWxg7ts 6jovFco1wcGMmN7DEENUJIwOHFLdaYyQDnHAJK9jqqxsfTkofykDqLvULpXjrHsTUjCcmYvY5Qo +JfU= X-Gm-Gg: AeBDietTRhwtETc5LjLb55sJ5xPlfqozxo6ztKRmHIZa8aYxjr3DaQRabjujCl5cHpu BZFrTs+9zoy7auIzXdI9peLt7ZQzQkhdWvlPcwEcWxWSKPhN+yzHhEpxlgfVRiV44cDseGCQUuj qPMtBtKKKZ0tSzCOaVEOFmiA5OK+Mlqr2AIkR4bw7dqGIUq16xQHwEHOF38ftRPQO3/dQceZq29 4oo/XVzL0L5e2BgL8sEEqNtu5vQCScEX7Bw38krnSbj5UOdVkaQtrnjRx9rSbn4wRXwxa50+C7r ZmXuMpmRQh/hMo6TvUckmCH81Ppc8hn41iHje+oDp70AYjUA53pxGHh+qUcU2fa5Kxl3Gev51wb vxRMkX/EhdO+9MZyfml1sypgdLFavmye7ns5MPJ4q/I+K1i7vcFMw5g5nzbQ1zq7ljH31XmO10Y +eAPM9ENL2OdlQid/GOLCV5Ugsuq3dbpBs4qYS2JWpLYgzKVx/k8mPOYkeSiItJyj1 X-Received: by 2002:a05:6830:dc7:b0:7d9:7209:4378 with SMTP id 46e09a7af769-7dc951c7513mr2421539a34.17.1776450245698; Fri, 17 Apr 2026 11:24:05 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Apr 2026 11:24:05 -0700 (PDT) From: Tom Tromey Date: Fri, 17 Apr 2026 12:24:03 -0600 Subject: [PATCH 1/6] Use scoped_restore for dwarf2_cu::list_in_scope MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260417-list-in-scope-v1-1-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 Some functions in the DWARF reader temporarily set dwarf2_cu::list_in_scope and then reset it when returning. This patch changes these spots to use scoped_restore. --- gdb/dwarf2/cu.h | 7 +------ gdb/dwarf2/read.c | 16 +++++----------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/gdb/dwarf2/cu.h b/gdb/dwarf2/cu.h index 9b90415ed64..5157c6b8fa1 100644 --- a/gdb/dwarf2/cu.h +++ b/gdb/dwarf2/cu.h @@ -309,12 +309,7 @@ struct dwarf2_cu /* The generic symbol table building routines have separate lists for file scope symbols and all all other scopes (local scopes). So we need to select the right one to pass to add_symbol_to_list(). - We do it by keeping a pointer to the correct list in list_in_scope. - - FIXME: The original dwarf code just treated the file scope as the - first local scope, and all other local scopes as nested local - scopes, and worked fine. Check to see if we really need to - distinguish these in buildsym.c. */ + We do it by keeping a pointer to the correct list in list_in_scope. */ std::vector *list_in_scope = nullptr; /* Storage for things with the same lifetime as this read-in diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 4035bba6e45..ebf7eeb673b 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -7478,9 +7478,8 @@ inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu) /* We're inheriting ORIGIN's children into the scope we'd put DIE's symbols in. */ - std::vector *origin_previous_list_in_scope - = origin_cu->list_in_scope; - origin_cu->list_in_scope = cu->list_in_scope; + scoped_restore save_scope = make_scoped_restore (&origin_cu->list_in_scope, + cu->list_in_scope); if (die->tag != origin_die->tag && !(die->tag == DW_TAG_inlined_subroutine @@ -7629,8 +7628,6 @@ inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu) } } - origin_cu->list_in_scope = origin_previous_list_in_scope; - if (cu != origin_cu) compute_delayed_physnames (origin_cu); } @@ -7826,7 +7823,9 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) attr_to_dynamic_prop (attr, die, cu, static_link, cu->addr_type ()); } - cu->list_in_scope = &cu->get_builder ()->get_local_symbols (); + scoped_restore save_scope + = make_scoped_restore (&cu->list_in_scope, + &cu->get_builder ()->get_local_symbols ()); for (die_info *child_die : die->children ()) { @@ -7912,11 +7911,6 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) back to building a containing block's symbol lists. */ cu->get_builder ()->get_local_symbols () = std::move (cstk.locals); cu->get_builder ()->set_local_using_directives (cstk.local_using_directives); - - /* If we've finished processing a top-level function, subsequent - symbols go in the file symbol list. */ - if (cu->get_builder ()->outermost_context_p ()) - cu->list_in_scope = &cu->get_builder ()->get_file_symbols (); } /* Process all the DIES contained within a lexical block scope. Start -- 2.53.0