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:
> On 22-Feb-2001, Eli Zaretskii wrote:
> >If we are to use an iterator, shouldn't the test in this loop be
> >abstracted as well, like this, for instance?
> Not necessarily: something like REGGROUP_FIRST_REGNUM and
> REGGROUP_NEXT_REGNUM are required for implementing multiple groups, but
> REGGROUP_NOT_LAST_REGNUM is consistent with the notion of changing integer
> register numbers into opaque identifiers (aka handles or cookies).
> But declaring that -1 is a reserved register identifier doesn't tie our
> hands much interface-wise.  It works pretty well for various UNIX file and
> memory interfaces.
> Maybe we need to establish some GDB coding policies about handles defined
> and passed around by abstract interfaces: should they be ints, struct
> pointers, typedefs, etc., and should there be a known-invalid value such
> as -1 or NULL?

To add to this, there are two classes of iterators:

	o	like the above where things don't
		change under your feet.

	o	nasty ones where where you're
		doing a transformation.  Vis:

		for everything in the old group
		   if blah
		      it stays in the group
		      it is removed from the group

		breakpoints have this problem but
		per my other comment that is a very
		separate problem to what is happening

For the simple first case, I think it is reasonable for a programmer to
expect the corresponding code to look like either:

	int group;
	for (group = ...; group >= 0; group = ...) { ... };
	struct reggroup *group;
	for (group = ...; group != NULL; group = ...) { ... }'

since in each case they are the natural sentinal.

In the integer case, the only thing I would encourage is that the test
be the looser but more robust ``... >= 0'' rather then the very exact
``... == -1''.


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