aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2012-03-01 19:30:25 +0000
committerDoug Evans <dje@google.com>2012-03-01 19:30:25 +0000
commit7d74f2446c5ebad93f62426e285b64de882db843 (patch)
treeb3bae2bccf6b51d2496c706ee1fb68911c000e0c /gdb/testsuite
parente88acd96184003169ba2c23cfd807243da100d72 (diff)
downloadgdb-7d74f2446c5ebad93f62426e285b64de882db843.zip
gdb-7d74f2446c5ebad93f62426e285b64de882db843.tar.gz
gdb-7d74f2446c5ebad93f62426e285b64de882db843.tar.bz2
* NEWS: Mention new python command class gdb.COMMAND_USER.
* cli/cli-cmds.c (show_user): Print error when used on a python command. (init_cli_cmds): Update documentation strings for "show user" and "set/show max-user-call-depth" to clarify that it does not apply to python commands. * python/py-cmd.c (cmdpy_init): Treat class_user as a valid class in error check. (gdbpy_initialize_commands): Add COMMAND_USER as a constant in gdb python api. * top.c (execute_command): Only execute a user-defined command as a legacy macro if c->user_commands is set. doc/ * gdb.texinfo (Commands In Python): Put example python macro in COMMAND_USER category rather than COMMAND_OBSCURE. Document gdb.COMMAND_USER. (User-defined Commands): Update documentation to clarify "set/show max-user-call-depth" and "show user" don't apply to python commands. Update documentation to clarify "help user-defined" may also include python commands defined as COMMAND_USER. testsuite/ * gdb.python/py-cmd.exp: Add test to verify that python commands can be put in the user-defined category and that the commands appear in "help user-defined".
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog6
-rw-r--r--gdb/testsuite/gdb.python/py-cmd.exp17
2 files changed, 23 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 9d6beea..2e450bf 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2012-03-01 Scott J. Goldman <scottjg@vmware.com>
+
+ * gdb.python/py-cmd.exp: Add test to verify that python commands can
+ be put in the user-defined category and that the commands appear in
+ "help user-defined".
+
2012-02-29 Joel Brobecker <brobecker@adacore.com>
* gdb.ada/tagged_not_init: New testcase.
diff --git a/gdb/testsuite/gdb.python/py-cmd.exp b/gdb/testsuite/gdb.python/py-cmd.exp
index fc7cac0..36fa343 100644
--- a/gdb/testsuite/gdb.python/py-cmd.exp
+++ b/gdb/testsuite/gdb.python/py-cmd.exp
@@ -138,3 +138,20 @@ gdb_test "python print gdb.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')"
+
+# Test user-defined python commands.
+gdb_py_test_multiple "input simple user-defined command" \
+ "python" "" \
+ "class test_help (gdb.Command):" "" \
+ " \"\"\"Docstring\"\"\"" "" \
+ " def __init__ (self):" "" \
+ " super (test_help, self).__init__ (\"test_help\", gdb.COMMAND_USER)" "" \
+ " def invoke (self, arg, from_tty):" "" \
+ " print \"test_cmd output, arg = %s\" % arg" "" \
+ "test_help ()" "" \
+ "end" ""
+
+gdb_test "test_help ugh" "test_cmd output, arg = ugh" "call simple user-defined command"
+
+# 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`"