[PATCH 0/5] create GDB/MI commands using python

Jan Vrany jan.vrany@labware.com
Mon Jan 17 12:44:20 GMT 2022


This is a restart of an earlier attempts to allow custom
GDB/MI commands written in Python.

I went thought comments made on earlier attempts and changed
code as suggested except in few cases - see my comments below.

====
gdb/python/py-micmd.c

> > +
> > +extern PyTypeObject
> > +  micmdpy_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("micmdpy_object");
>
> Is there a reason this is "extern"?  I don't see this used anywhere
> outside py-micmd.c.

I think it is. micmdpy_object_type is needed in gdbpy_initialize_micommands() and then
it is statically initialized at the bottom of the file when all functions are defined.
The extern allows this. Same thing is done in py-cmd.c for CLI commands.


> > +
> > +/* If the command invoked returns a list, this function parses it and create an
> > +   appropriate MI out output.
> > +
> > +   The returned values must be Python string,
>
> "values ... string" doesn't parse correctly for me.
>
> Did you mean

I have rewritten the comment and renamed the function to emit_py_result()
which seems to me a better name (now).


> > +         }
> > +     }

> There's aspace vs tabs mixup above, and in other parts
> of the file too.  Please fix that throughout.

Changed to use spaces consistenly.


> > +
> > +PyTypeObject micmdpy_object_type = {
>
> Can this be static?

I don't think so, see above.
=====

Jan Vrany (5):
  gdb/mi: introduce new class mi_command_builtin
  gdb/python: create GDB/MI commands using python.
  gdb/python: allow redefinition of python GDB/MI commands
  gdb/testsuite: add tests for python-defined MI commands
  gdb/python: document GDB/MI commands in Python

 gdb/Makefile.in                        |   1 +
 gdb/NEWS                               |   2 +
 gdb/doc/python.texi                    |  80 ++++++-
 gdb/mi/mi-cmds.c                       |  60 +++--
 gdb/mi/mi-cmds.h                       |  32 ++-
 gdb/python/py-micmd.c                  | 312 +++++++++++++++++++++++++
 gdb/python/py-micmd.h                  |  66 ++++++
 gdb/python/python-internal.h           |   2 +
 gdb/python/python.c                    |  13 +-
 gdb/testsuite/gdb.python/py-mi-cmd.exp | 133 +++++++++++
 gdb/testsuite/gdb.python/py-mi-cmd.py  |  68 ++++++
 11 files changed, 733 insertions(+), 36 deletions(-)
 create mode 100644 gdb/python/py-micmd.c
 create mode 100644 gdb/python/py-micmd.h
 create mode 100644 gdb/testsuite/gdb.python/py-mi-cmd.exp
 create mode 100644 gdb/testsuite/gdb.python/py-mi-cmd.py

-- 
2.30.2



More information about the Gdb-patches mailing list