[PATCH 0/5] create GDB/MI commands using python
Simon Marchi
simon.marchi@polymtl.ca
Sun Feb 6 21:16:46 GMT 2022
> 3. The top level result name can be changed from 'result' to anything
> the user wants, here's an example session:
>
> (gdb) python
> >class MyCommand(gdb.MICommand):
> > def __init__(self):
> > super(MyCommand, self).__init__("-my-command", "greeting")
> > def invoke(self, args):
> > return "Hello World"
> >
> >end
> (gdb) python cmd = MyCommand()
> (gdb) interpreter-exec mi "-my-command"
> ^done,greeting="Hello World"
> (gdb)
I find this a bit surprising, why is "greeting" passed to the
constructor? Since an MI result, at the root, is basically a dict,
my intuition would be to only allow the invoke method to return a dict.
def invoke(self, args):
return {'a': 1, 'b': "hello"}
which would result int:
^done,a="1",b="hello"
Returning None (which is returned if there's no explicit "return") would
also be allowed, in which case there is not result:
^done
Simon
More information about the Gdb-patches
mailing list