"Fossies" - the Fresh Open Source Software Archive 
Member "mpr-2.8/config/bti386.c.sig" (18 Oct 2002, 800 Bytes) of package /linux/misc/old/mpr-2.8.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
1 #include <stdio.h>
2 #include <signal.h>
3 #include <setjmp.h>
4
5 #undef ulong
6 #define ulong unsigned long
7
8 static sigjmp_buf jmpbuf;
9
10 extern int mprprint(int, char *, ...);
11
12 #define getfp(ap) (ap-2)
13 #define getpc(fp) (fp[1])
14
15 static void
16 mprsigsegv(int sig)
17 {
18 siglongjmp(jmpbuf, 1);
19 }
20
21 void
22 mprbt(int fd)
23 {
24 ulong pc, *fp = getfp((ulong *)&fd);
25 struct sigaction sa, osa;
26 sigset_t mask, omask;
27
28 sigemptyset(&mask);
29 sigaddset(&mask, SIGSEGV);
30 sigprocmask(SIG_UNBLOCK, &mask, &omask);
31 sa.sa_handler = mprsigsegv;
32 sa.sa_flags = 0;
33 sigemptyset(&sa.sa_mask);
34 sigaction(SIGSEGV, &sa, &osa);
35
36 if (sigsetjmp(jmpbuf, 1))
37 goto done;
38 while (fp && *fp && (pc = getpc(fp))) {
39 mprprint(fd, "%U:", pc-1);
40 fp = (ulong *)*fp;
41 }
42 done:
43 sigaction(SIGSEGV, &osa, 0);
44 sigprocmask(SIG_SETMASK, &omask, 0);
45 }