aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.python
diff options
context:
space:
mode:
authorThiago Jung Bauermann <bauerman@br.ibm.com>2009-03-21 03:13:02 +0000
committerThiago Jung Bauermann <bauerman@br.ibm.com>2009-03-21 03:13:02 +0000
commitcc924cad9149ec2249eb5b18658b2516a9014969 (patch)
tree56fab376894dbf9010290b011765fe677c77f8b8 /gdb/testsuite/gdb.python
parentbc3b79fd1ac12e5432ef017d81064427d04a2d71 (diff)
downloadgdb-cc924cad9149ec2249eb5b18658b2516a9014969.zip
gdb-cc924cad9149ec2249eb5b18658b2516a9014969.tar.gz
gdb-cc924cad9149ec2249eb5b18658b2516a9014969.tar.bz2
gdb/
2009-03-21 Jan Kratochvil <jan.kratochvil@redhat.com> Jim Blandy <jimb@red-bean.com> Thiago Jung Bauermann <bauerman@br.ibm.com> Tom Tromey <tromey@redhat.com> Miscellaneous fixes to the Python code. * python/python-cmd.c (cmdpy_init): Accept keyword arguments. * python/python-value.c (valpy_string): Accept keyword arguments. (valpy_binop): Use `break' to exit from the TRY_CATCH block. Do not call value_to_value_object on NULL RES_VAL. (value_object_methods): Change `string' entry to also accept keyword arguments. (convert_value_from_python): Return a copy of the value if obj is a gdb.Value object. (value_object_methods): Mark the `string' method as accepting keywords, and show method "prototype" in the doc string. * python/python.c (get_parameter): Don't return inside a TRY_CATCH. gdb/doc/ 2009-03-21 Thiago Jung Bauermann <bauerman@br.ibm.com> * gdb.texinfo (Values From Inferior): Fix optional arguments markup. (Commands In Python): Adjust argument names of gdb.Command.__init__ to what the function accepts as keywords. gdb/testsuite/ 2009-03-21 Thiago Jung Bauermann <bauerman@br.ibm.com> * gdb.python/python-cmd.exp: Add tests for keyword arguments. * gdb.python/python-function.exp: Add test for function returning a GDB value.
Diffstat (limited to 'gdb/testsuite/gdb.python')
-rw-r--r--gdb/testsuite/gdb.python/python-cmd.exp26
-rw-r--r--gdb/testsuite/gdb.python/python-function.exp14
2 files changed, 40 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.python/python-cmd.exp b/gdb/testsuite/gdb.python/python-cmd.exp
index 6c73ff2..f6ef938 100644
--- a/gdb/testsuite/gdb.python/python-cmd.exp
+++ b/gdb/testsuite/gdb.python/python-cmd.exp
@@ -92,6 +92,32 @@ gdb_py_test_multiple "input subcommand" \
gdb_test "prefix_cmd subcmd ugh" "subcmd output, arg = ugh" "call subcmd"
+# Test prefix command using keyword arguments.
+
+gdb_py_test_multiple "input prefix command, keyword arguments" \
+ "python" "" \
+ "class prefix_cmd2 (gdb.Command):" "" \
+ " def __init__ (self):" "" \
+ " super (prefix_cmd2, self).__init__ (\"prefix_cmd2\", gdb.COMMAND_OBSCURE, prefix = True, completer_class = gdb.COMPLETE_FILENAME)" "" \
+ " def invoke (self, arg, from_tty):" "" \
+ " print \"prefix_cmd2 output, arg = %s\" % arg" "" \
+ "prefix_cmd2 ()" "" \
+ "end" ""
+
+gdb_test "prefix_cmd2 argh" "prefix_cmd2 output, arg = argh" "call prefix command, keyword arguments"
+
+gdb_py_test_multiple "input subcommand under prefix_cmd2" \
+ "python" "" \
+ "class subcmd (gdb.Command):" "" \
+ " def __init__ (self):" "" \
+ " super (subcmd, self).__init__ (\"prefix_cmd2 subcmd\", gdb.COMMAND_OBSCURE)" "" \
+ " def invoke (self, arg, from_tty):" "" \
+ " print \"subcmd output, arg = %s\" % arg" "" \
+ "subcmd ()" "" \
+ "end" ""
+
+gdb_test "prefix_cmd2 subcmd ugh" "subcmd output, arg = ugh" "call subcmd under prefix_cmd2"
+
# Test a subcommand in an existing GDB prefix.
gdb_py_test_multiple "input new subcommand" \
diff --git a/gdb/testsuite/gdb.python/python-function.exp b/gdb/testsuite/gdb.python/python-function.exp
index 3ffc5aa..7feca2b 100644
--- a/gdb/testsuite/gdb.python/python-function.exp
+++ b/gdb/testsuite/gdb.python/python-function.exp
@@ -63,3 +63,17 @@ gdb_py_test_multiple "input convenience function" \
"end" ""
gdb_test "print \$test_func (\"ugh\")" "= \"test_func output, arg = ugh\"" "call function"
+
+# Test returning a gdb.Value from the function. This segfaulted GDB at one point.
+
+gdb_py_test_multiple "input value-returning convenience function" \
+ "python" "" \
+ "class Double (gdb.Function):" "" \
+ " def __init__ (self):" "" \
+ " super (Double, self).__init__ (\"double\")" "" \
+ " def invoke (self, n):" "" \
+ " return n*2" "" \
+ "Double ()" "" \
+ "end" ""
+
+gdb_test "print \$double (1)" "= 2" "call value-returning function"