Fix gdb.base/completion.exp with --target_board=dwarf4-gdb-index
authorPedro Alves <palves@redhat.com>
Fri, 14 Jul 2017 15:50:35 +0000 (16:50 +0100)
committerPedro Alves <palves@redhat.com>
Fri, 14 Jul 2017 15:50:35 +0000 (16:50 +0100)
commit8f14146e1317b7b416ce298fad1a4f3d1ccbeb2b
treeca6f9294c66d0f349b97473c09858af07b960789
parent0f6329bd7fcc8952aed5a386617d12529771415d
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.
gdb/ChangeLog
gdb/symtab.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.linespec/base/one/thefile.cc
gdb/testsuite/gdb.linespec/base/two/thefile.cc
gdb/testsuite/gdb.linespec/linespec.exp