diff options
author | Pedro Alves <palves@redhat.com> | 2017-11-08 14:22:34 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2017-11-08 16:06:25 +0000 |
commit | f9d67a22392f8f52c779f68a2561eb35c2f86b81 (patch) | |
tree | 789551df32e000d6bdbaa1b73e58c59f310da04a /gdb/symtab.c | |
parent | 56d87ef769e6adab27af77fa86ea294ee7c6ee72 (diff) | |
download | gdb-f9d67a22392f8f52c779f68a2561eb35c2f86b81.zip gdb-f9d67a22392f8f52c779f68a2561eb35c2f86b81.tar.gz gdb-f9d67a22392f8f52c779f68a2561eb35c2f86b81.tar.bz2 |
Make the linespec/location completer ignore data symbols
Currently "b foo[TAB]" offers data symbols as completion candidates.
This doesn't make sense, since you can't set a breakpoint on data
symbols, only on code symbols.
(gdb) b globa[TAB]
(gdb) b global [ENTER]
Function "global" not defined.
Make breakpoint pending on future shared library load? (y or [n]) n
(gdb) info symbol global
global in section .rodata
So this patch makes linespec completion ignore data symbols.
gdb/ChangeLog:
2017-11-08 Pedro Alves <palves@redhat.com>
* ada-lang.c (ada_make_symbol_completion_list): Use
completion_skip_symbol.
* symtab.c (symbol_is_function_or_method(minimal_symbol*)): New.
(symbol_is_function_or_method(symbol*)): New.
(add_symtab_completions): Add complete_symbol_mode parameter. Use
completion_skip_symbol.
(default_collect_symbol_completion_matches_break_on): Use
completion_skip_symbol. Pass down mode.
(collect_file_symbol_completion_matches): Pass down mode.
* symtab.h (symbol_is_function_or_method): New declarations.
(completion_skip_symbol): New template function.
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r-- | gdb/symtab.c | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c index eb4e30d..ebb7fbe 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -4877,11 +4877,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; + } +} + +/* See symtab.h. */ + +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) @@ -4900,6 +4933,9 @@ add_symtab_completions (struct compunit_symtab *cust, b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), i); ALL_BLOCK_SYMBOLS (b, iter, sym) { + if (completion_skip_symbol (mode, sym)) + continue; + if (code == TYPE_CODE_UNDEF || (SYMBOL_DOMAIN (sym) == STRUCT_DOMAIN && TYPE_CODE (SYMBOL_TYPE (sym)) == code)) @@ -4998,6 +5034,9 @@ default_collect_symbol_completion_matches_break_on { QUIT; + if (completion_skip_symbol (mode, msymbol)) + continue; + completion_list_add_msymbol (tracker, msymbol, lookup_name, sym_text, word); @@ -5008,7 +5047,7 @@ default_collect_symbol_completion_matches_break_on /* Add completions for all currently loaded symbol tables. */ ALL_COMPUNITS (objfile, cust) - add_symtab_completions (cust, tracker, lookup_name, + add_symtab_completions (cust, tracker, mode, lookup_name, sym_text, word, code); /* Look through the partial symtabs for all symbols which begin by @@ -5019,7 +5058,7 @@ default_collect_symbol_completion_matches_break_on [&] (compunit_symtab *symtab) /* expansion notify */ { add_symtab_completions (symtab, - tracker, lookup_name, + tracker, mode, lookup_name, sym_text, word, code); }, ALL_DOMAIN); @@ -5225,7 +5264,7 @@ collect_file_symbol_completion_matches (completion_tracker &tracker, iterate_over_symtabs (srcfile, [&] (symtab *s) { add_symtab_completions (SYMTAB_COMPUNIT (s), - tracker, lookup_name, + tracker, mode, lookup_name, sym_text, word, TYPE_CODE_UNDEF); return false; }); |