aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2015-08-10 12:23:09 -0700
committerDoug Evans <dje@google.com>2015-08-10 12:23:09 -0700
commite27852be65403306da198b3c1d7b222acd6bdfe9 (patch)
tree0c62fa6fa515cbde26bf7121086fab9dea124c39 /gdb
parentfd7dcb94cbd44629b3929336aec8b76c3e339656 (diff)
downloadgdb-e27852be65403306da198b3c1d7b222acd6bdfe9.zip
gdb-e27852be65403306da198b3c1d7b222acd6bdfe9.tar.gz
gdb-e27852be65403306da198b3c1d7b222acd6bdfe9.tar.bz2
PR gdb/17960 Internal error: tracker != NULL when completing on file:function
gdb/ChangeLog: * symtab.c (make_file_symbol_completion_list_1): Renamed from make_file_symbol_completion_list and made static. (make_file_symbol_completion_list): New function. gdb/testsuite/ChangeLog: * gdb.base/completion.exp: Add location completer tests.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog8
-rw-r--r--gdb/symtab.c38
-rw-r--r--gdb/testsuite/ChangeLog6
-rw-r--r--gdb/testsuite/gdb.base/completion.exp82
4 files changed, 129 insertions, 5 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 0d71d23..624fba8 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,11 @@
+2015-08-10 Doug Evans <dje@google.com>
+ Keith Seitz <keiths@redhat.com>
+
+ PR gdb/17960
+ * symtab.c (make_file_symbol_completion_list_1): Renamed from
+ make_file_symbol_completion_list and made static.
+ (make_file_symbol_completion_list): New function.
+
2015-08-10 Joel Brobecker <brobecker@adacore.com>
* infrun.c (follow_fork, displaced_step_prepare, resume): Remove
diff --git a/gdb/symtab.c b/gdb/symtab.c
index ebafe53..5278265 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -5604,9 +5604,9 @@ 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. */
-VEC (char_ptr) *
-make_file_symbol_completion_list (const char *text, const char *word,
- const char *srcfile)
+static VEC (char_ptr) *
+make_file_symbol_completion_list_1 (const char *text, const char *word,
+ const char *srcfile)
{
struct symbol *sym;
struct symtab *s;
@@ -5662,8 +5662,6 @@ make_file_symbol_completion_list (const char *text, const char *word,
sym_text_len = strlen (sym_text);
- return_val = NULL;
-
/* Find the symtab for SRCFILE (this loads it if it was not yet read
in). */
s = lookup_symtab (srcfile);
@@ -5699,6 +5697,36 @@ make_file_symbol_completion_list (const char *text, const char *word,
return (return_val);
}
+/* Wrapper around make_file_symbol_completion_list_1
+ to handle MAX_COMPLETIONS_REACHED_ERROR. */
+
+VEC (char_ptr) *
+make_file_symbol_completion_list (const char *text, const char *word,
+ const char *srcfile)
+{
+ struct cleanup *back_to, *cleanups;
+
+ completion_tracker = new_completion_tracker ();
+ cleanups = make_cleanup_free_completion_tracker (&completion_tracker);
+ return_val = NULL;
+ back_to = make_cleanup (do_free_completion_list, &return_val);
+
+ TRY
+ {
+ make_file_symbol_completion_list_1 (text, word, srcfile);
+ }
+ CATCH (except, RETURN_MASK_ERROR)
+ {
+ if (except.error != MAX_COMPLETIONS_REACHED_ERROR)
+ throw_exception (except);
+ }
+ END_CATCH
+
+ discard_cleanups (back_to);
+ do_cleanups (cleanups);
+ return return_val;
+}
+
/* A helper function for make_source_files_completion_list. It adds
another file name to a list of possible completions, growing the
list as necessary. */
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 813b249..294fbce 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2015-08-10 Doug Evans <dje@google.com>
+ Keith Seitz <keiths@redhat.com>
+
+ PR gdb/17960
+ * gdb.base/completion.exp: Add location completer tests.
+
2015-08-07 Pedro Alves <palves@redhat.com>
* gdb.arch/ppc64-atomic-inst.exp (do_test): New procedure, move
diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp
index 1eb0fd8..f0e4dec 100644
--- a/gdb/testsuite/gdb.base/completion.exp
+++ b/gdb/testsuite/gdb.base/completion.exp
@@ -777,6 +777,88 @@ gdb_test_multiple "" "$test" {
}
#
+# Tests for the location completer
+#
+
+# Turn off pending breakpoint support so that we don't get queried
+# all the time.
+gdb_test_no_output "set breakpoint pending off"
+
+set subsrc [string range $srcfile 0 [expr {[string length $srcfile] - 3}]]
+set test "tab complete break $subsrc"
+send_gdb "break $subsrc\t\t"
+gdb_test_multiple "" $test {
+ -re "break\.c.*break1\.c.*$gdb_prompt " {
+ send_gdb "1\t\n"
+ gdb_test_multiple "" $test {
+ -re ".*Function \"$srcfile2\" not defined\..*$gdb_prompt " {
+ pass $test
+ }
+ -re "$gdb_prompt p$" {
+ fail $test
+ }
+ }
+ }
+
+ -re "$gdb_prompt p$" {
+ fail $test
+ }
+}
+
+gdb_test "complete break $subsrc" "break\.c.*break1\.c"
+
+set test "tab complete break need"
+send_gdb "break need\t"
+gdb_test_multiple "" $test {
+ -re "break need_malloc " {
+ send_gdb "\n"
+ gdb_test_multiple "" $test {
+ -re ".*Breakpoint.*at .*/$srcfile, line .*$gdb_prompt " {
+ pass $test
+ gdb_test_no_output "delete breakpoint \$bpnum" \
+ "delete breakpoint for $test"
+ }
+ -re "$gdb_prompt p$" {
+ fail $test
+ }
+ }
+ }
+ -re "$gdb_prompt p$" {
+ fail $test
+ }
+}
+
+gdb_test "complete break need" "need_malloc"
+
+# gdb/17960
+# Enabling max-completions is necessary to trigger the bug.
+gdb_test_no_output "set max-completions 10"
+set test "tab complete break $srcfile:ma"
+send_gdb "break $srcfile:ma\t"
+gdb_test_multiple "" $test {
+ -re "break $srcfile:main " {
+ send_gdb "\n"
+ gdb_test_multiple "" $test {
+ -re ".*Breakpoint.*at .*/$srcfile, line .*$gdb_prompt " {
+ pass $test
+ gdb_test_no_output "delete breakpoint \$bpnum" \
+ "delete breakpoint for $test"
+ }
+ -re "$gdb_prompt p$" {
+ fail $test
+ }
+ }
+ }
+ -re "$gdb_prompt p$" {
+ fail $test
+ }
+}
+
+gdb_test "complete break $srcfile:ma" "break\.c:main"
+
+# End of gdb/17960 testing.
+
+#
# Completion limiting.
#