This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Register group proposal

Nick Duffek wrote:

Several thoughts on the interface.  Again mostly generic.


Rather than a simple integer, should reggroup be made an object vis
``struct reggroup *''?

I think one of the maintenance problems with GDB's current internals is
that it uses integers for many and varied things.  It is just too easy
to pass an integer intended for one purpose to a function where the
meaning is different.  It is also too easy to extract implied
information from it.

As an example, GDB kicks around a REGNUM when, it really means two
separate things - a register that is part of a frame; and an entry in
the raw register cache.  If REGNUM, was strongly typed the separation of
the two uses would be forced.  While that won't happen to REGNUM for a
very long time, I would like newer types to be made strongly typed so
that the same mistakes are less likely to happen again.

This may affect things like ``REGISTER_GROUPS()''.

Even if it isn't made an object could I suggest the convention of a
...._REGGROUP() be adopted to all methods that return a register group.


The interface defines an iterator:

>   /* Return the number of the first register to display in GROUP, which is
>      an index in REGISTER_GROUPS.  */
>   int REGISTER_INFO_FIRST (int group)
>   /* Return the number of the register to display after register REGNUM
>      in GROUP, which is an index in REGISTER_GROUPS.  If no registers
>      should be displayed after register REGNUM, return -1.  */
>   int REGISTER_INFO_NEXT (int group, int regnum)

I guess this is called as something like (I'll take the liberty of using
slightly different names):

	for (regnum = REGGROUP_FIRST_REGNUM (reggroup);
	     regnum >= 0;
	     retnum = REGGROUP_NEXT_REGNUM (reggroup, regnum))
	     apply regnum;

As an iterator it is the natural choice.  Perhaphs it should be adopted
as the convention to use when both a GDB object needs an iterator and
the members of that list are constant (reggrop won't change but the
breakpoint list could change).


>   /* Return a null-terminated list of register group
> names.  */
>   char **REGISTER_GROUPS (void)

Would such a table be released using freeargv() like many of the BFD

>   /* Return the REGISTER_GROUPS index of the group that
> "info registers"
>      should display.  */
>   int REGISTERS_SOME (void)



>   /* Return the REGISTER_GROUPS index of the group that
> "info
>      all-registers" should display.  */
>   int REGISTERS_ALL (void)

Hmm, is there a case when ``info all-registers'' doesn't display all the


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]