public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [patch][python] Fix python/15747 (provide access to COMPLETE_EXPRESSION
@ 2013-09-18 12:55 Phil Muldoon
  2013-09-18 20:14 ` Tom Tromey
  0 siblings, 1 reply; 6+ messages in thread
From: Phil Muldoon @ 2013-09-18 12:55 UTC (permalink / raw)
  To: gdb-patches


This patch adds support for the COMPLETE_EXPRESSION constant for
Python commands.  It also adds a test case for it using fields.

OK?

Cheers,

Phil


2013-09-18  Phil Muldoon  <pmuldoon@redhat.com>
	    
	PR python/15747

	* python/py-cmd.c: Add COMPLETE_EXPRESSION constant.

2013-09-18  Phil Muldoon  <pmuldoon@redhat.com>

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

2013-09-18  Phil Muldoon  <pmuldoon@redhat.com>

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

--

diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 60d2877..f277fde 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -25856,6 +25856,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
diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c
index 8b6252e..56321fa 100644
--- a/gdb/python/py-cmd.c
+++ b/gdb/python/py-cmd.c
@@ -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]))
diff --git a/gdb/testsuite/gdb.python/py-cmd.c b/gdb/testsuite/gdb.python/py-cmd.c
index e69de29..7f0dc59 100644
--- a/gdb/testsuite/gdb.python/py-cmd.c
+++ b/gdb/testsuite/gdb.python/py-cmd.c
@@ -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;
+}
diff --git a/gdb/testsuite/gdb.python/py-cmd.exp b/gdb/testsuite/gdb.python/py-cmd.exp
index 610fe52..6d12950 100644
--- a/gdb/testsuite/gdb.python/py-cmd.exp
+++ b/gdb/testsuite/gdb.python/py-cmd.exp
@@ -18,15 +18,20 @@
 
 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"
+	    }
+	}
+    }
+}
	

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch][python] Fix python/15747 (provide access to COMPLETE_EXPRESSION
  2013-09-18 12:55 [patch][python] Fix python/15747 (provide access to COMPLETE_EXPRESSION Phil Muldoon
@ 2013-09-18 20:14 ` Tom Tromey
  2013-10-01 11:30   ` Phil Muldoon
  0 siblings, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2013-09-18 20:14 UTC (permalink / raw)
  To: Phil Muldoon; +Cc: gdb-patches

>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes:

Phil> This patch adds support for the COMPLETE_EXPRESSION constant for
Phil> Python commands.  It also adds a test case for it using fields.

Thanks Phil.

Phil> 2013-09-18  Phil Muldoon  <pmuldoon@redhat.com>
Phil> 	PR python/15747
Phil> 	* python/py-cmd.c: Add COMPLETE_EXPRESSION constant.
Phil> 2013-09-18  Phil Muldoon  <pmuldoon@redhat.com>
Phil> 	* gdb.python/py-cmd.exp: Add COMPLETE_EXPRESSION tests.
Phil> 	* gdb.python/py-cmd.c: New File.

The code bits are ok.

Tom

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch][python] Fix python/15747 (provide access to COMPLETE_EXPRESSION
  2013-09-18 20:14 ` Tom Tromey
@ 2013-10-01 11:30   ` Phil Muldoon
  2013-11-04 10:11     ` Phil Muldoon
  0 siblings, 1 reply; 6+ messages in thread
From: Phil Muldoon @ 2013-10-01 11:30 UTC (permalink / raw)
  To: eliz; +Cc: gdb-patches

On 18/09/13 21:14, Tom Tromey wrote:
>>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes:
> 
> Phil> This patch adds support for the COMPLETE_EXPRESSION constant for
> Phil> Python commands.  It also adds a test case for it using fields.
> 
> Thanks Phil.
> 
> Phil> 2013-09-18  Phil Muldoon  <pmuldoon@redhat.com>
> Phil> 	PR python/15747
> Phil> 	* python/py-cmd.c: Add COMPLETE_EXPRESSION constant.
> Phil> 2013-09-18  Phil Muldoon  <pmuldoon@redhat.com>
> Phil> 	* gdb.python/py-cmd.exp: Add COMPLETE_EXPRESSION tests.
> Phil> 	* gdb.python/py-cmd.c: New File.
> 
> The code bits are ok.

Doc ping

Cheers

Phil

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch][python] Fix python/15747 (provide access to COMPLETE_EXPRESSION
  2013-10-01 11:30   ` Phil Muldoon
@ 2013-11-04 10:11     ` Phil Muldoon
  2013-11-04 16:24       ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Phil Muldoon @ 2013-11-04 10:11 UTC (permalink / raw)
  To: eliz; +Cc: gdb-patches

On 01/10/13 12:30, Phil Muldoon wrote:
> On 18/09/13 21:14, Tom Tromey wrote:
>>>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes:
>>
>> Phil> This patch adds support for the COMPLETE_EXPRESSION constant for
>> Phil> Python commands.  It also adds a test case for it using fields.
>>
>> Thanks Phil.
>>
>> Phil> 2013-09-18  Phil Muldoon  <pmuldoon@redhat.com>
>> Phil> 	PR python/15747
>> Phil> 	* python/py-cmd.c: Add COMPLETE_EXPRESSION constant.
>> Phil> 2013-09-18  Phil Muldoon  <pmuldoon@redhat.com>
>> Phil> 	* gdb.python/py-cmd.exp: Add COMPLETE_EXPRESSION tests.
>> Phil> 	* gdb.python/py-cmd.c: New File.
>>
>> The code bits are ok.
> 
> Doc ping

Doc Ping

Cheers,

Phil

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch][python] Fix python/15747 (provide access to COMPLETE_EXPRESSION
  2013-11-04 10:11     ` Phil Muldoon
@ 2013-11-04 16:24       ` Eli Zaretskii
  2013-11-07 13:06         ` Phil Muldoon
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2013-11-04 16:24 UTC (permalink / raw)
  To: Phil Muldoon; +Cc: gdb-patches

> Date: Mon, 04 Nov 2013 10:11:16 +0000
> From: Phil Muldoon <pmuldoon@redhat.com>
> CC: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
> 
> On 01/10/13 12:30, Phil Muldoon wrote:
> > On 18/09/13 21:14, Tom Tromey wrote:
> >>>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes:
> >>
> >> Phil> This patch adds support for the COMPLETE_EXPRESSION constant for
> >> Phil> Python commands.  It also adds a test case for it using fields.
> >>
> >> Thanks Phil.
> >>
> >> Phil> 2013-09-18  Phil Muldoon  <pmuldoon@redhat.com>
> >> Phil> 	PR python/15747
> >> Phil> 	* python/py-cmd.c: Add COMPLETE_EXPRESSION constant.
> >> Phil> 2013-09-18  Phil Muldoon  <pmuldoon@redhat.com>
> >> Phil> 	* gdb.python/py-cmd.exp: Add COMPLETE_EXPRESSION tests.
> >> Phil> 	* gdb.python/py-cmd.c: New File.
> >>
> >> The code bits are ok.
> > 
> > Doc ping
> 
> Doc Ping

Sorry, the doc parts is OK.

Thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch][python] Fix python/15747 (provide access to COMPLETE_EXPRESSION
  2013-11-04 16:24       ` Eli Zaretskii
@ 2013-11-07 13:06         ` Phil Muldoon
  0 siblings, 0 replies; 6+ messages in thread
From: Phil Muldoon @ 2013-11-07 13:06 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

On 04/11/13 16:08, Eli Zaretskii wrote:
>> Date: Mon, 04 Nov 2013 10:11:16 +0000
>> From: Phil Muldoon <pmuldoon@redhat.com>
>> CC: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
>>
>> On 01/10/13 12:30, Phil Muldoon wrote:
>>> On 18/09/13 21:14, Tom Tromey wrote:
>>>>>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes:
>>>>
>>>> Phil> This patch adds support for the COMPLETE_EXPRESSION constant for
>>>> Phil> Python commands.  It also adds a test case for it using fields.
>>>>
>>>> Thanks Phil.
>>>>
>>>> Phil> 2013-09-18  Phil Muldoon  <pmuldoon@redhat.com>
>>>> Phil> 	PR python/15747
>>>> Phil> 	* python/py-cmd.c: Add COMPLETE_EXPRESSION constant.
>>>> Phil> 2013-09-18  Phil Muldoon  <pmuldoon@redhat.com>
>>>> Phil> 	* gdb.python/py-cmd.exp: Add COMPLETE_EXPRESSION tests.
>>>> Phil> 	* gdb.python/py-cmd.c: New File.
>>>>
>>>> The code bits are ok.

> 
> Sorry, the doc parts is OK.

So committed, thanks,

Cheers,

Phil

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-11-07 12:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-18 12:55 [patch][python] Fix python/15747 (provide access to COMPLETE_EXPRESSION Phil Muldoon
2013-09-18 20:14 ` Tom Tromey
2013-10-01 11:30   ` Phil Muldoon
2013-11-04 10:11     ` Phil Muldoon
2013-11-04 16:24       ` Eli Zaretskii
2013-11-07 13:06         ` Phil Muldoon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).