This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] fix ref counting of inferior_to_inferior_object
- From: Tom Tromey <tromey at redhat dot com>
- To: Doug Evans <dje at google dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Mon, 23 Sep 2013 14:41:40 -0600
- Subject: Re: [RFA] fix ref counting of inferior_to_inferior_object
- Authentication-results: sourceware.org; auth=none
- References: <yjt2zjrhekva dot fsf at ruffy dot mtv dot corp dot google dot com>
>>>>> "Doug" == Doug Evans <dje@google.com> writes:
Doug> While adding an inferior attribute to the newobjfile event,
Doug> I noticed inferior_to_inferior_object sometimes returns (AFAICT)
Doug> a new reference and sometimes returns a borrowed reference.
The current code is maybe weird but I think it isn't incorrect. That
said it is fine to change it as well.
The current model is that the Python object mirroring the inferior
clears the inferior->Python mapping when it is finally destroyed.
If the Python code then requests the Python object for that inferior
again, a new object is created. This is "ok" because the Inferior
object doesn't carry any user state.
Doug> /* Return a reference to the Python object of type Inferior
Doug> representing INFERIOR. If the object has already been created,
Doug> - return it and increment the reference count, otherwise, create it.
Doug> + return it, otherwise create it. The result is a borrowed reference.
Doug> Return NULL on failure. */
This change requires a CPYCHECKER_RETURNS_BORROWED_REF annotation on the
declaration of inferior_to_inferior_object.
Tom