summaryrefslogtreecommitdiff
path: root/gdb/symtab.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2017-07-14 16:50:35 +0100
committerPedro Alves <palves@redhat.com>2017-07-14 16:50:35 +0100
commit8f14146e1317b7b416ce298fad1a4f3d1ccbeb2b (patch)
treeca6f9294c66d0f349b97473c09858af07b960789 /gdb/symtab.c
parent0f6329bd7fcc8952aed5a386617d12529771415d (diff)
Fix gdb.base/completion.exp with --target_board=dwarf4-gdb-index
This is the same patch as posted at <https://sourceware.org/ml/gdb-patches/2017-02/msg00644.html>, with the test at <https://sourceware.org/ml/gdb-patches/2017-02/msg00687.html> squashed in. This patch fixes: -FAIL: gdb.base/completion.exp: tab complete break break.c:ma (timeout) -FAIL: gdb.base/completion.exp: complete break break.c:ma +PASS: gdb.base/completion.exp: tab complete break break.c:ma +PASS: gdb.base/completion.exp: delete breakpoint for tab complete break break.c:ma +PASS: gdb.base/completion.exp: complete break break.c:ma When run with --target_board=dwarf4-gdb-index. The issue here is that make_file_symbol_completion_list_1, used when completing a symbol restricted to a given source file, uses lookup_symtab to look up the symtab with the given name, and search for matching symbols inside. This assumes that there's only one symtab for the given source file. This is an incorrect assumption with (for example) -fdebug-types-section, where we'll have an extra extra symtab containing the types. lookup_symtab finds that symtab, and inside that symtab there are no functions... gdb/ChangeLog: 2017-07-14 Pedro Alves <palves@redhat.com> * symtab.c (make_file_symbol_completion_list_1): Iterate over symtabs matching all symtabs with SRCFILE as file name instead of only considering the first hit, with lookup_symtab. gdb/testsuite/ChangeLog: 2017-07-14 Pedro Alves <palves@redhat.com> * gdb.linespec/base/one/thefile.cc (z1): New function. * gdb.linespec/base/two/thefile.cc (z2): New function. * gdb.linespec/linespec.exp: Add tests.
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r--gdb/symtab.c32
1 files changed, 9 insertions, 23 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 497d52012a..c7f1311c70 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -5379,13 +5379,12 @@ make_symbol_completion_list_fn (struct cmd_list_element *ignore,
}
/* Like make_symbol_completion_list, but returns a list of symbols
- defined in a source file FILE. */
+ defined in all source files name SRCFILE. */
static VEC (char_ptr) *
make_file_symbol_completion_list_1 (const char *text, const char *word,
const char *srcfile)
{
- struct symtab *s;
/* The symbol we are completing on. Points in same buffer as text. */
const char *sym_text;
/* Length of sym_text. */
@@ -5436,28 +5435,15 @@ make_file_symbol_completion_list_1 (const char *text, const char *word,
sym_text_len = strlen (sym_text);
- /* Find the symtab for SRCFILE (this loads it if it was not yet read
- in). */
- s = lookup_symtab (srcfile);
- if (s == NULL)
+ /* Go through symtabs for SRCFILE and check the externs and statics
+ for symbols which match. */
+ iterate_over_symtabs (srcfile, [&] (symtab *s)
{
- /* Maybe they typed the file with leading directories, while the
- symbol tables record only its basename. */
- const char *tail = lbasename (srcfile);
-
- if (tail > srcfile)
- s = lookup_symtab (tail);
- }
-
- /* If we have no symtab for that file, return an empty list. */
- if (s == NULL)
- return (return_val);
-
- /* Go through this symtab and check the externs and statics for
- symbols which match. */
- add_symtab_completions (SYMTAB_COMPUNIT (s),
- sym_text, sym_text_len,
- text, word, TYPE_CODE_UNDEF);
+ add_symtab_completions (SYMTAB_COMPUNIT (s),
+ sym_text, sym_text_len,
+ text, word, TYPE_CODE_UNDEF);
+ return false;
+ });
return (return_val);
}