This is the mail archive of the gdb-patches@sources.redhat.com 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: [rfa] language hooks for lookup_symbol


David Carlton writes:
 > Here's a patch to add language hooks to lookup_symbol.  I settled on
 > two hooks: one of them is a boolean saying whether or not to do the
 > field of this check, and the other is a function that replaces the
 > static/global lookup part of lookup_symbol_aux.  The reason why I
 > broke these up into two separate parts is that the field of this part
 > doesn't return a symbol, so it's a little hard to do it gracefully and
 > without duplicating code.  It also provides some functions that other
 > languages can use to build nonlocal hook functions if necessary.
 > 
 > The only potential behavior change (I hope) is that I turned off the
 > field of this check for the C, asm, and minimal languages.  Doubtless
 > it should be turned off for other languages, too, but I didn't want to
 > tamper with them.  This patch tells all languages to use a function
 > basic_lookup_symbol_nonlocal that implements the standard C behavior
 > that lookup_symbol_aux had been doing.  (I'll submit the C++ namespace
 > stuff in my next patch.)
 > 
 > It also deletes the strange #if 0 hunk from lookup_symbol_aux; if you
 > want, I can commit that change as a separate patch.
 > 
 > This is my first time playing around with struct language_defn, so
 > please let me know if I did anything wrong.  I like this idea; I
 > really should spend time thinking about where else we should use it.
 > For example, should lookup_symbol call language_demangle instead of
 > cplus_demangle?  Hmm.


Yes. I like it.
A couple of comments.

1. check in the if0 elimination by itself, then the deletion of
   static_block parameter and teh addition of the block_static_bloc
   function. After that check in the rest (which is really the big change).

2. I think that instead of: int la_lookup_symbol_this; We can just
     have the new field be a function pointer to NULL or to the
     value_of_this function itself. This function itself can be split
     in 2, one for objc and one for c++.

3. move the comments as well, instead of deleting them.

demangle? probably so, it will be much cleaner if that gets moved too
(eventually).  Other thought, Adam added a few if language == objc
checks in other parts of generic code. Those are also candidate for
hooks, if you feel lucky! At the very least, they should not conflict
with your changes, and should be included in the 'grand plan'. At a
first look I don't think they will create any problems.


 > +/* Lookup a symbol in all files' global blocks (searching psymtabs if
 > +   necessary).  */
 > +
 > +struct symbol *lookup_symbol_global (const char *name,
 > +				     const char *linkage_name,
 > +				     const domain_enum domain,
 > +				     struct symtab **symtab)

watch out for grep ^func.....



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