From patchwork Sun Apr 26 19:49:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Allow Python commands to be in class_tui X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 34505 Message-Id: <20200426194915.15629-1-tom@tromey.com> To: gdb-patches@sourceware.org Cc: Tom Tromey Date: Sun, 26 Apr 2020 13:49:15 -0600 From: Tom Tromey List-Id: Gdb-patches mailing list Now that Python code can create TUI windows, it seemed appropriate to allow Python commands to appear in the "TUI" help class. This patch adds this capability. 2020-04-25 Tom Tromey * NEWS: Update. * python/py-cmd.c (gdbpy_initialize_commands): Add COMMAND_TUI. (cmdpy_init): Allow class_tui. gdb/doc/ChangeLog 2020-04-25 Tom Tromey * python.texi (Commands In Python): Document gdb.COMMAND_TUI. --- gdb/ChangeLog | 6 ++++++ gdb/NEWS | 3 +++ gdb/doc/ChangeLog | 4 ++++ gdb/doc/python.texi | 7 +++++++ gdb/python/py-cmd.c | 9 +++++---- 5 files changed, 25 insertions(+), 4 deletions(-) -- 2.17.2 diff --git a/gdb/NEWS b/gdb/NEWS index 01e73c9e5ea..5b9eabe746c 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -73,6 +73,9 @@ GNU/Linux/RISC-V (gdbserver) riscv*-*-linux* field of a dynamic type may have None for its "bitpos" attribute as well. + ** Commands written in Python can be in the "TUI" help class by + registering with the new constant gdb.COMMAND_TUI. + *** Changes in GDB 9 * 'thread-exited' event is now available in the annotations interface. diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi index cfa813128ce..d0ec45c0263 100644 --- a/gdb/doc/python.texi +++ b/gdb/doc/python.texi @@ -3811,6 +3811,13 @@ The command has to do with tracepoints. For example, @code{trace}, @kbd{help tracepoints} at the @value{GDBN} prompt to see a list of commands in this category. +@findex COMMAND_TUI +@findex gdb.COMMAND_TUI +@item gdb.COMMAND_TUI +The command has to do with the text user interface (@pxref{TUI}). +Type @kbd{help tui} at the @value{GDBN} prompt to see a list of +commands in this category. + @findex COMMAND_USER @findex gdb.COMMAND_USER @item gdb.COMMAND_USER diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c index b822c140041..3c1c566b0a1 100644 --- a/gdb/python/py-cmd.c +++ b/gdb/python/py-cmd.c @@ -465,7 +465,8 @@ 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_user) + && cmdtype != class_maintenance && cmdtype != class_user + && cmdtype != class_tui) { PyErr_Format (PyExc_RuntimeError, _("Invalid command class argument.")); return -1; @@ -593,8 +594,7 @@ gdbpy_initialize_commands (void) if (PyType_Ready (&cmdpy_object_type) < 0) return -1; - /* Note: alias and user are special; pseudo appears to be unused, - and there is no reason to expose tui, I think. */ + /* Note: alias and user are special. */ if (PyModule_AddIntConstant (gdb_module, "COMMAND_NONE", no_class) < 0 || PyModule_AddIntConstant (gdb_module, "COMMAND_RUNNING", class_run) < 0 || PyModule_AddIntConstant (gdb_module, "COMMAND_DATA", class_vars) < 0 @@ -611,7 +611,8 @@ gdbpy_initialize_commands (void) class_obscure) < 0 || PyModule_AddIntConstant (gdb_module, "COMMAND_MAINTENANCE", class_maintenance) < 0 - || PyModule_AddIntConstant (gdb_module, "COMMAND_USER", class_user) < 0) + || PyModule_AddIntConstant (gdb_module, "COMMAND_USER", class_user) < 0 + || PyModule_AddIntConstant (gdb_module, "COMMAND_TUI", class_tui) < 0) return -1; for (i = 0; i < N_COMPLETERS; ++i)