8sa1-binutils-gdb/gdb/common
Pedro Alves 54b65c9b51 Introduce scope_exit
This add a new template class scope_exit.  scope_exit is a
general-purpose scope guard that calls its exit function at the end of
the current scope.  A scope_exit may be canceled by calling the
"release" method.  The API is modeled on P0052R5 - Generic Scope Guard
and RAII Wrapper for the Standard Library, which is itself based on
Andrej Alexandrescu's ScopeGuard/SCOPE_EXIT.

The main advantage of scope_exit is avoiding writing single-use RAII
classes and its boilerplate.  Following patches will remove a few of
such classes.

There are two forms available:

 - The "make_scope_exit" form allows canceling the scope guard.  Use
   it like this:

     auto cleanup = make_scope_exit ( <function, function object, lambda> );
     ...
     cleanup.release (); // cancel

 - If you don't need to cancel the guard, you can use the SCOPE_EXIT
   macro, like this:

     SCOPE_EXIT { /* any code you like here. */ }

Note: scope_exit instances do not allocate anything on the heap.

gdb/ChangeLog:
2019-01-23  Pedro Alves  <palves@redhat.com>
	    Andrew Burgess  <andrew.burgess@embecosm.com>
	    Tom Tromey  <tom@tromey.com>

	* common/scope-exit.h: New file.
2019-01-23 19:02:58 +00:00
..
agent.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
agent.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
array-view.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
ax.def Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
break-common.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
btrace-common.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
btrace-common.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
buffer.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
buffer.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
byte-vector.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
cleanups.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
cleanups.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
common-debug.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
common-debug.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
common-defs.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
common-exceptions.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
common-exceptions.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
common-gdbthread.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
common-inferior.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
common-regcache.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
common-regcache.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
common-types.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
common-utils.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
common-utils.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
common.host Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
common.m4 Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
create-version.sh Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
def-vector.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
default-init-alloc.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
enum-flags.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
environ.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
environ.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
errors.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
errors.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
fileio.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
fileio.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
filestuff.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
filestuff.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
filtered-iterator.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
format.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
format.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
function-view.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
gdb_assert.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
gdb_locale.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
gdb_optional.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
gdb_proc_service.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
gdb_ref_ptr.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
gdb_setjmp.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
gdb_signals.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
gdb_splay_tree.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
gdb_string_view.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
gdb_string_view.tcc Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
gdb_sys_time.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
gdb_tilde_expand.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
gdb_tilde_expand.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
gdb_unique_ptr.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
gdb_unlinker.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
gdb_vecs.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
gdb_vecs.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
gdb_wait.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
hash_enum.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
host-defs.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
job-control.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
job-control.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
mingw-strerror.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
netstuff.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
netstuff.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
new-op.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
next-iterator.h Remove ALL_OBJFILES_SAFE 2019-01-09 18:28:14 -07:00
observable.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
offset-type.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
pathstuff.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
pathstuff.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
poison.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
posix-strerror.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
preprocessor.h Rename ESC -> ESC_PARENS 2019-01-23 18:58:28 +00:00
print-utils.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
print-utils.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
ptid.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
ptid.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
queue.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
refcounted-object.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
rsp-low.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
rsp-low.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
run-time-clock.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
run-time-clock.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
safe-iterator.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
scope-exit.h Introduce scope_exit 2019-01-23 19:02:58 +00:00
scoped_fd.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
scoped_mmap.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
scoped_mmap.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
scoped_restore.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
selftest.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
selftest.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
signals-state-save-restore.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
signals-state-save-restore.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
signals.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
symbol.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
tdesc.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
tdesc.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
traits.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
underlying.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
valid-expr.h Rename ESC -> ESC_PARENS 2019-01-23 18:58:28 +00:00
vec.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
vec.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
version.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
x86-xstate.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
xml-utils.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
xml-utils.h Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00