public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Lancelot SIX <lsix@lancelotsix.com>
To: Abdul Basit Ijaz <abdul.b.ijaz@intel.com>
Cc: gdb-patches@sourceware.org, pedro@palves.net
Subject: Re: [PATCH v3 2/2] gdb: add shadowed field in '-stack-list-locals/variables' mi commands
Date: Mon, 18 Sep 2023 23:53:23 +0100	[thread overview]
Message-ID: <20230918225323.n526b3ubkkzvzsbe@octopus> (raw)
In-Reply-To: <20230918164738.17082-3-abdul.b.ijaz@intel.com>

Hi Abdul,

I think some of the comments I had on the previous patch also apply to
this one.

> diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
> index e473be7d465..7e4658ef415 100644
> --- a/gdb/mi/mi-cmd-stack.c
> +++ b/gdb/mi/mi-cmd-stack.c
> @@ -559,6 +575,30 @@ list_arg_or_local (const struct frame_arg *arg, enum what_to_list what,
>  	}
>        uiout->field_stream ("value", stb);
>      }
> +
> +  /* Only for C/C++/Fortran/Ada languages, in case of variables shadowing
> +     print shadowed field after the superblock variable and only location
> +     of the variables in the innerblock.  */
> +  if ((current_language->la_language == language_c
> +       || current_language->la_language == language_cplus
> +       || current_language->la_language == language_fortran
> +       || current_language->la_language == language_ada)
> +       && !(values == PRINT_NO_VALUES && what == locals)
> +       && shadowed)
> +    {
> +      std::string file_path = arg->sym->owner.symtab->filename;
> +      size_t slash_index = file_path.find_last_of ("\\/");
> +      std::string file_name = (!file_path.empty ()
> +			       ? file_path.substr (slash_index + 1)
> +			       : "NA");
> +      uiout->field_string ("file", file_name);
> +      if (arg->sym->m_line > 0)
> +	uiout->field_unsigned ("line", arg->sym->m_line);
> +      else
> +	uiout->field_string ("line", "NA");
> +      if (already_printed)
> +	uiout->field_string ("Shadowed", "True");
                              ^
I don't use MI much, but the uppercase 'S' seems odd.  For consistency,
I think it would be better left lowercase.  WDYT?

Best,
Lancelot.

> +    }
>  }
>  
>  /* Print a list of the objects for the frame FI in a certain form,

  reply	other threads:[~2023-09-18 22:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-18 16:47 [PATCH v3 0/2] add annotation in 'info locals' command for variables shadowing case Abdul Basit Ijaz
2023-09-18 16:47 ` [PATCH v3 1/2] gdb: " Abdul Basit Ijaz
2023-09-18 22:46   ` Lancelot SIX
2023-09-19  7:50     ` Ijaz, Abdul B
2023-09-18 16:47 ` [PATCH v3 2/2] gdb: add shadowed field in '-stack-list-locals/variables' mi commands Abdul Basit Ijaz
2023-09-18 22:53   ` Lancelot SIX [this message]
2023-09-19 11:41     ` Ijaz, Abdul B
2023-09-19 13:20       ` Lancelot SIX
2023-09-19 15:46         ` 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=20230918225323.n526b3ubkkzvzsbe@octopus \
    --to=lsix@lancelotsix.com \
    --cc=abdul.b.ijaz@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@palves.net \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).