This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC - Python Scripting] Unnecessary Py_XINCREF?
>>>>> "Siva" == Siva Chandra <sivachandra@google.com> writes:
Siva> I agree that the overall refcounting scheme is correct. However, I
Siva> still think that on the Python side, my example should print 1 and not
Siva> 2 as there are no references to the Objfile object other than that
Siva> from the argument to getrefcount.
gdb's 'struct objfile' owns a reference.
Siva> I have attached a patch now which I feel correctly fixes the 'issue'
Siva> that I report. The changelog is as follows:
I don't think I understand this patch. I started writing some comments
on it, but actually I think the idea is wrong.
The issue is that if gdb's struct objfile does not hold a reference to
the gdb.Objfile object, then the Objfile can be deleted prematurely,
causing pretty-printers attached to the Objfile to be lost.
Alternatively, if struct objfile does hold a reference, then it would
seem that refcount==2 is expected.
I think the actual refcount is not interesting, but the object's
behavior is. I guess I would say -- only look at refcounts if you can
prove that either (1) an object is leaked, or (2) an object is
prematurely deleted.
Tom