aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorJan Vrany <jan.vrany@fit.cvut.cz>2019-05-17 10:58:23 +0100
committerJan Vrany <jan.vrany@fit.cvut.cz>2019-05-17 10:58:23 +0100
commit26648588294d039fcf1efbf512d785753cb6286d (patch)
tree3a2635afa20d8e731d56ad29feb8f23100e0feda /gdb/testsuite
parent6e035501e15e72398fcd9db88c97dd30e585a9ae (diff)
downloadbinutils-26648588294d039fcf1efbf512d785753cb6286d.zip
binutils-26648588294d039fcf1efbf512d785753cb6286d.tar.gz
binutils-26648588294d039fcf1efbf512d785753cb6286d.tar.bz2
MI: Add new command -complete
There is a CLI command 'complete' intended to use with emacs. Such a command would also be useful for MI frontends, when separate CLI and MI channels cannot be used. For example, on Windows (because of lack of PTYs) or when GDB is used through SSH session. This commit adds a new '-complete' MI command. gdb/Changelog: 2019-01-28 Jan Vrany <jan.vrany@fit.cvut.cz> * mi/mi-cmds.h (mi_cmd_complete): New function. * mi/mi-main.c (mi_cmd_complete): Likewise. * mi/mi-cmds.c: Define new MI command -complete. * NEWS: Mention new -complete command. gdb/doc/ChangeLog: 2019-01-28 Jan Vrany <jan.vrany@fit.cvut.cz> * gdb.texinfo (Miscellaneous GDB/MI Commands): Document new MI command -complete. gdb/testsuite/ChangeLog: 2019-01-28 Jan Vrany <jan.vrany@fit.cvut.cz> * gdb.mi/mi-complete.exp: New file. * gdb.mi/mi-complete.cc: Likewise.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.mi/mi-complete.cc40
-rw-r--r--gdb/testsuite/gdb.mi/mi-complete.exp72
3 files changed, 117 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 78289d6..bdabbc7 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2019-01-28 Jan Vrany <jan.vrany@fit.cvut.cz>
+
+ * gdb.mi/mi-complete.exp: New file.
+ * gdb.mi/mi-complete.cc: Likewise.
+
2019-05-15 Bernhard Heckel <bernhard.heckel@intel.com>
* gdb.fortran/vla-sizeof.exp: Add tests of sizeof applied to
diff --git a/gdb/testsuite/gdb.mi/mi-complete.cc b/gdb/testsuite/gdb.mi/mi-complete.cc
new file mode 100644
index 0000000..3742152
--- /dev/null
+++ b/gdb/testsuite/gdb.mi/mi-complete.cc
@@ -0,0 +1,40 @@
+/* Copyright 2018-2019 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <vector>
+
+class A
+{
+public:
+ void push_back (void *value);
+};
+
+void
+A::push_back (void *value)
+{
+ /* nothing */
+}
+
+int
+main (int argc, char **argv)
+{
+ std::vector < int >v;
+ v.push_back (1);
+ A a;
+ a.push_back (&v);
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.mi/mi-complete.exp b/gdb/testsuite/gdb.mi/mi-complete.exp
new file mode 100644
index 0000000..692b004
--- /dev/null
+++ b/gdb/testsuite/gdb.mi/mi-complete.exp
@@ -0,0 +1,72 @@
+# Copyright 2018-2019 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Verify GDB/MI -complete in various scenarios. This test only tests
+# -complete command, not the correctness of completions.
+
+load_lib mi-support.exp
+set MIFLAGS "-i=mi"
+
+gdb_exit
+if [mi_gdb_start] {
+ continue
+}
+
+standard_testfile .cc
+
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
+ untested "failed to compile"
+ return -1
+}
+
+mi_run_to_main
+
+mi_gdb_test "1-complete br" \
+ "1\\^done,completion=\"break\",matches=\\\[.*\"break\",.*\"break-range\".*\\\],max_completions_reached=\"0\"" \
+ "-complete br"
+
+# Check empty completion list.
+mi_gdb_test "5-complete bogus" \
+ "5\\^done,matches=\\\[\\\],max_completions_reached=\"0\"" \
+ "-complete bogus"
+
+# Check completions for commands with space.
+mi_gdb_test "4-complete \"b mai\"" \
+ "4\\^done,completion=\"b main\",matches=\\\[.*\"b main\".*\\\],max_completions_reached=\"0\"" \
+ "-complete \"b mai\""
+
+# Check wildmatching.
+mi_gdb_test "5-complete \"b push_ba\"" \
+ "5\\^done,completion=\"b push_back\\(\",matches=\\\[.*\"b A::push_back\\(void\\*\\)\".*\\\],max_completions_reached=\"0\"" \
+ "-complete \"b push_ba\", wildmatching"
+
+mi_gdb_test "-info-gdb-mi-command complete" \
+ "\\^done,command=\{exists=\"true\"\}" \
+ "-info-gdb-mi-command complete"
+
+# Limit max completions and check that max_completions_reached=\"0\" is set
+# to 1.
+send_gdb "set max-completions 1\n"
+
+mi_gdb_test "2-complete br" \
+ ".*2\\^done,completion=\"br\[A-Za-z0-9-\]+\",matches=\\\[\"br\[A-Za-z0-9-\]+\"\\\],max_completions_reached=\"1\"" \
+ "-complete br, max-completions 1"
+
+# Disable completions and check an error is returned
+send_gdb "set max-completions 0\n"
+
+mi_gdb_test "3-complete br" \
+ ".*3\\^error,msg=\".*" \
+ "-complete br, max-completions 0"