binutils-gdb/gdb/python
Tom Tromey 1a3389079d 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.
2018-09-16 23:48:21 -06:00
..
lib/gdb Add more methods to gdb.Progspace 2018-09-16 06:52:37 -06:00
py-all-events.def
py-arch.c
py-auto-load.c
py-block.c Add more methods to gdb.Progspace 2018-09-16 06:52:37 -06:00
py-bpevent.c
py-breakpoint.c
py-cmd.c
py-continueevent.c Change thread_to_thread_object to return a new reference 2018-09-16 07:25:57 -06:00
py-event-types.def
py-event.c
py-event.h Change thread_to_thread_object to return a new reference 2018-09-16 07:25:57 -06:00
py-events.h
py-evtregistry.c
py-evts.c
py-exitedevent.c
py-finishbreakpoint.c
py-frame.c
py-framefilter.c
py-function.c
py-gdb-readline.c
py-inferior.c Simplify uses of thread_to_thread_object 2018-09-16 23:36:54 -06:00
py-infevents.c
py-infthread.c Change thread_to_thread_object to return a new reference 2018-09-16 07:25:57 -06:00
py-instruction.c
py-instruction.h
py-lazy-string.c
py-linetable.c
py-newobjfileevent.c Change objfile_to_objfile_object to return a new reference 2018-09-16 07:25:56 -06:00
py-objfile.c Change objfile_to_objfile_object to return a new reference 2018-09-16 07:25:56 -06:00
py-param.c
py-prettyprint.c Change objfile_to_objfile_object to return a new reference 2018-09-16 07:25:56 -06:00
py-progspace.c Change objfile_to_objfile_object to return a new reference 2018-09-16 07:25:56 -06:00
py-record-btrace.c
py-record-btrace.h
py-record-full.c
py-record-full.h
py-record.c
py-record.h
py-ref.h
py-signalevent.c
py-stopevent.c Change thread_to_thread_object to return a new reference 2018-09-16 07:25:57 -06:00
py-stopevent.h
py-symbol.c
py-symtab.c Change objfile_to_objfile_object to return a new reference 2018-09-16 07:25:56 -06:00
py-threadevent.c Simplify uses of thread_to_thread_object 2018-09-16 23:36:54 -06:00
py-type.c
py-unwind.c
py-utils.c
py-value.c
py-varobj.c Don't steal references in the gdb Python code 2018-09-16 23:48:21 -06:00
py-xmethods.c Change objfile_to_objfile_object to return a new reference 2018-09-16 07:25:56 -06:00
python-config.py
python-internal.h Don't steal references in the gdb Python code 2018-09-16 23:48:21 -06:00
python.c Change objfile_to_objfile_object to return a new reference 2018-09-16 07:25:56 -06:00
python.h