aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2010-05-25 15:27:17 +0000
committerDoug Evans <dje@google.com>2010-05-25 15:27:17 +0000
commit07ca107c2d958b45633ef0cdcce7219a95f0cf01 (patch)
tree489e342ae66a8cac06bdb3d0106dbccb2b15010c /gdb/testsuite
parent8e45593ff36c03d6f39e28a0a7947ce3d282794d (diff)
downloadgdb-07ca107c2d958b45633ef0cdcce7219a95f0cf01.zip
gdb-07ca107c2d958b45633ef0cdcce7219a95f0cf01.tar.gz
gdb-07ca107c2d958b45633ef0cdcce7219a95f0cf01.tar.bz2
Add python gdb.GdbError and gdb.string_to_argv.
* NEWS: Document them. * python/py-cmd.c (cmdpy_function): Don't print a traceback if the exception is gdb.GdbError. Print a second traceback if there's an error computing the error message. (gdbpy_string_to_argv): New function. * python/py-utils.c (gdbpy_obj_to_string): New function. (gdbpy_exception_to_string): New function. * python/python-internal.h (gdbpy_string_to_argv): Declare. (gdbpy_obj_to_string, gdbpy_exception_to_string): Declare. (gdbpy_gdberror_exc): Declare. * python/python.c (gdbpy_gdberror_exc): New global. (_initialize_python): Initialize gdbpy_gdberror_exc and create gdb.GdbError. (GdbMethods): Add string_to_argv. doc/ * gdb.texinfo (Exception Handling): Document gdb.GdbError. (Commands In Python): Document gdb.string_to_argv. testsuite/ * gdb.python/py-cmd.exp: Add tests for gdb.GdbError and gdb.string_to_argv.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.python/py-cmd.exp32
2 files changed, 37 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 3da5ebd..6526f1a 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2010-05-25 Doug Evans <dje@google.com>
+
+ * gdb.python/py-cmd.exp: Add tests for gdb.GdbError and
+ gdb.string_to_argv.
+
2010-05-24 Michael Snyder <msnyder@vmware.com>
* gdb.base/call-ar-st.exp: Replace send_gdb with gdb_test.
diff --git a/gdb/testsuite/gdb.python/py-cmd.exp b/gdb/testsuite/gdb.python/py-cmd.exp
index d3c05ff..0f250d2 100644
--- a/gdb/testsuite/gdb.python/py-cmd.exp
+++ b/gdb/testsuite/gdb.python/py-cmd.exp
@@ -126,3 +126,35 @@ gdb_py_test_multiple "input new subcommand" \
"end" ""
gdb_test "info newsubcmd ugh" "newsubcmd output, arg = ugh" "call newsubcmd"
+
+# Test a command that throws gdb.GdbError.
+
+gdb_py_test_multiple "input command to throw error" \
+ "python" "" \
+ "class test_error_cmd (gdb.Command):" "" \
+ " def __init__ (self):" "" \
+ " super (test_error_cmd, self).__init__ (\"test_error_cmd\", gdb.COMMAND_OBSCURE)" "" \
+ " def invoke (self, arg, from_tty):" "" \
+ " raise gdb.GdbError ('you lose!')" "" \
+ "test_error_cmd ()" "" \
+ "end" ""
+
+gdb_test "test_error_cmd ugh" "you lose!" "call error command"
+
+# Test gdb.string_to_argv.
+
+gdb_test "python print gdb.string_to_argv (\"1 2 3\")" \
+ {\['1', '2', '3'\]} \
+ "string_to_argv (\"1 2 3\")"
+
+gdb_test "python print gdb.string_to_argv (\"'1 2' 3\")" \
+ {\['1 2', '3'\]} \
+ "string_to_argv (\"'1 2' 3\")"
+
+gdb_test "python print gdb.string_to_argv ('\"1 2\" 3')" \
+ {\['1 2', '3'\]} \
+ "string_to_argv ('\"1 2\" 3')"
+
+gdb_test "python print gdb.string_to_argv ('1\\ 2 3')" \
+ {\['1 2', '3'\]} \
+ "string_to_argv ('1\\ 2 3')"