aboutsummaryrefslogtreecommitdiff
path: root/gdb/Makefile.in
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2019-12-04 13:27:21 -0500
committerSimon Marchi <simon.marchi@efficios.com>2019-12-04 13:27:56 -0500
commit610cfd618e4ea43a106d2b24ae4fe52af72de1f5 (patch)
treefb08ac03e354e45224e97542cf1693c030baef3e /gdb/Makefile.in
parentf47674be8e90a84edae49ec2b781201ea2f050bd (diff)
downloadgdb-610cfd618e4ea43a106d2b24ae4fe52af72de1f5.zip
gdb-610cfd618e4ea43a106d2b24ae4fe52af72de1f5.tar.gz
gdb-610cfd618e4ea43a106d2b24ae4fe52af72de1f5.tar.bz2
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.
Diffstat (limited to 'gdb/Makefile.in')
-rw-r--r--gdb/Makefile.in1
1 files changed, 1 insertions, 0 deletions
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index e5c8faa..67fa1df 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -422,6 +422,7 @@ SUBDIR_UNITTESTS_SRCS = \
unittests/common-utils-selftests.c \
unittests/copy_bitwise-selftests.c \
unittests/environ-selftests.c \
+ unittests/filtered_iterator-selftests.c \
unittests/format_pieces-selftests.c \
unittests/function-view-selftests.c \
unittests/help-doc-selftests.c \