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: [PATCH 24/40] Per-language symbol name hashing algorithm


On 06/02/2017 05:22 AM, Pedro Alves wrote:
> 
> This patch starts fixing this, by doing two things:
> 
> #1 - adds a language vector method to let each language decide how to
>      compute a symbol name hash.
> 
> #2 - makes dictionaries know the language of the symbols they hold,
>      and then use the dictionaries language to decide which hashing
>      method to use.

Me likey! :-)

Again, just the usual trivial comments.

> 
> diff --git a/gdb/buildsym.c b/gdb/buildsym.c
> index cbad027..15f65a8 100644
> --- a/gdb/buildsym.c
> +++ b/gdb/buildsym.c
> @@ -1047,11 +1055,11 @@ prepare_for_building (const char *name, CORE_ADDR start_addr)
>  
>  struct compunit_symtab *
>  start_symtab (struct objfile *objfile, const char *name, const char *comp_dir,
> -	      CORE_ADDR start_addr)
> +	      CORE_ADDR start_addr, enum language language)

Unlike start_buildsym_compunit, this function is exported. IMO, `language' should be mentioned in the comment.

> diff --git a/gdb/coffread.c b/gdb/coffread.c
> index 9db4792..db0b77a 100644
> --- a/gdb/coffread.c
> +++ b/gdb/coffread.c
> @@ -394,7 +394,9 @@ coff_start_symtab (struct objfile *objfile, const char *name)
>  		 NULL,
>    /* The start address is irrelevant, since we set
>       last_source_start_addr in coff_end_symtab.  */
> -		 0);
> +		 0,
> +  /* Let buildsym.c deduce the language for this symtab.  */
> +		 language_unknown);

re: "deduce the language" if language == language_unknown... That's not obvious from start_symtab's documentation, so I think that deserves a mention there.

> diff --git a/gdb/dictionary.h b/gdb/dictionary.h
> index 4f4f160..ef5fbed 100644
> --- a/gdb/dictionary.h
> +++ b/gdb/dictionary.h
> @@ -45,6 +45,7 @@ struct pending;
>     initialized from SYMBOL_LIST.  */
>  
>  extern struct dictionary *dict_create_hashed (struct obstack *obstack,
> +					      enum language language,
>  					      const struct pending
>  					      *symbol_list);
>  
> @@ -53,7 +54,8 @@ extern struct dictionary *dict_create_hashed (struct obstack *obstack,
>     it, call dict_add_symbol().  Call dict_free() when you're done with
>     it.  */
>  
> -extern struct dictionary *dict_create_hashed_expandable (void);
> +extern struct dictionary *
> +  dict_create_hashed_expandable (enum language language);
>  
>  /* Create a dictionary implemented via a fixed-size array.  All memory
>     it uses is allocated on OBSTACK; the environment is initialized
> @@ -61,6 +63,7 @@ extern struct dictionary *dict_create_hashed_expandable (void);
>     that they're found in SYMBOL_LIST.  */
>  
>  extern struct dictionary *dict_create_linear (struct obstack *obstack,
> +					      enum language language,
>  					      const struct pending
>  					      *symbol_list);
>  
> @@ -69,8 +72,8 @@ extern struct dictionary *dict_create_linear (struct obstack *obstack,
>     it, call dict_add_symbol().  Call dict_free() when you're done with
>     it.  */
>  
> -extern struct dictionary *dict_create_linear_expandable (void);
> -
> +extern struct dictionary *
> +  dict_create_linear_expandable (enum language language);
>  
>  /* The functions providing the interface to dictionaries.  Note that
>     the most common parts of the interface, namely symbol lookup, are

All of the above functions are exported, so I think our custom is to document all formal parameters, no?

> diff --git a/gdb/symtab.h b/gdb/symtab.h
> index fffe0f87..20904e4 100644
> --- a/gdb/symtab.h
> +++ b/gdb/symtab.h
> @@ -277,6 +277,9 @@ extern const char *symbol_search_name (const struct general_symbol_info *);
>  #define SYMBOL_MATCHES_SEARCH_NAME(symbol, name)			\
>    (strcmp_iw (SYMBOL_SEARCH_NAME (symbol), (name)) == 0)
>  
> +extern unsigned int search_name_hash (enum language language,
> +				      const char *search_name);
> +

symtab.c says, "See symtab.h." Missing comment here.

Keith


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