[RFA] fix ref counting of inferior_to_inferior_object
Tom Tromey
tromey@redhat.com
Mon Sep 23 20:41:00 GMT 2013
>>>>> "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
More information about the Gdb-patches
mailing list