blob: 96ca7c65f2435727168c594ebce052895f434a8b [file] [log] [blame]
Matt Fischere4fa46e2010-01-11 10:02:06 +08001#include <signal.h>
2
3extern int __sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
4extern void __sig_restorer();
5
6int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact)
7{
8 struct sigaction real_act;
9
10 /* If the caller has not set a custom restorer, then set up a default one.
11 * The code will function properly without this, however GDB will not be
12 * able to recognize the stack frame as a signal trampoline, because it
13 * is hardcoded to look for the instruction sequence that glibc uses in
14 * its custom restorer. By creating our own restorer with the same
15 * sequence, we ensure that GDB correctly identifies this as a signal
16 * trampoline frame.
17 *
18 * See http://sourceware.org/ml/gdb/2010-01/msg00143.html for more
19 * information on this.*/
20 if(act && !(act->sa_flags & SA_RESTORER)) {
21 real_act = *act;
22 real_act.sa_flags |= SA_RESTORER;
23 real_act.sa_restorer = __sig_restorer;
24
25 act = &real_act;
26 }
27
28 return __sigaction(signum, act, oldact);
29}