Re: [patch] python prompt additions at first prompt.

Matt Rice
2011-08-01T17:44:12Z

[-- Attachment #1: Type: text/plain, Size: 791 bytes --]

On Mon, Aug 1, 2011 at 7:13 AM, Phil Muldoon <pmuldoon@redhat.com> wrote:
> Matt Rice <ratmice@gmail.com> writes:
>
>> On Mon, Aug 1, 2011 at 2:50 AM, Phil Muldoon <pmuldoon@redhat.com> wrote:
>>> Matt Rice <ratmice@gmail.com> writes:
>>>
>>>> little bug with the new python prompt stuff, the prompt_hook doesn't
>>>> take effect until the second prompt.
>>>
>>> Thanks for doing this.  This looks fine to me, apart from one question.
>>>
>>> For tests, there are prompt tests in the python.exp file for prompt
>>> substitutions.  For passing arguments to GDB at start-up, see usage of
>>> $GDBFLAGS in the testsuite.

Think it was the quoting of $gdb_prompt which had me foiled.

2011-08-01 Matt Rice <ratmice@gmail.com>

* gdb.python/py-prompt.exp: New file.

[-- Attachment #2: testsuite.diff --]
[-- Type: text/x-patch, Size: 2078 bytes --]

diff --git a/gdb/testsuite/gdb.python/py-prompt.exp b/gdb/testsuite/gdb.python/py-prompt.exp
new file mode 100644
index 0000000..fc15931
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-prompt.exp
@@ -0,0 +1,60 @@
+# Copyright (C) 2009, 2010, 2011 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/>.
+
+# This file is part of the GDB testsuite. It tests the mechanism
+# for defining new GDB commands in Python.
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+load_lib gdb-python.exp
+
+# Start with a fresh gdb.
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+
+# Skip all tests if Python scripting is not enabled.
+if { [skip_python_tests] } { continue }
+gdb_exit
+
+global GDBFLAGS
+set saved_gdbflags $GDBFLAGS
+set GDBFLAGS [concat $GDBFLAGS " -ex \"python def foo(x): return \'(Foo) \'\""]
+set GDBFLAGS [concat $GDBFLAGS " -ex \"python gdb.prompt_hook = foo\""]
+
+set tmp_gdbflags $GDBFLAGS
+set saved_gdb_prompt $gdb_prompt
+
+global gdb_prompt
+set gdb_prompt "\[(\]Foo\[)\]"
+
+
+# The following tests are strange in that we are testing the first prompt
+# gdb_start will fail/timeout if does not receive the '(foo) ' prompt.
+# otherwise no 'passing' test is performed.
+set GDBFLAGS [concat $tmp_gdbflags " -ex \"set editing on\""]
+gdb_start
+gdb_exit
+
+set GDBFLAGS [concat $tmp_gdbflags " -ex \"set editing off\""]
+gdb_start
+gdb_exit
+
+set GDBFLAGS $saved_gdbflags
+set gdb_prompt $saved_gdb_prompt
+return 0