This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] Use custom hash function with bcache



This patch means that a given bcache could include two objects of the
same size that have different hash and comparison functions.  So, it
seems like some kind of clash could (in theory) result.  This is very
bad if one object is mutable and the other is not.

I think it would be safer to either:

I will take door number 1 since I am already working on it :)


1. Make the hash and comparison functions part of the bcache itself, set
    only when the bcache is allocated,

This is what Doug suggested. Making the functions part of the bcache struct and assigning them when bcache_xmalloc is called.


then audit all uses of this
    particular bcache to make sure that only psymtabs are added to it
    (this could be done by introducing a new type, so that invalid uses
    are compile-time errors),

with the above change the bcaches will be initialized like this:


objfile->psymbol_cache = bcache_xmalloc (psymbol_hash, psymbol_compare);
objfile->macro_cache = bcache_xmalloc (NULL, NULL);
objfile->filename_cache = bcache_xmalloc (NULL, NULL);

So only objects added to the psymbol_cache would be subjected to the new hash and compare functions. Although, you are right, there is no strict type checking. Are you suggesting we make psymbol_cache a new type ?


I think you can make the psym hash and comparison functions a bit simpler by just skipping the pointer-sized lang-specific hole. This is maybe more future-proof as well.


This patch already does that :)



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]