Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: Shahab Vahedi <shahab.vahedi@gmail.com>
Cc: gdb-patches@sourceware.org, Shahab Vahedi <shahab@synopsys.com>,
	Claudiu Zissulescu <claziss@synopsys.com>,
	Francois Bedard <fbedard@synopsys.com>
Subject: Re: [PATCH] Do not print empty-group regs when printing general ones
Date: Mon, 20 Jan 2020 23:04:00 -0000	[thread overview]
Message-ID: <20200120205838.GG3865@embecosm.com> (raw)
In-Reply-To: <20200120155315.30333-1-shahab.vahedi@gmail.com>

* Shahab Vahedi <shahab.vahedi@gmail.com> [2020-01-20 16:53:15 +0100]:

> From: Shahab Vahedi <shahab@synopsys.com>
> 
> When the command "info registers" (same as "info registers general"),
> is issued, _all_ the registers from a tdesc XML are printed. This
> includes the registers with empty register groups (set as "") which
> are supposed to be only printed by "info registers all" (or "info
> all-registers").
> 
> This bug got introduced after all the overhauls that the
> tdesc_register_in_reggroup_p() went through. You can see that the
> logic of tdesc_register_in_reggroup_p() did NOT remain the same after
> all those changes:
> 
>   git difftool c9c895b9666..HEAD -- gdb/target-descriptions.c
> 
> With the current implementation, when the reg->group is an empty
> string, this function returns -1, while in the working revision
> (c9c895b9666), it returned 0. This patch makes sure that the 0 is
> returned again.
> 
> The old implementation of tdesc_register_in_reggroup_p() returned
> -1 when "reggroup" was set to "all_reggroups" at line 4 below:
> 
> 1  tdesc_register_reggroup_p (...)
> 2  {
> 3   ...
> 4   ret = tdesc_register_in_reggroup_p (gdbarch, regno, reggroup);
> 5   if (ret != -1)
> 6     return ret;
> 7
> 8   return default_register_reggroup_p (gdbarch, regno, reggroup);
> 9  }
> 
> As a result, the execution continued at line 8 and the
> default_register_reggroup_p(..., reggroup=all_reggroups) would
> return 1. However, with the current implementation of
> tdesc_register_in_reggroup_p() that allows checking against any
> arbitrary group name, it returns 0 when comparing the "reg->group"
> against the string "all" which is the group name for "all_reggroups".
> I have added a special check to cover this case and
> "info all-registers" works as expected.
> 
> gdb/ChangeLog:
> 2020-01-20  Shahab Vahedi  <shahab@synopsys.com>
> 
> 	* target-descriptions.c (tdesc_register_in_reggroup_p):
> 	Return 0 when reg->group is empty and reggroup is not.

Looks good to me.

Thanks,
Andrew



> ---
>  gdb/target-descriptions.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
> index 04711ba2fa5..937210cf25e 100644
> --- a/gdb/target-descriptions.c
> +++ b/gdb/target-descriptions.c
> @@ -977,13 +977,15 @@ tdesc_register_in_reggroup_p (struct gdbarch *gdbarch, int regno,
>  {
>    struct tdesc_reg *reg = tdesc_find_register (gdbarch, regno);
>  
> -  if (reg != NULL && !reg->group.empty ()
> -      && (reg->group == reggroup_name (reggroup)))
> +  if (reg != NULL)
> +    {
> +      if (reggroup == all_reggroup)
>  	return 1;
> -
> -  if (reg != NULL
> -      && (reggroup == save_reggroup || reggroup == restore_reggroup))
> -    return reg->save_restore;
> +      else if (reggroup == save_reggroup || reggroup == restore_reggroup)
> +	return reg->save_restore;
> +      else
> +	return (int) (reg->group == reggroup_name (reggroup));
> +    }
>  
>    return -1;
>  }
> -- 
> 2.25.0
> 


  reply	other threads:[~2020-01-20 20:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-20 17:29 Shahab Vahedi
2020-01-20 23:04 ` Andrew Burgess [this message]
     [not found] ` <CH2PR12MB3847E492663E7997CFAB1741A6070@CH2PR12MB3847.namprd12.prod.outlook.com>
2020-02-28 13:08   ` [Regression] " Luis Machado
2020-02-28 13:22     ` Christian Biesinger via gdb-patches
     [not found]       ` <9c256b27-4a00-8830-46e2-934922e39cc2@linaro.org>
2020-02-28 13:36         ` Shahab Vahedi
2020-02-28 13:51           ` Luis Machado
2020-02-28 14:08             ` Shahab Vahedi
2020-02-28 14:11               ` Christian Biesinger via gdb-patches
2020-02-28 14:15                 ` Shahab Vahedi
2020-03-04 13:17                   ` Luis Machado
2020-03-04 15:21                     ` Shahab Vahedi
2020-03-04 16:14                       ` Luis Machado

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=20200120205838.GG3865@embecosm.com \
    --to=andrew.burgess@embecosm.com \
    --cc=claziss@synopsys.com \
    --cc=fbedard@synopsys.com \
    --cc=gdb-patches@sourceware.org \
    --cc=shahab.vahedi@gmail.com \
    --cc=shahab@synopsys.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