This is the mail archive of the
mailing list for the GDB project.
[binutils-gdb] Introduce forward_scope_exit
- From: sergiodj+buildbot at sergiodj dot net
- To: gdb-testers at sourceware dot org
- Date: Wed, 23 Jan 2019 14:52:17 -0500
- Subject: [binutils-gdb] Introduce forward_scope_exit
*** TEST RESULTS FOR COMMIT 5b9b3e53a68f4568dc0b6907e34e763a6c3dd145 ***
Author: Pedro Alves <email@example.com>
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
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
- 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.
2019-01-23 Pedro Alves <firstname.lastname@example.org>
Andrew Burgess <email@example.com>
* common/forward-scope-exit.h: New file.
- Failures on RHEL-s390x-m64, branch master
- Failures on Debian-s390x-native-extended-gdbserver-m64, branch master
- Failures on Debian-s390x-native-gdbserver-m64, branch master
- Failures on Debian-s390x-m64, branch master
- Failures on Fedora-i686, branch master
- Failures on Fedora-x86_64-cc-with-index, branch master
- Failures on Fedora-x86_64-native-extended-gdbserver-m32, branch master
- Failures on Fedora-x86_64-m64, branch master
- Failures on Fedora-x86_64-m32, branch master
- Failures on Fedora-x86_64-native-gdbserver-m32, branch master