From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id alfsGxqwKWkmmz4AWB0awg (envelope-from ) for ; Fri, 28 Nov 2025 09:22:18 -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=rw6LnK7h; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 58ECD1E08D; Fri, 28 Nov 2025 09:22:18 -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 77F031E08D for ; Fri, 28 Nov 2025 09:22:17 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C4C2A3858D2A for ; Fri, 28 Nov 2025 14:22:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C4C2A3858D2A 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=rw6LnK7h Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 197BA3858D1E for ; Fri, 28 Nov 2025 14:21:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 197BA3858D1E 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 197BA3858D1E 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=1764339689; cv=none; b=fhJheU2Y11qIdGqYA63sieeCEMdmbVZcJLQK9tFxG+3z0nNl4cee6CB/BayhyXdHfuX8COh8+vdo0EJ+0cnHL6bqFvrnUvFnwUBddCorKlsQwCC2v3022j8/F3oSZcrldgjqg/TAlfbYbxXurJ2+dhoC9H9fcHMDERceIBKnGt0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1764339689; c=relaxed/simple; bh=ooYTPQdayNhN6/K8JxSnItskMYUdEkmUqgIewOWRXLU=; h=DKIM-Signature:Date:Message-Id:From:To:Subject; b=ZzZgjR/iuMxI//iuMW1JaCrHl0rotexKGoHt3i1/US/8ZqSKNWJ9FzezDUVP9/nQsTSbLMaDCXaA+z6LykphipaGMz4KUtfvpt0Mnnj/Pabv/uO2maU2Mm5kpAQatWAa7h7F3cYijMB6DOTjSw0ydlQi1FIN9LUJEBWkw9Bb+iU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 197BA3858D1E 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 1vOzLj-0008UO-M9; Fri, 28 Nov 2025 09:21:27 -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=ecwzyj+MEjS9I8fqksPvle1yrXuKzWn/alFTeFTXiZU=; b=rw6LnK7h/uzT qrCpVcS7naf9Rtuz1e0uRTL/dD4cEyyV3zdqJwKsj6H3qxdpnZ1X6uWM7Yv0LC7QG3jbB3nGDyfbN U++sLhqN4yzUVcqkVhhyO1AekAgVrE/CzdpZ5dnuSL4txL05H+WTloJChu590OtU/+KgyhIkSrkzx TKg392hqevlKI2q1qGOjiWQCEZQz9JeubTMIQhE0v6DXXyHxSbTlSZo5pehzZQr/ldeig3dk97Sxg aDu29HcWjB8InEckZ46jyZ1oC+Q2mYpFnwGw/4a78Wt+IXRh4d64wtnH1h0w2vxbNJExwseJIdi8c tWS+jsSIUXRTWok2G9kKVA==; Date: Fri, 28 Nov 2025 16:21:23 +0200 Message-Id: <86y0nq8cgs.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-3-abdul.b.ijaz@intel.com> (message from Abdul Basit Ijaz on Fri, 28 Nov 2025 13:03:17 +0100) Subject: Re: [PATCH v11 2/2] gdb: add shadowed field in '-stack-list-locals/variables' mi commands References: <20251128120317.12208-1-abdul.b.ijaz@intel.com> <20251128120317.12208-3-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:17 +0100 > > gdb/NEWS | 4 + > gdb/doc/gdb.texinfo | 18 +++ > gdb/mi/mi-cmd-stack.c | 129 ++++++++++++++------ > gdb/testsuite/gdb.mi/mi-var-shadowing.c | 48 ++++++++ > gdb/testsuite/gdb.mi/mi-var-shadowing.exp | 141 ++++++++++++++++++++++ > 5 files changed, 305 insertions(+), 35 deletions(-) > create mode 100644 gdb/testsuite/gdb.mi/mi-var-shadowing.c > create mode 100644 gdb/testsuite/gdb.mi/mi-var-shadowing.exp Thanks. > diff --git a/gdb/NEWS b/gdb/NEWS > index 616899147c3..034b530a7bf 100644 > --- a/gdb/NEWS > +++ b/gdb/NEWS > @@ -371,6 +371,10 @@ vFile:stat > multiple times, and the same mapping was being reused. In all > other cases, this field will have the value 'false'. > > +** GDB now shows "shadowed", "file" and "line" fields in the output > + of '-stack-list-locals/variables' mi commands for variables > + shadowing case. > + > * Support for stabs debugging format and the a.out/dbx object format is > deprecated, and will be removed in GDB 18. > > diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo > index 9ea4a2705bf..f761e85ee28 100644 > --- a/gdb/doc/gdb.texinfo > +++ b/gdb/doc/gdb.texinfo > @@ -35417,6 +35417,24 @@ If the @code{--skip-unavailable} option is specified, local variables > and arguments that are not available are not listed. Partially > available arguments and local variables are still displayed, however. > > +@smallexample > +1: int x = 3; > +2: @{ > +3: int x = 4; > +4: int y = 5; > +4: x = 99; // breakpoint-line > +5: @} > +(gdb) -stack-list-variables 2 > +^done,variables=[@{name="x",type="int",value="4",file="/home/src/name.c",line="3"@},@{name="y",type="int",value="5",file="/home/src/name.c",line="4"@},@{name="x",type="int",value="3",file="/home/src/name.c",line="1",shadowed="true"@}] > +@end smallexample Same comment as in the previous patch regarding multi-line examples. Also, the last line is too long, so please break it into several lines, each one no longer than 72 characters (and preferably even fewer). > +A variable is shadowed when there's another variable with the same > +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} attribute. The > +location can help to locate the instances of shadowed variables. So, > +location information is only added for shadowed variables. There's no reason to explain twice what does "shadowed variable" mean. Instead, please put here a cross-reference to the other node where this is explained. I still think that all variables should have this annotation. In the MI output, it will make the job of the front-end which needs to parse this output simpler, since the fields will always be present. Reviewed-By: Eli Zaretskii