From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 03/40] Fix gdb.base/completion.exp with --target_board=dwarf4-gdb-index
Date: Fri, 02 Jun 2017 12:22:00 -0000 [thread overview]
Message-ID: <1496406158-12663-4-git-send-email-palves@redhat.com> (raw)
In-Reply-To: <1496406158-12663-1-git-send-email-palves@redhat.com>
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:
yyyy-mm-dd 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:
yyyy-mm-dd 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/symtab.c | 30 +++------
gdb/testsuite/gdb.linespec/base/one/thefile.cc | 5 ++
gdb/testsuite/gdb.linespec/base/two/thefile.cc | 5 ++
gdb/testsuite/gdb.linespec/linespec.exp | 93 +++++++++++++++++++++++++-
4 files changed, 108 insertions(+), 25 deletions(-)
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 22d81fa..69f3bc2 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -5385,7 +5385,6 @@ 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);
}
diff --git a/gdb/testsuite/gdb.linespec/base/one/thefile.cc b/gdb/testsuite/gdb.linespec/base/one/thefile.cc
index 0417b7a..34bc547 100644
--- a/gdb/testsuite/gdb.linespec/base/one/thefile.cc
+++ b/gdb/testsuite/gdb.linespec/base/one/thefile.cc
@@ -23,3 +23,8 @@ int NameSpace::overload(int x)
{
return x + 23;
}
+
+int z1 ()
+{
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.linespec/base/two/thefile.cc b/gdb/testsuite/gdb.linespec/base/two/thefile.cc
index 88188a5..264ae97 100644
--- a/gdb/testsuite/gdb.linespec/base/two/thefile.cc
+++ b/gdb/testsuite/gdb.linespec/base/two/thefile.cc
@@ -24,3 +24,8 @@ int NameSpace::overload(double x)
{
return (int) x - 23;
}
+
+int z2 ()
+{
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.linespec/linespec.exp b/gdb/testsuite/gdb.linespec/linespec.exp
index ccb73c8..3a7bae5 100644
--- a/gdb/testsuite/gdb.linespec/linespec.exp
+++ b/gdb/testsuite/gdb.linespec/linespec.exp
@@ -43,6 +43,9 @@ if {$l1 != $l2} {
error "somebody incompatibly modified the source files needed by linespec.exp"
}
+gdb_test_no_output "set breakpoint pending off" \
+ "disable pending breakpoints for linespec tests"
+
# Copying files to a remote host loses the directory prefix during
# compilation.
if { [is_remote host] } {
@@ -55,6 +58,93 @@ if { [is_remote host] } {
gdb_test "clear one/thefile.cc:$l1" \
"Deleted breakpoint $decimal *" \
"clear breakpoint using dir/file:line"
+
+ if { [readline_is_used] } {
+ # There are functions name twodup in both source files. Both
+ # should be found if we restrict the linespec to the ambiguous
+ # "thefile.cc" source filename. Check both completion and
+ # setting the breakpoint.
+ set tst "complete unique function name in two source files"
+ send_gdb "break thefile.cc:t\t"
+ gdb_test_multiple "" $tst {
+ -re "break thefile.cc:twodup\\(\\) " {
+ pass $tst
+
+ send_gdb "\n"
+ gdb_test "" \
+ "Breakpoint $decimal at $hex: thefile.cc:twodup\\(\\). \[(\]2 locations\[)\]" \
+ "set break at unique function name in two source files"
+ }
+ }
+
+ # Check both completing and setting a breakpoint on a linespec
+ # with a source component, where there's more than one source
+ # file with the same basename. We should find the functions
+ # in all matching sources -- one/thefile.cc and
+ # two/thefile.cc. The "one" file has "z1()", while the "two"
+ # file has "z2()".
+ set tst "complete non-unique function name in two source files"
+ send_gdb "break thefile.cc:z\t"
+ gdb_test_multiple "" $tst {
+ -re "break thefile.cc:z\\\x07" {
+ send_gdb "\t"
+ gdb_test_multiple "" $tst {
+ -re "\r\nz1\\(\\)\[ \t\]+z2\\(\\)\[ \t\]+\r\n$gdb_prompt " {
+ pass $tst
+
+ send_gdb "\n"
+ gdb_test "" \
+ "Function \"z\" not defined in \"thefile.cc\"." \
+ "set break at non-unique function name in two source files"
+ }
+ }
+ }
+ }
+
+ # Now check that disambiguating the source path makes GDB only
+ # match the symbols in that file. "z" should now have a
+ # unique completion to "z1()", and setting the breakpoint
+ # should find only one location.
+ set tst "complete unique function name in disambiguated source file"
+ send_gdb "break one/thefile.cc:z\t"
+ gdb_test_multiple "" $tst {
+ -re "break one/thefile.cc:z1\\(\\) " {
+ pass $tst
+
+ send_gdb "\n"
+ gdb_test "" \
+ "Breakpoint $decimal at $hex: file .*thefile.cc, line \[^\r\n\]*" \
+ "set break at unique function name in disambiguated source file"
+ }
+ }
+
+ # Check that using a non-existing source path does not confuse
+ # gdb. It should not match any symbol.
+ set dir_file "one/thefile.cc"
+ set non_existing "/some/non-existing/absolute/path/prefix/$dir_file"
+ set non_existing_re [string_to_regexp $non_existing]
+
+ set tst "complete functions in non-existing absolute path"
+ send_gdb "break $non_existing:\t"
+ gdb_test_multiple "" $tst {
+ -re "break $non_existing_re:\\\x07" {
+ send_gdb "\t\t"
+ gdb_test_multiple "" $tst {
+ -re "^\\\x07\\\x07" {
+ pass $tst
+
+ # There's a function called twodup in each of
+ # the thefile.cc files. Make sure none is
+ # picked.
+ send_gdb "twodup\n"
+ gdb_test "" \
+ "No source file named $non_existing_re." \
+ "set break in function in non-existing absolute path"
+ }
+ }
+ }
+ }
+ }
}
gdb_test "break thefile.cc:$l1" \
@@ -73,9 +163,6 @@ gdb_test "break dupname:label" \
# not the locations.
gdb_test "complete condition " "condition $decimal\r\ncondition $decimal\r\ncondition $decimal"
-gdb_test_no_output "set breakpoint pending off" \
- "disable pending breakpoints for linespec tests"
-
# This is PR breakpoints/12856.
gdb_test "break lspec.cc:nosuchfunction" \
"Function \"nosuchfunction\" not defined in \"lspec.cc\"." \
--
2.5.5
next prev parent reply other threads:[~2017-06-02 12:22 UTC|newest]
Thread overview: 182+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-02 12:22 [PATCH 00/40] C++ debugging improvements: breakpoints, TAB completion, more Pedro Alves
2017-06-02 12:22 ` Pedro Alves [this message]
2017-07-13 20:28 ` [PATCH 03/40] Fix gdb.base/completion.exp with --target_board=dwarf4-gdb-index Keith Seitz
2017-07-14 16:02 ` Pedro Alves
2017-06-02 12:22 ` [PATCH 01/40] Make gdb.base/dmsym.exp independent of "set language ada" Pedro Alves
2017-07-18 19:42 ` Simon Marchi
2017-07-20 17:00 ` Pedro Alves
2017-06-02 12:22 ` [PATCH 14/40] Introduce CP_OPERATOR_STR/CP_OPERATOR_LEN and use throughout Pedro Alves
2017-07-14 18:04 ` Keith Seitz
2017-07-17 14:55 ` Pedro Alves
2017-06-02 12:22 ` [PATCH 02/40] Eliminate make_cleanup_obstack_free, introduce auto_obstack Pedro Alves
2017-06-26 13:47 ` Yao Qi
2017-06-27 10:25 ` Pedro Alves
2017-06-28 10:36 ` Yao Qi
2017-06-28 14:39 ` Pedro Alves
2017-06-28 21:33 ` Yao Qi
2017-06-02 12:22 ` [PATCH 08/40] completion_list_add_name wrapper functions Pedro Alves
2017-06-27 12:56 ` Yao Qi
2017-06-27 15:35 ` Pedro Alves
2017-06-02 12:22 ` [PATCH 06/40] Expression completer should not match explicit location options Pedro Alves
2017-06-29 8:29 ` Yao Qi
2017-06-29 10:56 ` Pedro Alves
2017-06-29 11:08 ` Pedro Alves
2017-06-29 15:23 ` Pedro Alves
2017-06-29 11:24 ` Yao Qi
2017-06-29 15:25 ` Pedro Alves
2017-06-02 12:23 ` [PATCH 38/40] Use TOLOWER in SYMBOL_HASH_NEXT Pedro Alves
2017-08-09 19:25 ` Keith Seitz
2017-11-25 0:35 ` [pushed] " Pedro Alves
2017-06-02 12:23 ` [PATCH 09/40] Rename make_symbol_completion_list_fn -> symbol_completer Pedro Alves
2017-06-28 21:40 ` Yao Qi
2017-07-13 20:46 ` Keith Seitz
2017-07-17 11:00 ` Pedro Alves
2017-06-02 12:23 ` [PATCH 13/40] Introduce strncmp_iw Pedro Alves
2017-06-29 8:42 ` Yao Qi
2017-07-17 19:16 ` Pedro Alves
2017-06-02 12:23 ` [PATCH 40/40] Document breakpoints / linespec & co improvements (manual + NEWS) Pedro Alves
2017-06-02 13:01 ` Eli Zaretskii
2017-06-02 13:33 ` Pedro Alves
2017-06-21 15:50 ` Pedro Alves
2017-06-21 19:14 ` Pedro Alves
2017-06-22 19:45 ` Eli Zaretskii
2017-06-22 19:42 ` Eli Zaretskii
2017-06-21 13:32 ` Pedro Alves
2017-06-21 18:26 ` Eli Zaretskii
2017-06-21 19:01 ` Pedro Alves
2017-06-22 19:43 ` Eli Zaretskii
2017-06-02 12:23 ` [PATCH 19/40] Fix cp_find_first_component_aux bug Pedro Alves
2017-07-17 19:17 ` Keith Seitz
2017-07-17 19:50 ` Pedro Alves
2017-07-17 21:38 ` Keith Seitz
2017-07-20 17:03 ` Pedro Alves
2017-06-02 12:23 ` [PATCH 28/40] lookup_name_info::make_ignore_params Pedro Alves
2017-08-08 20:55 ` Keith Seitz
2017-11-08 16:18 ` Pedro Alves
2017-06-02 12:23 ` [PATCH 18/40] A smarter linespec completer Pedro Alves
2017-07-15 0:07 ` Keith Seitz
2017-07-17 18:21 ` Pedro Alves
2017-07-17 19:02 ` Keith Seitz
2017-07-17 19:33 ` Pedro Alves
2017-06-02 12:23 ` [PATCH 11/40] Introduce class completion_tracker & rewrite completion<->readline interaction Pedro Alves
2017-07-14 17:23 ` Keith Seitz
2017-07-17 13:56 ` Pedro Alves
2017-07-18 8:23 ` Christophe Lyon
[not found] ` <845f435e-d3d5-b327-4e3a-ce9434bd6ffd@redhat.com>
2017-07-18 10:42 ` [pushed] Fix GDB builds that include the simulator (Re: [PATCH 11/40] Introduce class completion_tracker & rewrite completion<->readline interaction) Pedro Alves
2018-03-05 21:43 ` [PATCH 11/40] Introduce class completion_tracker & rewrite completion<->readline interaction Simon Marchi
2017-06-02 12:23 ` [PATCH 39/40] Breakpoints in symbols with ABI tags (PR c++/19436) Pedro Alves
2017-08-09 19:34 ` Keith Seitz
2017-11-27 17:14 ` Pedro Alves
2017-06-02 12:23 ` [PATCH 15/40] Rewrite/enhance explicit locations completer, parse left->right Pedro Alves
2017-07-14 20:55 ` Keith Seitz
2017-07-17 19:24 ` Pedro Alves
2017-06-02 12:23 ` [PATCH 35/40] Comprehensive C++ linespec/completer tests Pedro Alves
2017-08-09 17:30 ` Keith Seitz
2017-11-24 16:25 ` Pedro Alves
2017-06-02 12:23 ` [PATCH 36/40] Add comprehensive C++ operator linespec/location/completion tests Pedro Alves
2017-08-09 17:59 ` Keith Seitz
2017-11-25 0:18 ` [pushed] " Pedro Alves
2017-11-30 15:43 ` Yao Qi
2017-11-30 16:06 ` Pedro Alves
2017-11-30 16:35 ` [pushed] Fix gdb.linespec/cpls-ops.exp on 32-bit (Re: [pushed] Re: [PATCH 36/40] Add comprehensive C++ operator linespec/location/completion tests) Pedro Alves
2017-06-02 12:23 ` [PATCH 37/40] Fix completing an empty string Pedro Alves
2017-08-09 18:01 ` Keith Seitz
2017-11-25 0:28 ` Pedro Alves
2017-06-02 12:23 ` [PATCH 27/40] Make cp_remove_params return a unique_ptr Pedro Alves
2017-08-08 20:35 ` Keith Seitz
2017-10-09 15:13 ` Pedro Alves
2017-06-02 12:23 ` [PATCH 10/40] Clean up "completer_handle_brkchars" callback handling Pedro Alves
2017-07-13 21:08 ` Keith Seitz
2017-07-17 11:14 ` Pedro Alves
2017-06-02 12:23 ` [PATCH 34/40] Make strcmp_iw NOT ignore whitespace in the middle of tokens Pedro Alves
2017-08-09 15:48 ` Keith Seitz
2017-11-24 23:38 ` [pushed] " Pedro Alves
2017-06-02 12:28 ` [PATCH 24/40] Per-language symbol name hashing algorithm Pedro Alves
2017-07-18 17:33 ` Keith Seitz
2017-07-20 18:53 ` Pedro Alves
2017-11-08 16:08 ` Pedro Alves
2017-06-02 12:29 ` [PATCH 12/40] "complete" command and completion word break characters Pedro Alves
2017-07-14 17:50 ` Keith Seitz
2017-07-17 14:36 ` Pedro Alves
2017-06-02 12:29 ` [PATCH 33/40] Make the linespec/location completer ignore data symbols Pedro Alves
2017-08-09 15:42 ` Keith Seitz
2017-11-08 16:22 ` Pedro Alves
2017-06-02 12:29 ` [PATCH 07/40] objfile_per_bfd_storage non-POD Pedro Alves
2017-06-27 12:00 ` Yao Qi
2017-06-27 15:30 ` Pedro Alves
2017-06-02 12:29 ` [PATCH 16/40] Explicit locations -label completer Pedro Alves
2017-07-14 21:32 ` Keith Seitz
2017-06-02 12:29 ` [PATCH 17/40] Linespec lexing and C++ operators Pedro Alves
2017-07-14 21:45 ` Keith Seitz
2017-07-17 19:34 ` Pedro Alves
2017-06-02 12:29 ` [PATCH 05/40] command.h: Include scoped_restore_command.h Pedro Alves
2017-06-27 11:30 ` Yao Qi
2017-06-27 11:45 ` Pedro Alves
2017-06-27 11:52 ` Pedro Alves
2017-06-27 12:03 ` Pedro Alves
2017-06-27 15:46 ` [PATCH 05/40] command.h: Include common/scoped_restore.h Pedro Alves
2017-06-28 7:54 ` Yao Qi
2017-06-28 14:20 ` Pedro Alves
2017-06-02 12:29 ` [PATCH 21/40] Use SYMBOL_MATCHES_SEARCH_NAME some more Pedro Alves
2017-07-17 21:39 ` Keith Seitz
2017-07-20 17:08 ` Pedro Alves
2017-06-02 12:30 ` [PATCH 20/40] Eliminate block_iter_name_* Pedro Alves
2017-07-17 19:47 ` Keith Seitz
2017-07-20 17:05 ` Pedro Alves
2017-06-02 12:30 ` [PATCH 30/40] Use search_domain::FUNCTIONS_DOMAIN when setting breakpoints Pedro Alves
2017-08-08 21:07 ` Keith Seitz
2017-11-08 16:20 ` Pedro Alves
2017-06-02 12:30 ` [PATCH 32/40] Make "break foo" find "A::foo", A::B::foo", etc. [C++ and wild matching] Pedro Alves
2017-08-08 23:48 ` Keith Seitz
2017-11-22 16:48 ` Pedro Alves
2017-11-24 16:48 ` Pedro Alves
2017-11-24 16:57 ` Pedro Alves
2017-11-28 0:39 ` Keith Seitz
2017-11-28 0:02 ` Keith Seitz
2017-11-28 0:21 ` Pedro Alves
2017-11-28 0:42 ` Keith Seitz
2017-06-02 12:31 ` [PATCH 29/40] Simplify completion_list_add_name | remove sym_text / sym_text_len Pedro Alves
2017-08-08 20:59 ` Keith Seitz
2017-11-08 16:19 ` Pedro Alves
2017-06-02 12:31 ` [PATCH 04/40] Fix TAB-completion + .gdb_index slowness (generalize filename_seen_cache) Pedro Alves
2017-07-13 20:41 ` Keith Seitz
2017-07-14 19:40 ` Pedro Alves
2017-07-17 10:51 ` Pedro Alves
2017-06-02 12:31 ` [PATCH 22/40] get_int_var_value Pedro Alves
2017-07-17 22:11 ` Keith Seitz
2017-07-20 17:15 ` Pedro Alves
2017-06-02 12:33 ` [PATCH 31/40] Handle custom completion match prefix / LCD Pedro Alves
2017-08-08 21:28 ` Keith Seitz
2017-11-27 17:11 ` Pedro Alves
2017-06-02 12:39 ` [PATCH 25/40] Introduce lookup_name_info and generalize Ada's FULL/WILD name matching Pedro Alves
2017-07-18 20:14 ` Keith Seitz
2017-07-18 22:31 ` Pedro Alves
2017-07-20 19:00 ` Pedro Alves
2017-07-20 19:06 ` Pedro Alves
2017-08-08 20:29 ` Keith Seitz
2017-10-19 17:36 ` Pedro Alves
2017-11-01 15:38 ` Joel Brobecker
2017-11-08 16:10 ` Pedro Alves
2017-11-08 22:15 ` Joel Brobecker
2017-06-02 12:39 ` [PATCH 26/40] Optimize .gdb_index symbol name searching Pedro Alves
2017-08-08 20:32 ` Keith Seitz
2017-11-08 16:14 ` Pedro Alves
2017-11-08 16:16 ` [pushed] Reorder/reindent dw2_expand_symtabs_matching & friends (Re: [PATCH 26/40] Optimize .gdb_index symbol name searching) Pedro Alves
2017-11-18 5:23 ` [PATCH 26/40] Optimize .gdb_index symbol name searching Simon Marchi
2017-11-20 0:33 ` Pedro Alves
2017-11-20 0:42 ` [PATCH 1/3] 0xff chars in name components table; cp-name-parser lex UTF-8 identifiers Pedro Alves
2017-11-20 1:38 ` Simon Marchi
2017-11-20 11:56 ` Pedro Alves
2017-11-20 16:50 ` Simon Marchi
2017-11-21 0:11 ` Pedro Alves
2017-11-20 0:42 ` [PATCH 2/3] Unit test name-component bounds searching directly Pedro Alves
2017-11-20 3:16 ` Simon Marchi
2017-11-20 14:17 ` Pedro Alves
2017-11-20 0:42 ` [PATCH 3/3] Fix mapped_index::find_name_components_bounds upper bound computation Pedro Alves
2017-11-20 3:17 ` Simon Marchi
2017-06-02 12:39 ` [PATCH 23/40] Make language_def O(1) Pedro Alves
2017-07-17 23:03 ` Keith Seitz
2017-07-20 17:40 ` Pedro Alves
2017-07-20 18:12 ` Get rid of "set language local"? (was: Re: [PATCH 23/40] Make language_def O(1)) Pedro Alves
2017-07-20 23:44 ` Matt Rice
2017-06-02 15:26 ` [PATCH 00/40] C++ debugging improvements: breakpoints, TAB completion, more Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1496406158-12663-4-git-send-email-palves@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox