Simon Marchi 610cfd618e Compare iterators, not values, in filtered_iterator::operator{==,!=}
The == and != operators on filtered_iterator are not doing the
right thing, they compare values pointed by the wrapped iterators
instead of comparing the iterators themselves.

As a result, operator== will return true if the two iterators point to
two equal values at different positions.  operator!= will fail
similarly.

Also, this causes it to deference past-the-end iterators when doing.
For example, in

  for (iter = ...; iter != end_iter; ++iter)

the != comparison dereferences end_iter.  I don't think this should
happen.

I don't think it's a problem today, given that we only use
filtered_iterator to wrap linked lists of threads and inferiors.
Dereferencing past-the-end iterators of these types is not fatal, it
just returns NULL, which is not a value we otherwise find in the lists.
But in other contexts, it could become problematic.

I have added a simple self test that fails without the fix applied.

gdb/ChangeLog:

	* filtered-iterator.h (filtered_iterator) <operator==,
	operator!=>: Compare wrapped iterators, not wrapped pointers.
	* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
	unittests/filtered_iterator-selftests.c.
	* unittests/filtered_iterator-selftests.c: New file.
2019-12-04 13:27:56 -05:00
..
2019-10-31 13:28:14 -05:00
2019-10-31 13:28:14 -05:00
2019-11-15 11:48:08 -08:00
2019-11-26 14:02:58 -07:00
2019-11-21 14:39:40 -07:00
2019-11-12 23:46:41 +00:00
2019-11-10 20:09:59 +00:00
2019-08-23 13:13:18 -04:00
2019-11-26 14:02:58 -07:00
2019-11-26 14:02:58 -07:00
2019-11-26 14:02:57 -07:00