This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Define python hooks


gdb.execute (command, to_string=True) will return the output as a python string.

As for what's the best way to go, I'm not sure.

On Mon, Oct 27, 2014 at 2:17 AM, nojhan <nojhan@nojhan.net> wrote:
> Thanks.
> I would want to manipulate the output of several existing commands with python.
>
> Is there a way to get the output of the command in python (something
> like a gdb.execute that would return the output)?
> Or should I use a redirection to a named pipe to communicate with gdb?
> Or maybe it would be a better option to overload existing commands
> with a python class that would execute them?
>
> --
> nojhan
>
> On Sun, Oct 26, 2014 at 12:57 AM, Doug Evans <xdje42@gmail.com> wrote:
>> On Sat, Oct 25, 2014 at 2:08 AM, nojhan <nojhan@nojhan.net> wrote:
>>> Hello,
>>>
>>> I'm currently using several of hook-* and hookpost-* functions with
>>> shell commands.
>>> I was wondering if there was a way to define such hooks in pure python.
>>>
>>> For instance, I would like to import a module at startup and use it
>>> across all the hooks to manipulate the output of the hooked commands.
>>
>> Hi.
>>
>> While one can't directly define hooks in python, one can still invoke
>> python from hooks.
>>
>> E.g.
>>
>> define hookpost-step
>> python
>> ... python code ...
>> end
>> end


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]