[RFC 8/8] mi/python: Allow redefinition of python MI commands
Jan Vrany
jan.vrany@fit.cvut.cz
Fri May 3 15:26:00 GMT 2019
On Thu, 2019-04-25 at 13:50 -0600, Tom Tromey wrote:
> > > > > > "Jan" == Jan Vrany <jan.vrany@fit.cvut.cz> writes:
>
> Jan> Redefining python MI commands is especially useful when developing
> Jan> then.
>
> It seems like this could lead to difficulties with dangling pointers.
> Some assurance on this would be good.
I'm not sure what exactly do you mean. However, I changed mi_command_py to
use gdbpy_ref<> instead of PyObject* (or even void*).
Therefore when one redefines the command:
+ if (mi_cmd_table.find (name) != mi_cmd_table.end ())
+ if (! mi_cmd_table[name]->can_be_redefined ())
+ return false;
+
+ mi_cmd_table[name] = std::move (command);
then the old command (if any) is destructed so Py_DECREF() is called on
Python objech held on by mi_command_py() instance.
I double checked by tracing it in GDB - I don't know how to write
the test for for this though.
Does above address your concern?
Thanks!
Jan
>
> Tom
More information about the Gdb-patches
mailing list