diff options
author | Tom Tromey <tom@tromey.com> | 2018-09-16 07:32:23 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2018-09-16 23:48:21 -0600 |
commit | 1a3389079dd5c93419846f44d42027a526ce19cf (patch) | |
tree | 150566fed14018557081881633e3700d2f37378f /gdb/python/python-internal.h | |
parent | 4a137fec2e1a8a6372da8fca1040ee582c62f78d (diff) | |
download | binutils-1a3389079dd5c93419846f44d42027a526ce19cf.zip binutils-1a3389079dd5c93419846f44d42027a526ce19cf.tar.gz binutils-1a3389079dd5c93419846f44d42027a526ce19cf.tar.bz2 |
Don't steal references in the gdb Python code
Some Python APIs steal references from their caller, and the refcount
checker supports this via an attribute.
However, in gdb with C++ we have a better idiom available: we can use
std::move on a gdbpy_ref<> instead. This makes the semantics obvious
at the point of call, and is safer at runtime as well, because the
callee's gdbpy_ref<> will be emptied.
This patch changes the reference-stealing code in gdb to use rvalue
references instead.
Tested on x86-64 Fedora 28.
gdb/ChangeLog
2018-09-16 Tom Tromey <tom@tromey.com>
* python/python-internal.h (CPYCHECKER_STEALS_REFERENCE_TO_ARG):
Remove.
* python/py-varobj.c (py_varobj_iter_ctor): Change pyiter to
rvalue reference. Remove CPYCHECKER_STEALS_REFERENCE_TO_ARG.
(py_varobj_iter_new): Likewise.
(py_varobj_get_iterator): Use gdbpy_ref.
Diffstat (limited to 'gdb/python/python-internal.h')
-rw-r--r-- | gdb/python/python-internal.h | 7 |
1 files changed, 0 insertions, 7 deletions
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index dc42978..e32502d 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -38,13 +38,6 @@ #define CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF(ARG) #endif -#ifdef WITH_CPYCHECKER_STEALS_REFERENCE_TO_ARG_ATTRIBUTE -#define CPYCHECKER_STEALS_REFERENCE_TO_ARG(n) \ - __attribute__ ((cpychecker_steals_reference_to_arg (n))) -#else -#define CPYCHECKER_STEALS_REFERENCE_TO_ARG(n) -#endif - #ifdef WITH_CPYCHECKER_SETS_EXCEPTION_ATTRIBUTE #define CPYCHECKER_SETS_EXCEPTION __attribute__ ((cpychecker_sets_exception)) #else |