Solibs and objfile BFD ownership

Tom Tromey tromey@redhat.com
Fri Aug 21 17:32:00 GMT 2009


>>>>> "Paul" == Paul Pluzhnikov <ppluzhnikov@google.com> writes:

Paul> It would be slightly wasteful to set refcount to 1 everywhere,
Paul> since solib is the only place where sharing could (currently)
Paul> occur.

Yeah, I suppose.  But it seems clearer and more future-proof to me.

Paul> 2009-08-19  Paul Pluzhnikov  <ppluzhnikov@google.com>
Paul> 	* objfiles.h (gdb_bfd_ref): New prototype.
Paul> 	* objfiles.c (gdb_bfd_ref): New function.
Paul> 	(allocate_objfile): Call it.
Paul> 	(gdb_bfd_unref): Adjust assertion.
Paul> 	* solib.c (solib_map_sections): Add reference.
Paul> 	(symbol_add_stub): Don't add reference here.
Paul> 	* symfile.c (reread_symbols): Add reference.

This is ok.  Thanks.

Paul> +  gdb_assert (*p_refcount == 1 || *p_refcount == 2);

This assertion is a bit strange, but I suppose it is harmless.  If we
ever want more sharing, we can always just remove it.  In the meantime I
suppose it is checking that we don't over-share somehow.

Tom



More information about the Gdb mailing list