Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Ijaz, Abdul B" <abdul.b.ijaz@intel.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
	"pedro@palves.net" <pedro@palves.net>,
	"philippe.waroquiers@skynet.be" <philippe.waroquiers@skynet.be>,
	"aburgess@redhat.com" <aburgess@redhat.com>,
	 "Aktemur, Tankut Baris" <tankut.baris.aktemur@intel.com>,
	"Schimpe, Christina" <christina.schimpe@intel.com>,
	"lsix@lancelotsix.com" <lsix@lancelotsix.com>,
	"tom@tromey.com" <tom@tromey.com>
Subject: RE: [PATCH v11 1/2] gdb: add annotation in 'info locals' command for variables shadowing case
Date: Fri, 28 Nov 2025 14:37:34 +0000	[thread overview]
Message-ID: <SA1PR11MB6846BDC9397F07984BF04364CBDCA@SA1PR11MB6846.namprd11.prod.outlook.com> (raw)
In-Reply-To: <86zf868cq7.fsf@gnu.org>

Hi Eli,

Thanks a lot for the feedback. Please review my feedback below.

>> +  the output of this command for variables shadowing case.

Eli>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?

Abdul>Yes it the case. As otherwise this information is not useful. For example if variable is shown for "info locals" 5 times then 4 instances will have shadowed annotation with location info while the one instance will be without it. So it will be easier for user to identify the variable in current scope from the rest but any variable is only shown once then the information is not that useful.

>> +@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	<file.c:3>
>> +y = 52
>> +x = 3	<file.c:1, shadowed>
>> +@end smallexample
Eli>Please use @group..@end group to prevent multi-line examples, or their parts, from being split between pages (which makes reading harder).

Abdul>Sure, will make use of "group " in the example in the next patch.

>> +A variable is shadowed when there's another variable with the same

Eli>I suggest to have "shadowed" in @dfn, and add a @cindex entry before this paragraph saying

Abdul>Will update in patch v12.

>> +is only added for shadowed variables.

Eli>I suggest to add the annotations for all variables.
Abdul>Please confirm if the first comment above addresses your concerns.

Thanks & Best Regards
Abdul Basit

-----Original Message-----
From: Eli Zaretskii <eliz@gnu.org> 
Sent: Friday, November 28, 2025 3:16 PM
To: Ijaz, Abdul B <abdul.b.ijaz@intel.com>
Cc: gdb-patches@sourceware.org; pedro@palves.net; philippe.waroquiers@skynet.be; aburgess@redhat.com; Aktemur, Tankut Baris <tankut.baris.aktemur@intel.com>; Schimpe, Christina <christina.schimpe@intel.com>; lsix@lancelotsix.com; tom@tromey.com
Subject: Re: [PATCH v11 1/2] gdb: add annotation in 'info locals' command for variables shadowing case

> From: Abdul Basit Ijaz <abdul.b.ijaz@intel.com>
> 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	<file.c:3>
> +y = 52
> +x = 3	<file.c:1, shadowed>
> +@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 <eliz@gnu.org>
Intel Deutschland GmbH
Registered Address: Dornacher Straße 1, 85622 Feldkirchen, Germany
Tel: +49 89 991 430, www.intel.de
Managing Directors: Harry Demas, Jeffrey Schneiderman, Yin Chong Sorrell
Chairperson of the Supervisory Board: Nicole Lau
Registered Seat: Munich
Commercial Register: Amtsgericht München HRB 186928

  reply	other threads:[~2025-11-28 14:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-28 12:03 [PATCH v11 0/2] " Abdul Basit Ijaz
2025-11-28 12:03 ` [PATCH v11 1/2] gdb: " Abdul Basit Ijaz
2025-11-28 14:15   ` Eli Zaretskii
2025-11-28 14:37     ` Ijaz, Abdul B [this message]
2025-11-28 15:23       ` Eli Zaretskii
2025-11-28 12:03 ` [PATCH v11 2/2] gdb: add shadowed field in '-stack-list-locals/variables' mi commands Abdul Basit Ijaz
2025-11-28 14:21   ` Eli Zaretskii
2025-11-28 15:09     ` Ijaz, Abdul B

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=SA1PR11MB6846BDC9397F07984BF04364CBDCA@SA1PR11MB6846.namprd11.prod.outlook.com \
    --to=abdul.b.ijaz@intel.com \
    --cc=aburgess@redhat.com \
    --cc=christina.schimpe@intel.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=lsix@lancelotsix.com \
    --cc=pedro@palves.net \
    --cc=philippe.waroquiers@skynet.be \
    --cc=tankut.baris.aktemur@intel.com \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox