This is the mail archive of the gdb-testers@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Don't steal references in the gdb Python code


*** TEST RESULTS FOR COMMIT 1a3389079dd5c93419846f44d42027a526ce19cf ***

Author: Tom Tromey <tom@tromey.com>
Branch: master
Commit: 1a3389079dd5c93419846f44d42027a526ce19cf

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]