From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1164 invoked by alias); 18 May 2011 23:28:24 -0000 Received: (qmail 1155 invoked by uid 22791); 18 May 2011 23:28:23 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI,TW_MD,TW_RG,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-outbound-2.vmware.com (HELO smtp-outbound-2.vmware.com) (65.115.85.73) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 18 May 2011 23:28:01 +0000 Received: from mailhost3.vmware.com (mailhost3.vmware.com [10.16.27.45]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id 1A4D62700A for ; Wed, 18 May 2011 16:28:01 -0700 (PDT) Received: from promd-1n-dhcp85.eng.vmware.com (scottjg-dev.eng.vmware.com [10.20.118.44]) by mailhost3.vmware.com (Postfix) with ESMTP id 155A6CD9B8; Wed, 18 May 2011 16:28:01 -0700 (PDT) From: "Scott J. Goldman" To: gdb-patches@sourceware.org Cc: "Scott J. Goldman" Subject: [PATCH] Add support for `user-defined` python commands Date: Wed, 18 May 2011 23:28:00 -0000 Message-Id: <1305761175-10188-1-git-send-email-scottjg@vmware.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-05/txt/msg00414.txt.bz2 For codebases with a large pre-existing set of legacy gdb macros, it's nice to be able to use `help user-defined`, to refresh your memory wrt to existing macros. Currently, python gdb commands can't put themselves under the `user-defined` category. This patch aims to rectify that. --- gdb/ChangeLog | 6 ++++++ gdb/doc/ChangeLog | 4 ++++ gdb/doc/gdb.texinfo | 10 +++++++++- gdb/python/py-cmd.c | 6 ++++-- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 3103398..9f9fade 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2011-05-18 Scott J. Goldman + + Add support to define python commands as 'user-defined' + * py-cmd.c (gdbpy_initialize_commands): support COMMAND_USER type + (cmdpy_init): support class_user + 2011-05-18 Tom Tromey * dwarf2read.c (dwarf2_add_field): Constify. diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 0469b0a..d21c9ef 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,7 @@ +2011-05-18 Scott J. Goldman + + * gdb.texinfo: Document COMMAND_USER python command type + 2011-05-17 Pedro Alves * gdb.texinfo (Remote Protocol) : Mention vCont is diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 584a520..8b15ed2 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -21124,7 +21124,7 @@ to handle this case. Example: >class HelloWorld (gdb.Command): > """Greet the whole world.""" > def __init__ (self): -> super (HelloWorld, self).__init__ ("hello-world", gdb.COMMAND_OBSCURE) +> super (HelloWorld, self).__init__ ("hello-world", gdb.COMMAND_USER) > def invoke (self, args, from_tty): > argv = gdb.string_to_argv (args) > if len (argv) != 0: @@ -22450,6 +22450,14 @@ The command is only useful to @value{GDBN} maintainers. The @code{maintenance} and @code{flushregs} commands are in this category. Type @kbd{help internals} at the @value{GDBN} prompt to see a list of commands in this category. + +@findex COMMAND_USER +@findex gdb.COMMAND_USER +@item COMMAND_USER +The command is considered user-defined. Old-style @value{GDBN} +command macros always fall under this category. +Type @kbd{help user-defined} at the @value{GDBN} prompt to see a list +of commands in this category. @end table A new command can use a predefined completion function, either by diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c index c0e3291..8b8e384 100644 --- a/gdb/python/py-cmd.c +++ b/gdb/python/py-cmd.c @@ -436,7 +436,7 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw) && cmdtype != class_files && cmdtype != class_support && cmdtype != class_info && cmdtype != class_breakpoint && cmdtype != class_trace && cmdtype != class_obscure - && cmdtype != class_maintenance) + && cmdtype != class_maintenance && cmdtype != class_user) { PyErr_Format (PyExc_RuntimeError, _("Invalid command class argument.")); return -1; @@ -576,7 +576,9 @@ gdbpy_initialize_commands (void) || PyModule_AddIntConstant (gdb_module, "COMMAND_OBSCURE", class_obscure) < 0 || PyModule_AddIntConstant (gdb_module, "COMMAND_MAINTENANCE", - class_maintenance) < 0) + class_maintenance) < 0 + || PyModule_AddIntConstant (gdb_module, "COMMAND_USER", class_user) < 0) + return; for (i = 0; i < N_COMPLETERS; ++i) -- 1.7.4.1