Go to file
Simon Marchi 9be259865c gdb: introduce iterator_range, remove next_adapter
I was always a bit confused by next_adapter, because it kind of mixes
the element type and the iterator type.  In reality, it is not much more
than a class that wraps two iterators (begin and end).  However, it
assumes that:

 - you can construct the begin iterator by passing a pointer to the
   first element of the iterable
 - you can default-construct iterator to make the end iterator

I think that by generalizing it a little bit, we can re-use it at more
places.

Rename it to "iterator_range".  I think it describes a bit better: it's
a range made by wrapping a begin and end iterator.  Move it to its own
file, since it's not related to next_iterator anymore.

iterator_range has two constructors.  The variadic one, where arguments
are forwarded to construct the underlying begin iterator.  The end
iterator is constructed through default construction.  This is a
generalization of what we have today.

There is another constructor which receives already constructed begin
and end iterators, useful if the end iterator can't be obtained by
default-construction.  Or, if you wanted to make a range that does not
end at the end of the container, you could pass any iterator as the
"end".

This generalization allows removing some "range" classes, like
all_inferiors_range.  These classes existed only to pass some arguments
when constructing the begin iterator.  With iterator_range, those same
arguments are passed to the iterator_range constructed and then
forwarded to the constructed begin iterator.

There is a small functional difference in how iterator_range works
compared to next_adapter.  next_adapter stored the pointer it received
as argument and constructeur an iterator in the `begin` method.
iterator_range constructs the begin iterator and stores it as a member.
Its `begin` method returns a copy of that iterator.

With just iterator_range, uses of next_adapter<foo> would be replaced
with:

  using foo_iterator = next_iterator<foo>;
  using foo_range = iterator_range<foo_iterator>;

However, I added a `next_range` wrapper as a direct replacement for
next_adapter<foo>.  IMO, next_range is a slightly better name than
next_adapter.

The rest of the changes are applications of this new class.

gdbsupport/ChangeLog:

	* next-iterator.h (class next_adapter): Remove.
	* iterator-range.h: New.

gdb/ChangeLog:

	* breakpoint.h (bp_locations_range): Remove.
	(bp_location_range): New.
	(struct breakpoint) <locations>: Adjust type.
	(breakpoint_range): Use iterator_range.
	(tracepoint_range): Use iterator_range.
	* breakpoint.c (breakpoint::locations): Adjust return type.
	* gdb_bfd.h (gdb_bfd_section_range): Use iterator_range.
	* gdbthread.h (all_threads_safe): Pass argument to
	all_threads_safe_range.
	* inferior-iter.h (all_inferiors_range): Use iterator_range.
	(all_inferiors_safe_range): Use iterator_range.
	(all_non_exited_inferiors_range): Use iterator_range.
	* inferior.h (all_inferiors, all_non_exited_inferiors): Pass
	inferior_list as argument.
	* objfiles.h (struct objfile) <compunits_range>: Remove.
	<compunits>: Return compunit_symtab_range.
	* progspace.h (unwrapping_objfile_iterator)
	<unwrapping_objfile_iterator>: Take parameter by value.
	(unwrapping_objfile_range): Use iterator_range.
	(struct program_space) <objfiles_range>: Define with "using".
	<objfiles>: Adjust.
	<objfiles_safe_range>: Define with "using".
	<objfiles_safe>: Adjust.
	<solibs>: Return so_list_range, define here.
	* progspace.c (program_space::solibs): Remove.
	* psymtab.h (class psymtab_storage) <partial_symtab_iterator>:
	New.
	<partial_symtab_range>: Use iterator_range.
	* solist.h (so_list_range): New.
	* symtab.h (compunit_symtab_range):
	New.
	(symtab_range): New.
	(compunit_filetabs): Change to a function.
	* thread-iter.h (inf_threads_range,
	inf_non_exited_threads_range, safe_inf_threads_range,
	all_threads_safe_range): Use iterator_range.
	* top.h (ui_range): New.
	(all_uis): Use ui_range.

Change-Id: Ib7a9d2a3547f45f01aa1c6b24536ba159db9b854
2021-07-06 15:02:05 -04:00
bfd PR 28053: Fix spelling mistakes: usupported -> unsupported and relocatation -> relocation. 2021-07-06 14:56:05 +01:00
binutils RISC-V: Add PT_RISCV_ATTRIBUTES and add it to PHDR. 2021-07-06 11:34:36 +08:00
config Add markers for 2.37 branch 2021-07-03 14:50:57 +01:00
contrib Import mklog.py from gcc repo 2020-09-25 10:24:44 -04:00
cpu Re: opcodes: constify & local meps macros 2021-07-05 21:40:49 +09:30
elfcpp Add markers for 2.37 branch 2021-07-03 14:50:57 +01:00
etc Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
gas PR 28053: Fix spelling mistakes: usupported -> unsupported and relocatation -> relocation. 2021-07-06 14:56:05 +01:00
gdb gdb: introduce iterator_range, remove next_adapter 2021-07-06 15:02:05 -04:00
gdbserver gdbsupport/common.m4: check for sigtimedwait 2021-07-05 09:54:35 -04:00
gdbsupport gdb: introduce iterator_range, remove next_adapter 2021-07-06 15:02:05 -04:00
gnulib gnulib: define the path to gnulib's parent dir 2021-06-14 18:01:20 -04:00
gold Updated translations (mainly Ukranian and French) triggered by creation of 2.37 branch. 2021-07-05 15:54:35 +01:00
gprof Updated translations (mainly Ukranian and French) triggered by creation of 2.37 branch. 2021-07-05 15:54:35 +01:00
include RISC-V: Add PT_RISCV_ATTRIBUTES and add it to PHDR. 2021-07-06 11:34:36 +08:00
intl GNU gettext introduced this change[0] in version 0.19.8 to fix gettext detection with musl libc, since it does not define these internal symbols. 2021-06-14 14:05:39 +01:00
ld elf/riscv: Fix relaxation with aliases [PR28021] 2021-07-06 15:49:03 +02:00
libctf Add markers for 2.37 branch 2021-07-03 14:50:57 +01:00
libdecnumber Run autoreconf -vf throughout 2020-07-29 16:03:55 -04:00
libiberty Restore the libiberty component of commit 50ad1254d5. 2021-07-05 16:21:42 +01:00
opcodes Updated translations (mainly Ukranian and French) triggered by creation of 2.37 branch. 2021-07-05 15:54:35 +01:00
readline Update config.sub and config.guess for MIPS R3 and R5 ISA support 2021-05-24 18:11:49 +02:00
sim sim: ppc: add missing empty targets 2021-07-06 11:47:50 -04:00
texinfo
zlib GCC: Check if AR works with --plugin and rc 2021-01-11 16:26:51 -08:00
.cvsignore
.gitattributes
.gitignore Add gnu global outputs to .gitignore 2020-12-02 10:00:27 -05:00
ar-lib Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
ChangeLog Add markers for 2.37 branch 2021-07-03 14:50:57 +01:00
compile
config-ml.in Update top level configure files by synchronizing them with gcc. 2018-01-10 15:29:21 +00:00
config.guess Update config.sub and config.guess for MIPS R3 and R5 ISA support 2021-05-24 18:11:49 +02:00
config.rpath
config.sub Update config.sub and config.guess for MIPS R3 and R5 ISA support 2021-05-24 18:11:49 +02:00
configure sim: leverage gnulib 2021-05-29 11:56:43 -04:00
configure.ac sim: leverage gnulib 2021-05-29 11:56:43 -04:00
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
COPYING.LIBGLOSS Update the address of the FSF in the copyright notice of files which were using the old address. 2017-12-14 12:48:55 +00:00
COPYING.NEWLIB
depcomp
djunpack.bat
install-sh
libtool.m4 GCC: Check if AR works with --plugin and rc 2021-01-11 16:26:51 -08:00
lt~obsolete.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
MAINTAINERS MAINTAINERS: Update path to readline config.{sub,guess} files 2021-05-24 18:11:49 +02:00
Makefile.def sim: depend on gnulib 2021-05-18 17:47:27 -04:00
Makefile.in sim: depend on gnulib 2021-05-18 17:47:27 -04:00
Makefile.tpl Add missing changes to Makefile.tpl 2021-02-28 04:39:38 -08:00
makefile.vms
missing
mkdep
mkinstalldirs
move-if-change
multilib.am Merge autoconf / automake update changes from GCC. 2018-10-31 17:10:56 +00:00
README
README-maintainer-mode Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
setup.com
src-release.sh src-release: fix indentation 2021-01-12 18:19:20 -05:00
symlink-tree
test-driver Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
ylwrap

		   README for GNU development tools

This directory contains various GNU compilers, assemblers, linkers, 
debuggers, etc., plus their support routines, definitions, and documentation.

If you are receiving this as part of a GDB release, see the file gdb/README.
If with a binutils release, see binutils/README;  if with a libg++ release,
see libg++/README, etc.  That'll give you info about this
package -- supported targets, how to use it, how to report bugs, etc.

It is now possible to automatically configure and build a variety of
tools with one command.  To build all of the tools contained herein,
run the ``configure'' script here, e.g.:

	./configure 
	make

To install them (by default in /usr/local/bin, /usr/local/lib, etc),
then do:
	make install

(If the configure script can't determine your type of computer, give it
the name as an argument, for instance ``./configure sun4''.  You can
use the script ``config.sub'' to test whether a name is recognized; if
it is, config.sub translates it to a triplet specifying CPU, vendor,
and OS.)

If you have more than one compiler on your system, it is often best to
explicitly set CC in the environment before running configure, and to
also set CC when running make.  For example (assuming sh/bash/ksh):

	CC=gcc ./configure
	make

A similar example using csh:

	setenv CC gcc
	./configure
	make

Much of the code and documentation enclosed is copyright by
the Free Software Foundation, Inc.  See the file COPYING or
COPYING.LIB in the various directories, for a description of the
GNU General Public License terms under which you can copy the files.

REPORTING BUGS: Again, see gdb/README, binutils/README, etc., for info
on where and how to report problems.