Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Problems with hook-stop
@ 2007-09-26 16:06 Carl Shapiro
  2007-09-27 12:06 ` Mark Kettenis
  2007-09-27 12:35 ` Christian Thalinger
  0 siblings, 2 replies; 7+ messages in thread
From: Carl Shapiro @ 2007-09-26 16:06 UTC (permalink / raw)
  To: gdb

Hi,

I am trying to write a user-defined command hook that automatically
passes a SIGTRAP to my program.  Here is the definition I am working
with:

define hook-stop
  if (((* (char *) ($pc - 1)) & 0xff) == 0xcc)
    signal SIGTRAP
  end
end

My target architecture is x86.  This command fires the first time I
hit an "int3" instruction.  The next time I hit an int3, hook-stop is
not executed and I must manually pass a SIGTRAP by evaluating "signal
SIGTRAP".  It seems that every other time gdb is stopped with a
SIGTRAP the stop hook is not executed.  Here's a program that can be
used to demonstrate this:

#include <signal.h>
#include <stdio.h>

void handler(int signum) {
  fprintf(stderr, "handler(signum=%d)\n", signum);
}

int main(int argc, char *argv[]) {
  struct sigaction sa;
  int i;
  sa.sa_handler = handler;
  for (i = 0;; ++i) {
    fprintf(stderr, "i=%d\n", i);
    asm("int3");
  }
  return 0;
}

If I remove the "signal SIGTRAP" statement from hook-stop, it fires
every time around the loop.  Does anyone know where am I going wrong
wrong?

Thanks,

Carl


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-10-02 11:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-26 16:06 Problems with hook-stop Carl Shapiro
2007-09-27 12:06 ` Mark Kettenis
2007-09-28  1:23   ` Carl Shapiro
2007-09-29 21:44     ` Daniel Jacobowitz
2007-10-02  7:57       ` Carl Shapiro
2007-10-02 11:42         ` Daniel Jacobowitz
2007-09-27 12:35 ` Christian Thalinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox