Left: | ||
Right: |
OLD | NEW |
---|---|
1 // Copyright 2010 The Go Authors. All rights reserved. | 1 // Copyright 2010 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file.· | 3 // license that can be found in the LICENSE file.· |
4 | 4 |
5 #include "runtime.h" | 5 #include "runtime.h" |
6 #include "defs_GOOS_GOARCH.h" | |
7 #include "os_GOOS.h" | |
8 #include "signals_GOOS.h" | |
9 | |
10 void | |
11 runtime·dumpregs(Ureg *u) | |
12 { | |
13 runtime·printf("ax %X\n", u->ax); | |
14 runtime·printf("bx %X\n", u->bx); | |
15 runtime·printf("cx %X\n", u->cx); | |
16 runtime·printf("dx %X\n", u->dx); | |
17 runtime·printf("di %X\n", u->di); | |
18 runtime·printf("si %X\n", u->si); | |
19 runtime·printf("bp %X\n", u->bp); | |
20 runtime·printf("sp %X\n", u->sp); | |
21 runtime·printf("pc %X\n", u->pc); | |
22 runtime·printf("flags %X\n", u->flags); | |
23 runtime·printf("cs %X\n", u->cs); | |
24 runtime·printf("fs %X\n", u->fs); | |
25 runtime·printf("gs %X\n", u->gs); | |
26 } | |
27 | |
28 int32 | |
29 runtime·sighandler(void *v, int8 *s, G *gp) | |
30 { | |
31 Ureg *ureg; | |
32 SigTab *sig, *nsig; | |
33 int32 len, i; | |
34 | |
35 if(!s) | |
36 return NCONT; | |
37 ························ | |
38 len = runtime·findnull((byte*)s); | |
39 if(len <= 4 || runtime·mcmp((byte*)s, (byte*)"sys:", 4) != 0) | |
40 return NDFLT; | |
41 | |
42 nsig = nil; | |
43 sig = runtime·sigtab; | |
44 for(i=0; i < NSIG; i++) { | |
45 if(runtime·strstr((byte*)s, (byte*)sig->name)) { | |
46 nsig = sig; | |
47 break; | |
48 } | |
49 sig++; | |
50 } | |
51 | |
52 if(nsig == nil) | |
53 return NDFLT; | |
54 | |
55 ureg = v; | |
56 if(nsig->flags & SigPanic) { | |
57 if(gp == nil || g->sigcode0 == 0) | |
58 goto Throw; | |
59 | |
60 // Save error string from sigtramp's stack, | |
61 // into gsignal->sigcode0, so we can reliably | |
62 // access it from the panic routines. | |
63 if(len > ERRMAX) | |
64 len = ERRMAX; | |
65 runtime·memmove((void*)g->sigcode0, (void*)s, len); | |
66 | |
67 gp->sig = i; | |
68 gp->sigpc = ureg->pc; | |
69 | |
ality
2013/01/20 08:44:46
You need to push the PC onto the stack here
for th
akumar
2013/01/22 01:11:38
Done.
| |
70 ureg->pc = (uintptr)runtime·sigpanic; | |
71 return NCONT; | |
72 } | |
73 | |
74 if(!(nsig->flags & SigThrow)) | |
75 return NDFLT; | |
76 | |
77 Throw: | |
78 runtime·startpanic(); | |
79 | |
80 runtime·printf("%s\n", s); | |
81 runtime·printf("PC=%X\n", ureg->pc); | |
82 runtime·printf("\n"); | |
83 | |
84 if(runtime·gotraceback()) { | |
85 runtime·traceback((void*)ureg->pc, (void*)ureg->sp, 0, gp); | |
86 runtime·tracebackothers(gp); | |
87 runtime·dumpregs(ureg); | |
88 } | |
89 runtime·goexitsall(""); | |
90 runtime·exits(s); | |
91 | |
92 return 0; | |
93 } | |
94 | |
6 | 95 |
7 void | 96 void |
8 runtime·sigenable(uint32 sig) | 97 runtime·sigenable(uint32 sig) |
9 { | 98 { |
10 USED(sig); | 99 USED(sig); |
11 } | 100 } |
12 | 101 |
13 void | 102 void |
14 runtime·resetcpuprofiler(int32 hz) | 103 runtime·resetcpuprofiler(int32 hz) |
15 { | 104 { |
16 // TODO: Enable profiling interrupts. | 105 // TODO: Enable profiling interrupts. |
17 ········ | 106 ········ |
18 m->profilehz = hz; | 107 m->profilehz = hz; |
19 } | 108 } |
OLD | NEW |