Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Stafford Horne <shorne@gmail.com>
To: Simon Marchi <simon.marchi@polymtl.ca>
Cc: GDB patches <gdb-patches@sourceware.org>,
	Openrisc <openrisc@lists.librecores.org>
Subject: Re: [PATCH v3 4/4] tdesc: handle arbitrary strings in tdesc_register_in_reggroup_p
Date: Thu, 21 Dec 2017 12:55:00 -0000	[thread overview]
Message-ID: <20171221125552.GE32243@lianli.shorne-pla.net> (raw)
In-Reply-To: <842bc3de1ad8cd8a568127aedeb58275@polymtl.ca>

On Wed, Dec 20, 2017 at 10:29:31PM -0500, Simon Marchi wrote:
> On 2017-12-19 09:22, Stafford Horne wrote:
> > @@ -1299,26 +1294,9 @@ 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 ())
> > -    {
> > -      int general_p = 0, float_p = 0, vector_p = 0;
> > -
> > -      if (reg->group == "general")
> > -	general_p = 1;
> > -      else if (reg->group == "float")
> > -	float_p = 1;
> > -      else if (reg->group == "vector")
> > -	vector_p = 1;
> > -
> > -      if (reggroup == float_reggroup)
> > -	return float_p;
> > -
> > -      if (reggroup == vector_reggroup)
> > -	return vector_p;
> > -
> > -      if (reggroup == general_reggroup)
> > -	return general_p;
> > -    }
> > +  if (reg != NULL && !reg->group.empty ()
> > +      && (strcmp (reg->group.c_str (), reggroup_name (reggroup)) == 0))
> 
> I suggest
> 
>   reg->group == reggroup_name (reggroup)

OK. Strange, I thought I tried that first but was having issues with std::string
vs (char *), but I just tried again and it works fine.

> > +	return 1;
> > 
> >    if (reg != NULL
> >        && (reggroup == save_reggroup || reggroup == restore_reggroup))
> > @@ -1421,6 +1399,28 @@ tdesc_use_registers (struct gdbarch *gdbarch,
> >  	void **slot = htab_find_slot (reg_hash, reg.get (), INSERT);
> > 
> >  	*slot = reg.get ();
> > +	/* Add reggroup if its new.  */
> > +	if (!reg->group.empty ())
> > +	  {
> > +	    struct reggroup *group;
> > +	    bool group_exists = false;
> > +
> > +	    for (group = reggroup_next (gdbarch, NULL);
> > +		 group != NULL;
> > +		 group = reggroup_next (gdbarch, group))
> > +	      {
> > +		if (strcmp (reg->group.c_str (), reggroup_name (group)) == 0)
> 
> Here too.

OK.

> > +		  {
> > +		    group_exists = true;
> > +		    break;
> > +		  }
> > +	      }
> > +
> > +	    if (!group_exists)
> > +	      reggroup_add (gdbarch, reggroup_gdbarch_new (gdbarch,
> > +							   reg->group.c_str (),
> > +							   USER_REGGROUP));
> > +	  }
> 
> Could you factor this out in a separate function?  It would probably be
> useful to have a general-purpose function
> 
>   reggroup *reggroup_find (struct gdbarch *gdbarch, const char *name);
> 
> Which you could then use here
> 
>   if (reggroup_find (...) == NULL)
>     {
>       // Create group
>     }

Sure good point, if I find any places I can use it I will.

Thank You,

-Stafford


  reply	other threads:[~2017-12-21 12:55 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-19 14:23 [PATCH v3 0/4] Support for arbitrary reggroups Stafford Horne
2017-12-19 14:23 ` [PATCH v3 1/4] reggroups: Add test and docs for `info reg $reggroup` feature Stafford Horne
2017-12-19 16:23   ` Eli Zaretskii
2017-12-20 10:40     ` Stafford Horne
2017-12-21  2:40     ` Simon Marchi
2017-12-21  3:40       ` Eli Zaretskii
2017-12-21  2:59   ` Simon Marchi
2017-12-24 14:47     ` Stafford Horne
2017-12-19 14:23 ` [PATCH v3 4/4] tdesc: handle arbitrary strings in tdesc_register_in_reggroup_p Stafford Horne
2017-12-19 16:27   ` Eli Zaretskii
2017-12-19 22:13     ` Stafford Horne
2017-12-20 13:35       ` Stafford Horne
2017-12-20 16:37       ` Eli Zaretskii
2017-12-21  3:29   ` Simon Marchi
2017-12-21 12:55     ` Stafford Horne [this message]
2017-12-19 14:23 ` [PATCH v3 3/4] reggroups: Create reggroup_gdbarch_new for dynamic reggroups Stafford Horne
2017-12-21  3:15   ` Simon Marchi
2017-12-19 14:23 ` [PATCH v3 2/4] reggroups: Convert reggroups from post_init to pre_init Stafford Horne
2017-12-21  3:03   ` Simon Marchi

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=20171221125552.GE32243@lianli.shorne-pla.net \
    --to=shorne@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=openrisc@lists.librecores.org \
    --cc=simon.marchi@polymtl.ca \
    /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