binutils-gdb/gdb/common
Pedro Alves 7c44b49cb6 Introduce gdb::array_view
An array_view is an abstraction that provides a non-owning view over a
sequence of contiguous objects.

A way to put it is that array_view is to std::vector (and std::array
and built-in arrays with rank==1) like std::string_view is to
std::string.

The main intent of array_view is to use it as function input parameter
type, making it possible to pass in any sequence of contiguous
objects, irrespective of whether the objects live on the stack or heap
and what actual container owns them.  Implicit construction from the
element type is supported too, making it easy to call functions that
expect an array of elements when you only have one element (usually on
the stack).  For example:

 struct A { .... };
 void function (gdb::array_view<A> as);

 std::vector<A> std_vec = ...;
 std::array<A, N> std_array = ...;
 A array[] = {...};
 A elem;

 function (std_vec);
 function (std_array);
 function (array);
 function (elem);

Views can be either mutable or const.  A const view is simply created
by specifying a const T as array_view template parameter, in which
case operator[] of non-const array_view objects ends up returning
const references.  (Making the array_view itself const is analogous to
making a pointer itself be const.  I.e., disables re-seating the
view/pointer.)  Normally functions will pass around array_views by
value.

Uses of gdb::array_view (other than the ones in the unit tests) will
be added in a follow up patch.

gdb/ChangeLog
2017-09-04  Pedro Alves  <palves@redhat.com>

	* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
	unittests/array-view-selftests.c.
	(SUBDIR_UNITTESTS_OBS): Add array-view-selftests.o.
	* common/array-view.h: New file.
	* unittests/array-view-selftests.c: New file.
2017-09-04 17:10:12 +01:00
..
agent.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
agent.h Add STRINGIFY to gdb/common/preprocessor.h 2017-06-22 10:59:42 +01:00
array-view.h Introduce gdb::array_view 2017-09-04 17:10:12 +01:00
ax.def update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
break-common.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
btrace-common.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
btrace-common.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
buffer.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
buffer.h buffer.h: Fix spelling mistakes 2017-07-03 13:59:00 +02:00
byte-vector.h Introduce gdb::byte_vector, add allocator that default-initializes 2017-06-14 11:08:52 +01:00
cleanups.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
cleanups.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
common-debug.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
common-debug.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
common-defs.h Poison non-POD memset & non-trivially-copyable memcpy/memmove 2017-04-25 01:46:19 +01:00
common-exceptions.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
common-exceptions.h DWARF-5: call sites 2017-02-20 21:00:55 +01:00
common-gdbthread.h Share parts of gdb/gdbthread.h with gdbserver 2017-06-07 19:56:01 -04:00
common-inferior.h Share fork_inferior et al with gdbserver 2017-06-07 19:56:09 -04:00
common-regcache.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
common-regcache.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
common-types.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
common-utils.c Fix possible bug when no args have been provided to the executable 2017-06-08 16:58:25 -04:00
common-utils.h Share fork_inferior et al with gdbserver 2017-06-07 19:56:09 -04:00
common.host update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
common.m4 Create gdb_termios.h (and cleanup gdb/{,gdbserver/}terminal.h) 2017-04-12 17:59:45 -04:00
create-version.sh update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
def-vector.h Introduce gdb::byte_vector, add allocator that default-initializes 2017-06-14 11:08:52 +01:00
default-init-alloc.h Introduce gdb::byte_vector, add allocator that default-initializes 2017-06-14 11:08:52 +01:00
diagnostics.h vec: Silence -Wunused-function warnings on clang 2017-06-26 16:51:17 +02:00
enum-flags.h Don't memcpy non-trivially-copyable types: Make enum_flags triv. copyable 2017-04-25 01:42:03 +01:00
environ.c Implement the ability to set/unset environment variables to GDBserver when starting the inferior 2017-08-31 17:22:10 -04:00
environ.h Implement the ability to set/unset environment variables to GDBserver when starting the inferior 2017-08-31 17:22:10 -04:00
errors.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
errors.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
fileio.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
fileio.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
filestuff.c Introduce and use gdb_file_up 2017-08-03 07:58:52 -06:00
filestuff.h Introduce and use gdb_file_up 2017-08-03 07:58:52 -06:00
format.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
format.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
function-view.h Poison non-POD memset & non-trivially-copyable memcpy/memmove 2017-04-25 01:46:19 +01:00
gdb_assert.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
gdb_locale.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
gdb_optional.h More gdb::optional features 2017-04-18 23:48:41 +01:00
gdb_ref_ptr.h Use class to manage BFD reference counts 2017-01-10 19:14:10 -07:00
gdb_setjmp.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
gdb_signals.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
gdb_sys_time.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
gdb_termios.h Create gdb_termios.h (and cleanup gdb/{,gdbserver/}terminal.h) 2017-04-12 17:59:45 -04:00
gdb_unique_ptr.h Allow gdb::unique_xmalloc_ptr<T[]> 2017-08-10 14:18:02 +01:00
gdb_unlinker.h gdb: Fix ATTRIBUTE_NONNULL usage 2017-03-08 15:52:16 +00:00
gdb_vecs.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
gdb_vecs.h Remove definition of VEC (CORE_ADDR) 2017-05-02 13:30:09 -04:00
gdb_wait.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
host-defs.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
job-control.c Move parts of inferior job control to common/ 2017-06-07 19:52:56 -04:00
job-control.h Move parts of inferior job control to common/ 2017-06-07 19:52:56 -04:00
mingw-strerror.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
new-op.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
offset-type.h Make sect_offset and cu_offset strong typedefs instead of structs 2017-04-04 20:03:26 +01:00
poison.h Fix build on gcc < 5 (std::is_trivially_copyable missing) 2017-04-25 10:58:57 +01:00
posix-strerror.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
preprocessor.h Add STRINGIFY to gdb/common/preprocessor.h 2017-06-22 10:59:42 +01:00
print-utils.c -Wwrite-strings: The Rest 2017-04-05 19:21:37 +01:00
print-utils.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
ptid.c Class-ify ptid_t 2017-04-06 23:29:53 -04:00
ptid.h Class-ify ptid_t 2017-04-06 23:29:53 -04:00
queue.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
refcounted-object.h Fix removing inferiors from within "thread apply" commands 2017-04-19 13:12:23 +01:00
rsp-low.c Implement the ability to set/unset environment variables to GDBserver when starting the inferior 2017-08-31 17:22:10 -04:00
rsp-low.h Implement the ability to set/unset environment variables to GDBserver when starting the inferior 2017-08-31 17:22:10 -04:00
run-time-clock.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
run-time-clock.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
scoped_restore.h Make inferior::detaching a bool, and introduce scoped_restore::release() 2017-04-19 13:12:23 +01:00
selftest.c GDBserver self tests 2017-08-18 09:20:43 +01:00
selftest.h GDBserver self tests 2017-08-18 09:20:43 +01:00
signals-state-save-restore.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
signals-state-save-restore.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
signals.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
symbol.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
traits.h Fix build on gcc < 5 (std::is_trivially_copyable missing) 2017-04-25 10:58:57 +01:00
underlying.h dwarf2read.c: Make dir_index and file_name_index strong typedefs 2017-04-04 20:03:25 +01:00
valid-expr.h Make sect_offset and cu_offset strong typedefs instead of structs 2017-04-04 20:03:26 +01:00
vec.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
vec.h vec: Silence -Wunused-function warnings on clang 2017-06-26 16:51:17 +02:00
version.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
x86-xstate.h Add support for Intel PKRU register to GDB and GDBserver. 2017-02-17 11:44:48 +01:00
xml-utils.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
xml-utils.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00