Mirror of the gdb mailing list
 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: Wed, 29 Oct 2014 18:39:00 -0000	[thread overview]
Message-ID: <CAP9bCMSkoqp+R4wVwiq892spC5J=7-Zau4V1fo-ts+zPORLJ1w@mail.gmail.com> (raw)
In-Reply-To: <CAJRERJX7PabS0hZ5rhk1p3uftFZHFXudKy9LyawoNzthsBSU2A@mail.gmail.com>

On Tue, Oct 28, 2014 at 6:17 AM, nojhan <nojhan@nojhan.net> wrote:
> The documentation states that "It is valid for a hook to call the
> command which it hooks. If this occurs, the hook is not re-executed,
> thereby avoiding infinite recursion."
> But this does not seems to be true for the python API.
>
> Here what I tried:
> 1) Defining the hook as a python function that would gdb.execute the
> same command. Failed, because then the command is executed twice.

You mean the hook is executed twice, right?
The docs say the hook won't be executed twice, but executing the
command twice is ok.

I tried a trivial example and couldn't reproduce symptoms of the hook
being executed twice.
This is with current sources and 7.8 (release and branch).

(gdb) define foo
echo Hi there.\n
end
(gdb) define hookpost-foo
echo Me again.\n
python gdb.execute("foo")
end
(gdb) foo
Hi there.
Me again.
Hi there.
(gdb)

> Additionally, I did not find how to access the arguments of the
> command.

I'm not sure what you mean here.
Access the arguments of the command from the hook?
I don't think we support that.

> 2) Overload the existing command with a python class binded on the
> same command name. Failed because of infinite recursion.

Infinite recursion because command -> hook -> command -> hook -> ...
or something else?
Just trying to understand if and how this is different from (1).

If it's easy, providing an example so that we can see it for ourselves
will help.

> 3) Use a named pipe to communicate. Failed (sort of) because one
> should sleep a variable amount of time waiting for the pipe to be
> consumed before returning to the prompt.

I don't understand how this relates to (1) and (2).
Communicate what between whom?


  reply	other threads:[~2014-10-29 18:39 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
2014-10-28 13:18       ` nojhan
2014-10-29 18:39         ` Doug Evans [this message]
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='CAP9bCMSkoqp+R4wVwiq892spC5J=7-Zau4V1fo-ts+zPORLJ1w@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