Re: [PATCH 2/4] Change objfile_to_objfile_object to return a new reference

Simon Marchi
2018-09-16T02:00:01Z

On 2018-09-15 9:28 p.m., Simon Marchi wrote:
> On 2018-09-13 1:30 a.m., Tom Tromey wrote:
>> This changes objfile_to_objfile_object to return a new references and
>> fixes up all the uses.
>>
>> 2018-09-12 Tom Tromey <tom@tromey.com>
>>
>> * python/python-internal.h (objfile_to_objfile_object): Change
>> return type.
>> * python/py-newobjfileevent.c (create_new_objfile_event_object):
>> Update.
>> * python/py-xmethods.c (gdbpy_get_matching_xmethod_workers):
>> Update.
>> * python/python.c (gdbpy_get_current_objfile): Update.
>> (gdbpy_objfiles): Update.
>> * python/py-objfile.c (objfpy_get_owner, gdbpy_lookup_objfile):
>> Update.
>> (objfile_to_objfile_object): Return a new reference.
>> * python/py-symtab.c (stpy_get_objfile): Update.
>> * python/py-prettyprint.c (find_pretty_printer_from_objfiles):
>> Update.
>
> I'm also getting some failures with this patch;
>
> CXX python/python.o
> /home/simark/src/binutils-gdb/gdb/python/python.c:1432:12: error: assigning to 'PyObject *' (aka '_object *') from incompatible type 'gdbpy_ref<>' (aka 'gdb::ref_ptr<_object, gdbpy_ref_policy<_object> >')
> result = objfile_to_objfile_object (gdbpy_current_objfile);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/simark/src/binutils-gdb/gdb/python/python.c:1451:17: error: no viable conversion from 'gdbpy_ref<>' (aka 'gdb::ref_ptr<_object, gdbpy_ref_policy<_object> >') to 'PyObject *' (aka '_object *')
> PyObject *item = objfile_to_objfile_object (objf);
> ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Forget about this failure. I had trouble applying the patches (finding
the right base commit) and managed to get rid of the changes in that file
when dealing with the conflicts. Everything looks fine here.

Simon