From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14862 invoked by alias); 14 Feb 2012 00:49:03 -0000 Received: (qmail 14837 invoked by uid 22791); 14 Feb 2012 00:49:00 -0000 X-SWARE-Spam-Status: No, hits=0.9 required=5.0 tests=BAYES_50,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) (208.91.2.13) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 14 Feb 2012 00:48:46 +0000 Received: from sc9-mailhost2.vmware.com (sc9-mailhost2.vmware.com [10.113.161.72]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id 7703B28A2D for ; Mon, 13 Feb 2012 16:48:45 -0800 (PST) Received: from pa-exht04.vmware.com (pa-exht04.vmware.com [10.16.45.224]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id 73305B017B for ; Mon, 13 Feb 2012 16:48:45 -0800 (PST) Received: from exch-mbx-111.vmware.com ([10.113.190.111]) by pa-exht04.vmware.com ([10.16.45.224]) with mapi; Mon, 13 Feb 2012 16:48:45 -0800 From: Scott Goldman To: "gdb-patches@sourceware.org" Date: Tue, 14 Feb 2012 00:49:00 -0000 Subject: [PATCH] Allow user-defined as a category for python gdb macros (resend) Message-ID: <03E840D17E263A48A5766AD576E0423A03D72B653F@exch-mbx-111.vmware.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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: 2012-02/txt/msg00246.txt.bz2 Hi. The VMware legal folks and FSF legal folks seem to be done with their back and forth, and I am told it is now legally ok for this patch to be committed. This patch allows python macros to coexist with legacy gdb macros in user-defined category. This way, it's possible to organize your macros such that `help user` shows both legacy and python macros. I also modified the documentation to use the `user` category in the example python macro. It seemed like a more reasonable default category than `obscure`. 2012-02-13 Scott J. Goldman * gdb.texinfo: put example python macro in COMMAND_USER category rather than COMMAND_OBSCURE. * 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. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 9edc6ad..2a26cbe 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -21871,7 +21871,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 =3D gdb.string_to_argv (args) > if len (argv) !=3D 0: @@ -23311,7 +23311,7 @@ class HelloWorld (gdb.Command): """Greet the whole world.""" =20 def __init__ (self): - super (HelloWorld, self).__init__ ("hello-world", gdb.COMMAND_OBSCURE) + super (HelloWorld, self).__init__ ("hello-world", gdb.COMMAND_USER) =20 def invoke (self, arg, from_tty): print "Hello, World!" diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c index aad1ab4..04476db 100644 --- a/gdb/python/py-cmd.c +++ b/gdb/python/py-cmd.c @@ -436,7 +436,7 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *k= w) && cmdtype !=3D class_files && cmdtype !=3D class_support && cmdtype !=3D class_info && cmdtype !=3D class_breakpoint && cmdtype !=3D class_trace && cmdtype !=3D class_obscure - && cmdtype !=3D class_maintenance) + && cmdtype !=3D class_maintenance && cmdtype !=3D class_user) { PyErr_Format (PyExc_RuntimeError, _("Invalid command class argument.= ")); return -1; @@ -578,7 +578,8 @@ 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; =20 for (i =3D 0; i < N_COMPLETERS; ++i) diff --git a/gdb/top.c b/gdb/top.c index e41f56c..8a91735 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -470,7 +470,7 @@ execute_command (char *p, int from_tty) if (c->flags & DEPRECATED_WARN_USER) deprecated_cmd_warning (&line); =20 - if (c->class =3D=3D class_user) + if (c->class =3D=3D class_user && c->user_commands) execute_user_command (c, arg); else if (c->type =3D=3D set_cmd || c->type =3D=3D show_cmd) do_setshow_command (arg, from_tty, c);