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]

Re: Problems with hook-stop


On 9/27/07, Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
> Since SIGTRAP has a very special meaning for debugging, it's probably
> unwise to play games like this.

The problem I am having is not specific to SIGTRAP.  You can replace
the interrupt instruction with a kill(2), providing any signal you'd
like as an argument.  The stop hook will fails execute every other
time.

Here's the hook-stop definition to use:

define hook-stop
  signal SIGUSR1
end

Here's the program to run under GDB:

#include <signal.h>
#include <stdio.h>
#include <unistd.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;
 sigaction(SIGUSR1, &sa, NULL);
 for (i = 0;; ++i) {
   fprintf(stderr, "i=%d\n", i);
   kill(getpid(), SIGUSR1);
 }
 return 0;
}


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