Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: "Amker.Cheng" <amker.cheng@gmail.com>
To: gdb@sourceware.org
Cc: hellogcc@freelists.org
Subject: behavior of hook-stop command
Date: Tue, 02 Aug 2011 02:44:00 -0000	[thread overview]
Message-ID: <CAHFci296i+6EGPL45Gx0LYtQ7F-eg0QCR+cQeVaAo7k6Z_uFsQ@mail.gmail.com> (raw)

Hi,
In gdb document, it is said hook-stop makes the associated commands
execute every time execution stops in your program.

while for cases where continue command included in hook-stop, it's not true.
for example:
define hook-stop
  p /x $pc
  continue
end

User defined hook-stop command is executed by codes:

void execute_cmd_pre_hook (struct cmd_list_element *c)
{
  if ((c->hook_pre) && (!c->hook_in))
    {
      struct cleanup *cleanups = make_cleanup (clear_hook_in_cleanup, c);
      c->hook_in = 1; /* Prevent recursive hooking.  */
      execute_user_command (c->hook_pre, (char *) 0);
      do_cleanups (cleanups);
    }
}
Since hook_in is set to 1, the (!c->hook_in) is false next time
breakpoint is hit, resulting in
hook-stop will be executed at the first breakpoint.

I understand hook_in is essential to prevent gdb from possible
recursion and seems hard
to change the behavior within current infrastructure.
Is this a bug? Should we state this in GDB document?

Any suggestion? Thanks.
-- 
Best Regards.


             reply	other threads:[~2011-08-02  2:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-02  2:44 Amker.Cheng [this message]
2011-08-02 22:58 ` Sergio Durigan Junior
2011-08-03  6:58   ` Amker.Cheng

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=CAHFci296i+6EGPL45Gx0LYtQ7F-eg0QCR+cQeVaAo7k6Z_uFsQ@mail.gmail.com \
    --to=amker.cheng@gmail.com \
    --cc=gdb@sourceware.org \
    --cc=hellogcc@freelists.org \
    /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