Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(36)

Side by Side Diff: src/pkg/runtime/freebsd/386/signal.c

Issue 157055: code review 157055: FreeBSD/i386 work (Closed)
Patch Set: code review 157055: FreeBSD/i386 work Created 15 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #include "runtime.h"
2 #include "defs.h"
3 #include "signals.h"
4 #include "os.h"
5
6 extern void sigtramp(void);
7
8 typedef struct sigaction {
9 union {
10 void (*__sa_handler)(int32);
11 void (*__sa_sigaction)(int32, Siginfo*, void *);
12 } __sigaction_u; /* signal handler */
13 int32 sa_flags; /* see signal options below */
14 int64 sa_mask; /* signal mask to apply */
15 } Sigaction;
16
17 void
18 dumpregs(Sigcontext *r)
19 {
20 printf("eax %X\n", r->sc_eax);
rsc 2009/11/18 07:51:31 These should all be %x not %X. I fixed this bug re
21 printf("ebx %X\n", r->sc_ebx);
22 printf("ecx %X\n", r->sc_ecx);
23 printf("edx %X\n", r->sc_edx);
24 printf("edi %X\n", r->sc_edi);
25 printf("esi %X\n", r->sc_esi);
26 printf("ebp %X\n", r->sc_ebp);
27 printf("esp %X\n", r->sc_esp);
28 printf("eip %X\n", r->sc_eip);
29 printf("eflags %X\n", r->sc_efl);
30 printf("cs %X\n", r->sc_cs);
31 printf("fs %X\n", r->sc_fsbase);
32 printf("gs %X\n", r->sc_gsbase);
33 }
34
35 void
36 sighandler(int32 sig, Siginfo* info, void* context)
37 {
38 Ucontext *uc;
39 Mcontext *mc;
40 Sigcontext *sc;
41
42 if(panicking) // traceback already printed
43 exit(2);
44 panicking = 1;
45
46 uc = context;
47 mc = &uc->uc_mcontext;
48 sc = (Sigcontext*)mc; // same layout, more conveient names
49
50 if(sig < 0 || sig >= NSIG)
51 printf("Signal %d\n", sig);
52 else
53 printf("%s\n", sigtab[sig].name);
54
55 printf("Faulting address: %p\n", info->si_addr);
56 printf("PC=%X\n", sc->sc_eip);
57 printf("\n");
58
59 if(gotraceback()){
60 traceback((void*)sc->sc_eip, (void*)sc->sc_esp, m->curg);
61 tracebackothers(m->curg);
62 dumpregs(sc);
63 }
64
65 breakpoint();
66 exit(2);
67 }
68
69 void
70 sigignore(void)
71 {
72 }
73
74 void
75 signalstack(byte *p, int32 n)
76 {
77 Sigaltstack st;
78
79 st.ss_sp = (int8*)p;
80 st.ss_size = n;
81 st.ss_flags = 0;
82 sigaltstack(&st, nil);
83 }
84
85 void
86 initsig(void)
87 {
88 static Sigaction sa;
89
90 int32 i;
91 sa.sa_flags |= SA_ONSTACK | SA_SIGINFO;
92 sa.sa_mask = ~0x0ull;
93 ········
94 for(i = 0; i < NSIG; i++) {
95 if(sigtab[i].flags) {
96 if(sigtab[i].flags & SigCatch)
97 sa.__sigaction_u.__sa_handler = (void*) sigtramp ;
98 else
99 sa.__sigaction_u.__sa_handler = (void*) sigignor e;
100
101 if(sigtab[i].flags & SigRestart)
102 sa.sa_flags |= SA_RESTART;
103 else
104 sa.sa_flags &= ~SA_RESTART;
105
106 sigaction(i, &sa, nil);
107 }
108 }
109 }
OLDNEW

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b