Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Abdul Basit Ijaz <abdul.b.ijaz@intel.com>
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
Subject: Re: [PATCH v11 1/2] gdb: add annotation in 'info locals' command for variables shadowing case
Date: Fri, 28 Nov 2025 16:15:44 +0200	[thread overview]
Message-ID: <86zf868cq7.fsf@gnu.org> (raw)
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)

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

  reply	other threads:[~2025-11-28 14:18 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 [this message]
2025-11-28 14:37     ` Ijaz, Abdul B
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=86zf868cq7.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=abdul.b.ijaz@intel.com \
    --cc=aburgess@redhat.com \
    --cc=christina.schimpe@intel.com \
    --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