Re: [PATCH 33/40] Make the linespec/location completer ignore data symbols

Keith Seitz
2017-08-09T15:42:19Z

On 06/02/2017 05:22 AM, Pedro Alves wrote:
>
> diff --git a/gdb/symtab.c b/gdb/symtab.c
> index bbc317d..52cf70a 100644
> --- a/gdb/symtab.c
> +++ b/gdb/symtab.c
> @@ -5034,11 +5034,44 @@ completion_list_add_fields (completion_tracker &tracker,
> }
> }
>
> +/* See symtab.h. */
> +
> +bool
> +symbol_is_function_or_method (symbol *sym)
> +{
> + switch (TYPE_CODE (SYMBOL_TYPE (sym)))
> + {
> + case TYPE_CODE_FUNC:
> + case TYPE_CODE_METHOD:
> + return true;
> + default:
> + return false;
> + }
> +}
> +
> +/* Return whether MSYMBOL is a function/method. */
> +

I think "See symtab.h." is more customary here?

> +bool
> +symbol_is_function_or_method (minimal_symbol *msymbol)
> +{
> + switch (MSYMBOL_TYPE (msymbol))
> + {
> + case mst_text:
> + case mst_text_gnu_ifunc:
> + case mst_solib_trampoline:
> + case mst_file_text:
> + return true;
> + default:
> + return false;
> + }
> +}
> +
> /* Add matching symbols from SYMTAB to the current completion list. */
>
> static void
> add_symtab_completions (struct compunit_symtab *cust,
> completion_tracker &tracker,
> + complete_symbol_mode mode,
> const lookup_name_info &lookup_name,
> const char *text, const char *word,
> enum type_code code)

Otherwise, LGTM.

Keith