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]

behavior of hook-stop command


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.


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