public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Doug Evans <xdje42@gmail.com>
To: nojhan <nojhan@nojhan.net>
Cc: gdb <gdb@sourceware.org>
Subject: Re: Define python hooks
Date: Mon, 27 Oct 2014 23:22:00 -0000	[thread overview]
Message-ID: <CAP9bCMSduJBd4er4ZzGYtp8fv6XGuO1KKobkZ-zYJ7p=DoZATQ@mail.gmail.com> (raw)
In-Reply-To: <CAJRERJXcawq3mQmWHpodjj10Z_T6-0TKmtCprehDskdCh3R-4g@mail.gmail.com>

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

  reply	other threads:[~2014-10-27 23:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-25  9:08 nojhan
2014-10-25 22:57 ` Doug Evans
2014-10-27  9:17   ` nojhan
2014-10-27 23:22     ` Doug Evans [this message]
2014-10-28 13:18       ` nojhan
2014-10-29 18:39         ` Doug Evans
2014-11-05 16:50           ` nojhan
2014-12-07 19:59             ` Doug Evans

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAP9bCMSduJBd4er4ZzGYtp8fv6XGuO1KKobkZ-zYJ7p=DoZATQ@mail.gmail.com' \
    --to=xdje42@gmail.com \
    --cc=gdb@sourceware.org \
    --cc=nojhan@nojhan.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).