aboutsummaryrefslogtreecommitdiff
path: root/gdb/symtab.h
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2017-11-08 14:22:34 +0000
committerPedro Alves <palves@redhat.com>2017-11-08 16:06:25 +0000
commitf9d67a22392f8f52c779f68a2561eb35c2f86b81 (patch)
tree789551df32e000d6bdbaa1b73e58c59f310da04a /gdb/symtab.h
parent56d87ef769e6adab27af77fa86ea294ee7c6ee72 (diff)
downloadgdb-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.h')
-rw-r--r--gdb/symtab.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 868c435..7b8b5cc 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1803,6 +1803,26 @@ extern void collect_file_symbol_completion_matches
extern completion_list
make_source_files_completion_list (const char *, const char *);
+/* Return whether SYM is a function/method, as opposed to a data symbol. */
+
+extern bool symbol_is_function_or_method (symbol *sym);
+
+/* Return whether MSYMBOL is a function/method, as opposed to a data
+ symbol */
+
+extern bool symbol_is_function_or_method (minimal_symbol *msymbol);
+
+/* Return whether SYM should be skipped in completion mode MODE. In
+ linespec mode, we're only interested in functions/methods. */
+
+template<typename Symbol>
+static bool
+completion_skip_symbol (complete_symbol_mode mode, Symbol *sym)
+{
+ return (mode == complete_symbol_mode::LINESPEC
+ && !symbol_is_function_or_method (sym));
+}
+
/* symtab.c */
int matching_obj_sections (struct obj_section *, struct obj_section *);