From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id EbgSEzKvKWkhlz4AWB0awg (envelope-from ) for ; Fri, 28 Nov 2025 09:18:26 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=gnu.org header.i=@gnu.org header.a=rsa-sha256 header.s=fencepost-gnu-org header.b=D2bEpc5V; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 3D7EB1E08D; Fri, 28 Nov 2025 09:18:26 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.4 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_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED 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 EEB9F1E08D for ; Fri, 28 Nov 2025 09:18:24 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 76BAE3858CD9 for ; Fri, 28 Nov 2025 14:18:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 76BAE3858CD9 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gnu.org header.i=@gnu.org header.a=rsa-sha256 header.s=fencepost-gnu-org header.b=D2bEpc5V Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id AF7093858D1E for ; Fri, 28 Nov 2025 14:16:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AF7093858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AF7093858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:470:142:3::10 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1764339406; cv=none; b=P5n8tSqeu8D1ClPLUOq13/quQ+aZf7h3t9Fhe/KSxBrE2RLx7Py7DAEeFSqmzJnTiHFNrSERDuD5owgAAt+jpSPrqngxMGGb3d69pW+ejh4HcVBoByNVkcCekG1sCC+VzleNU4dlRMsyMkZWgMsvIA+IThoS2dTFmCaMAuXRzCQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1764339406; c=relaxed/simple; bh=SvfxlvTXPE6K40O+wsMiL7J1V18DhpTGySS3ptO+ArU=; h=DKIM-Signature:Date:Message-Id:From:To:Subject; b=rDSXrFNGO1zP24OQUNuprlF/IT2qY65ipsWNg3QUy710fS0jm44gsYGQZCkGv1QP7nSMwEApoLOuuPt6s6ySGPtSgvUIPEBVRUjNR6pvYrb9eaRmiPRUB3JYfZLJMBZvZ1ivaF/bntY4UBnQRE+I2lBq8A3NSJZC5ig8QDhzQu8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AF7093858D1E Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vOzH1-0007Ud-LR; Fri, 28 Nov 2025 09:16:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=Y+aVp1tyWUcOLiqLtlRyvN9S7yaRNvUbO9n+ERPnDx4=; b=D2bEpc5VLF9B PcYpkhUuIjd7uhQhRCRszzzU6sZo815PTsy72WoJD+mhYdFwPHWBrtz1C3WFBb5hxoovDgu1D6gs7 7V+NgPhUrsQOoSo6Ilv2Fb8x72n8qWCuCIsVmuWqLnUC6B2uDeT2hJw06eTO+/Xu0vpiyifMEFgoO 25ECLTZ/n8HWrs5IJ7pUeMLw7KFjc+VV6uq3vNZS+Um8DzygSEPGz08mYxhaIogHT0u02MXqFuc6h bdoq8clPcq++TiAkxdPXhwN5Ma1CwBHbEmiYluA32jUWcIykjErCue5M3L5LxFtTwpIHrv1HEpNjU lYecvS0MoOBr+yrVhh6ukw==; Date: Fri, 28 Nov 2025 16:15:44 +0200 Message-Id: <86zf868cq7.fsf@gnu.org> From: Eli Zaretskii To: Abdul Basit Ijaz Cc: gdb-patches@sourceware.org, pedro@palves.net, philippe.waroquiers@skynet.be, aburgess@redhat.com, tankut.baris.aktemur@intel.com, christina.schimpe@intel.com, lsix@lancelotsix.com, tom@tromey.com In-Reply-To: <20251128120317.12208-2-abdul.b.ijaz@intel.com> (message from Abdul Basit Ijaz on Fri, 28 Nov 2025 13:03:16 +0100) Subject: Re: [PATCH v11 1/2] gdb: add annotation in 'info locals' command for variables shadowing case References: <20251128120317.12208-1-abdul.b.ijaz@intel.com> <20251128120317.12208-2-abdul.b.ijaz@intel.com> 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 > From: Abdul Basit Ijaz > Cc: pedro@palves.net, > philippe.waroquiers@skynet.be, > aburgess@redhat.com, > tankut.baris.aktemur@intel.com, > christina.schimpe@intel.com, > lsix@lancelotsix.com, > eliz@gnu.org, > abdul.b.ijaz@intel.com, > tom@tromey.com > Date: Fri, 28 Nov 2025 13:03:16 +0100 > > gdb/NEWS | 4 + > gdb/doc/gdb.texinfo | 20 +++ > gdb/language.c | 20 +++ > gdb/language.h | 19 +++ > gdb/printcmd.c | 29 ++++- > gdb/stack.c | 115 ++++++++++++++++-- > gdb/stack.h | 14 +++ > gdb/testsuite/gdb.ada/var_shadowing.exp | 39 ++++++ > .../gdb.ada/var_shadowing/var_shadowing.adb | 30 +++++ > gdb/testsuite/gdb.base/var-shadowing.c | 49 ++++++++ > gdb/testsuite/gdb.base/var-shadowing.exp | 92 ++++++++++++++ > gdb/testsuite/gdb.base/var-shadowing2.c | 16 +++ > gdb/testsuite/gdb.opt/inline-locals.exp | 21 ++-- > gdb/testsuite/gdb.rust/var_reuse.exp | 36 ++++++ > gdb/testsuite/gdb.rust/var_reuse.rs | 20 +++ > gdb/value.h | 17 ++- > 16 files changed, 524 insertions(+), 17 deletions(-) > create mode 100644 gdb/testsuite/gdb.ada/var_shadowing.exp > create mode 100644 gdb/testsuite/gdb.ada/var_shadowing/var_shadowing.adb > create mode 100755 gdb/testsuite/gdb.base/var-shadowing.c > create mode 100755 gdb/testsuite/gdb.base/var-shadowing.exp > create mode 100644 gdb/testsuite/gdb.base/var-shadowing2.c > create mode 100755 gdb/testsuite/gdb.rust/var_reuse.exp > create mode 100755 gdb/testsuite/gdb.rust/var_reuse.rs Thanks. > diff --git a/gdb/NEWS b/gdb/NEWS > index c976727ee45..616899147c3 100644 > --- a/gdb/NEWS > +++ b/gdb/NEWS > @@ -74,6 +74,10 @@ New command class for help > commands that we, as developers, believe would be close to a minimal > set of commands for a new user of GDB. > > +info locals > + GDB now shows the "shadowed" annotation and the location information in > + the output of this command for variables shadowing case. This sounds like the annotations are only shown when variables' values are shadowed. Is that really the case? If so, why not show also annotations for the non-shadowed variables? > +@smallexample > +1: int x = 3; > +2: @{ > +3: int x = 4; > +4: int y = 52; > +5: x = 99; // breakpoint-line > +6: @} > +(gdb) info locals > +x = 4 > +y = 52 > +x = 3 > +@end smallexample Please use @group..@end group to prevent multi-line examples, or their parts, from being split between pages (which makes reading harder). > +A variable is shadowed when there's another variable with the same I suggest to have "shadowed" in @dfn, and add a @cindex entry before this paragraph saying @cindex shadowed variables This will make it easier to find this stuff if someone is looking for it. > +name which is declared within an inner scope (decision block, > +method, or inner class). For such cases, its location for the > +outermost scope is followed by @samp{shadowed}. The location can > +help to locate the instances of shadowed variables. So, > +location information is only added for shadowed variables. I suggest to add the annotations for all variables. Reviewed-By: Eli Zaretskii