2013-11-07 Phil Muldoon <pmuldoon@redhat.com>
authorPhil Muldoon <pmuldoon@redhat.com>
Thu, 7 Nov 2013 12:32:31 +0000 (12:32 +0000)
committerPhil Muldoon <pmuldoon@redhat.com>
Thu, 7 Nov 2013 12:32:31 +0000 (12:32 +0000)
        PR python/15747
        * python/py-cmd.c: Add COMPLETE_EXPRESSION constant.

2013-11-07  Phil Muldoon  <pmuldoon@redhat.com>

        * gdb.python/py-cmd.exp: Add COMPLETE_EXPRESSION tests.
        * gdb.python/py-cmd.c: New File.

2013-11-07  Phil Muldoon  <pmuldoon@redhat.com>

        * gdb.texinfo (Commands In Python): Document COMPLETE_EXPRESSION
        constant.

gdb/ChangeLog
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo
gdb/python/py-cmd.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.python/py-cmd.c [new file with mode: 0644]
gdb/testsuite/gdb.python/py-cmd.exp

index 090aee7e364a5addf49e3703c05b286a1f672d0e..40842995702812e8d7599dc83f3f9064ce1036b6 100644 (file)
@@ -1,3 +1,8 @@
+2013-11-07  Phil Muldoon  <pmuldoon@redhat.com>
+
+        PR python/15747
+        * python/py-cmd.c: Add COMPLETE_EXPRESSION constant.
+
 2013-11-07  Phil Muldoon  <pmuldoon@redhat.com>
 
        * NEWS: Document Python temporary breakpoint support.
index 1a29b4f877eb58a8217901306730b50f85e4463f..3894647d2622aee5fbcf19f695749766f453279b 100644 (file)
@@ -1,3 +1,8 @@
+2013-11-07  Phil Muldoon  <pmuldoon@redhat.com>
+
+        * gdb.texinfo (Commands In Python): Document COMPLETE_EXPRESSION
+        constant.
+
 2013-11-07  Phil Muldoon  <pmuldoon@redhat.com>
 
        * gdb.texinfo (Breakpoints In Python): Document temporary
index c735b901730365742d0d3c7ec1bceb9f5c2c780b..6a1ed8d628b2f5c9360ba044b4e255a3897f5996 100644 (file)
@@ -26011,6 +26011,13 @@ command names.
 @item gdb.COMPLETE_SYMBOL
 This constant means that completion should be done using symbol names
 as the source.
+
+@findex COMPLETE_EXPRESSION
+@findex gdb.COMPLETE_EXPRESSION
+@item gdb.COMPLETE_EXPRESSION
+This constant means that completion should be done on expressions.
+Often this means completing on symbol names, but some language
+parsers also have support for completing on field names.
 @end table
 
 The following code snippet shows how a trivial CLI command can be
index 8b6252e555e65e9f6dfbf2b5aa0bf30b56f07feb..56321facc3de10d578372df81b5287a9ca235a89 100644 (file)
@@ -45,6 +45,7 @@ static struct cmdpy_completer completers[] =
   { "COMPLETE_LOCATION", location_completer },
   { "COMPLETE_COMMAND", command_completer },
   { "COMPLETE_SYMBOL", make_symbol_completion_list_fn },
+  { "COMPLETE_EXPRESSION", expression_completer },
 };
 
 #define N_COMPLETERS (sizeof (completers) / sizeof (completers[0]))
index 11ca125e58fe6bc84aafb92a439d5afa502bfc30..3f2467d37a73e163ecb46ad0e6f6873dc68eb1c2 100644 (file)
@@ -1,3 +1,8 @@
+2013-11-07  Phil Muldoon  <pmuldoon@redhat.com>
+
+        * gdb.python/py-cmd.exp: Add COMPLETE_EXPRESSION tests.
+        * gdb.python/py-cmd.c: New File.
+
 2013-11-07  Phil Muldoon  <pmuldoon@redhat.com>
 
        * gdb.python/py-breakpoint.exp: Add temporary breakpoint tests.
diff --git a/gdb/testsuite/gdb.python/py-cmd.c b/gdb/testsuite/gdb.python/py-cmd.c
new file mode 100644 (file)
index 0000000..7f0dc59
--- /dev/null
@@ -0,0 +1,29 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2013 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/>.  */
+
+struct foo
+{
+  int ij;
+  int bc;
+};
+
+int
+main (void)
+{
+  struct foo bar;
+  return 0;
+}
index 610fe52e2d852ca4c3eded83a88ceccaa95d962b..6d129506cbbf34678c282816236b55ecae382b6b 100644 (file)
 
 load_lib gdb-python.exp
 
-# Start with a fresh gdb.
+standard_testfile
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
+    return -1
+}
 
 # Skip all tests if Python scripting is not enabled.
 if { [skip_python_tests] } { continue }
 
+if ![runto_main] then {
+    fail "Cannot run to main."
+    return 0
+}
+
 # Test a simple command.
 
 gdb_py_test_multiple "input simple command" \
@@ -155,3 +160,32 @@ gdb_test "test_help ugh" "test_cmd output, arg = ugh" "call simple user-defined
 
 # Make sure the command shows up in `help user-defined`.
 gdb_test "help user-defined" "User-defined commands.\[\r\n\]+The commands in this class are those defined by the user.\[\r\n\]+Use the \"define\" command to define a command.\[\r\n\]+\[\r\n\]+List of commands:\[\r\n\]+\[\r\n\]+test_help -- Docstring\[\r\n\]+\[\r\n\]+Type \"help\" followed by command name for full documentation.\[\r\n\]+Type \"apropos word\" to search for commands related to \"word\".\[\r\n\]+Command name abbreviations are allowed if unambiguous.\[\r\n\]+" "see user-defined command in `help user-defined`"
+
+# Test expression completion on fields
+gdb_py_test_multiple "expression completion command" \
+  "python" "" \
+  "class expr_test (gdb.Command):" "" \
+  "  def __init__ (self):" "" \
+  "    super (expr_test, self).__init__ (\"expr_test\", gdb.COMMAND_USER, gdb.COMPLETE_EXPRESSION)" "" \
+  "  def invoke (self, arg, from_tty):" "" \
+  "    print (\"invoked on = %s\" % arg)" "" \
+  "expr_test ()" "" \
+  "end" ""
+
+
+gdb_test "complete expr_test bar\." \
+    "expr_test bar\.bc.*expr_test bar\.ij.*" \
+    "Test completion through complete command"
+
+set test "complete 'expr_test bar.i'"
+send_gdb "expr_test bar\.i\t\t"
+gdb_test_multiple "" "$test" {
+    -re "expr_test bar\.ij \\\x07$" {
+       send_gdb "\n"
+       gdb_test_multiple "" $test {
+           -re "invoked on = bar.ij.*$gdb_prompt $" {
+               pass "$test"
+           }
+       }
+    }
+}
This page took 0.068223 seconds and 4 git commands to generate.