aboutsummaryrefslogtreecommitdiff
path: root/gdb/utils.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2019-01-23 18:58:29 +0000
committerPedro Alves <palves@redhat.com>2019-01-23 19:03:20 +0000
commit5b9b3e53a68f4568dc0b6907e34e763a6c3dd145 (patch)
tree88330e51c94cb494319813787fe23e42abeee4b1 /gdb/utils.c
parent54b65c9b51ec80ef5812dde1a508ce171eeb8ce6 (diff)
downloadgdb-5b9b3e53a68f4568dc0b6907e34e763a6c3dd145.zip
gdb-5b9b3e53a68f4568dc0b6907e34e763a6c3dd145.tar.gz
gdb-5b9b3e53a68f4568dc0b6907e34e763a6c3dd145.tar.bz2
Introduce forward_scope_exit
This adds a template that can be used to automatically instantiate scope_exit-like types that wrap some cleanup function. The instantiated type has a ctor that has the same interface as the wrapped function. While the "magic" is just straight C++11, the intended use is via the FORWARD_SCOPE_EXIT macro, which is a minimal macro that avoids spelling out the wrapped function name more than once: void some_function (int foo, object *bar); using some_function_fce = FORWARD_SCOPE_EXIT (some_function); some_function_fce cleanup (some_int, some_obj_ptr); The above runs: some_function (some_int, some_obj_ptr); at scope exit. This is mainly useful as opposed to a simpler SCOPE_EXIT when you need to: - cancel the scope_exit, in which case you need the object's name - wrap the scope_exit in a gdb::optional, in which case you need the scope_exit's type in advance. More details in the code comments. gdb/ChangeLog: 2019-01-23 Pedro Alves <palves@redhat.com> Andrew Burgess <andrew.burgess@embecosm.com> * common/forward-scope-exit.h: New file.
Diffstat (limited to 'gdb/utils.c')
0 files changed, 0 insertions, 0 deletions