[PATCH v2 0/5] Create MI commands using python

Jan Vrany
2019-05-14T11:24:42Z

This is a rework of previous patch series based on Tom's and Simon's
comments. I may happen that I overlooked something since some of
the issues were addressed in subsequent commits and a lot of code
was moved around.

This version *does not* use std::shared_ptr to hold on MI commands, instead
it makes sure that `this` pointer is not used after it me become stale.

Changes v1 -> v2

* squashed following commits into one:
- 8e65585bdab0 Create MI commands using python.
- 9e2afadd2d4d03 mi/python: C++ify python MI command handling code
- 0491a0634f7de4 mi/python: Polish MI output of python commands
* moved class mi_command_py to python code
* use gdbpy_ref<> instead of void* to hold on Python object
in mi_command_py
* release python objects held on by mi_command_py objects
when finalizing Python
* merged py_mi_invoke() into mi_command_py::invoke()
* added missing copyright headers
* dropped micmdpy_parse_command_name()
* prefixed error messages by MI command name except for
"Problem parsing arguments:" since old C-implemented MI
commands do not prefix command name.
* make do_suppress_notification() to return gdb::optional
* split invoke to invoke and do_invoke, making invoke to perform
common initialization
* add test redefining Python MI command while the very same command
is running
* documented the fact that in mi_command_py::do_invoke() `this` pointer cannot
be used after invoking python code since it may got stale.

Didier Nadeau (3):
Use std::map for MI commands in mi-cmds.c
Use classes to represent MI Command instead of structures
Create MI commands using python.

Jan Vrany (2):
mi/python: Allow redefinition of python MI commands
mi/python: Add tests for python-defined MI commands

gdb/ChangeLog | 88 +++++
gdb/Makefile.in | 1 +
gdb/mi/mi-cmd-info.c | 4 +-
gdb/mi/mi-cmds.c | 501 +++++++++++++------------
gdb/mi/mi-cmds.h | 87 +++--
gdb/mi/mi-main.c | 18 +-
gdb/mi/mi-main.h | 1 +
gdb/mi/mi-parse.c | 20 +-
gdb/mi/mi-parse.h | 6 +-
gdb/python/py-micmd.c | 308 +++++++++++++++
gdb/python/py-micmd.h | 52 +++
gdb/python/python-internal.h | 2 +
gdb/python/python.c | 13 +-
gdb/testsuite/ChangeLog | 5 +
gdb/testsuite/gdb.python/py-mi-cmd.exp | 109 ++++++
gdb/testsuite/gdb.python/py-mi-cmd.py | 39 ++
16 files changed, 959 insertions(+), 295 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.20.1