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("r8 %X\n", u->r8); |
| 22 runtime·printf("r9 %X\n", u->r9); |
| 23 runtime·printf("r10 %X\n", u->r10); |
| 24 runtime·printf("r11 %X\n", u->r11); |
| 25 runtime·printf("r12 %X\n", u->r12); |
| 26 runtime·printf("r13 %X\n", u->r13); |
| 27 runtime·printf("r14 %X\n", u->r14); |
| 28 runtime·printf("r15 %X\n", u->r15); |
| 29 runtime·printf("ip %X\n", u->ip); |
| 30 runtime·printf("flags %X\n", u->flags); |
| 31 runtime·printf("cs %X\n", (uint64)u->cs); |
| 32 runtime·printf("fs %X\n", (uint64)u->fs); |
| 33 runtime·printf("gs %X\n", (uint64)u->gs); |
| 34 } |
| 35 |
| 36 int32 |
| 37 runtime·sighandler(void *v, int8 *s, G *gp) |
| 38 { |
| 39 Ureg *ureg; |
| 40 uintptr *sp; |
| 41 SigTab *sig, *nsig; |
| 42 int32 len, i; |
| 43 |
| 44 if(!s) |
| 45 return NCONT; |
| 46 ························ |
| 47 len = runtime·findnull((byte*)s); |
| 48 if(len <= 4 || runtime·mcmp((byte*)s, (byte*)"sys:", 4) != 0) |
| 49 return NDFLT; |
| 50 |
| 51 nsig = nil; |
| 52 sig = runtime·sigtab; |
| 53 for(i=0; i < NSIG; i++) { |
| 54 if(runtime·strstr((byte*)s, (byte*)sig->name)) { |
| 55 nsig = sig; |
| 56 break; |
| 57 } |
| 58 sig++; |
| 59 } |
| 60 |
| 61 if(nsig == nil) |
| 62 return NDFLT; |
| 63 |
| 64 ureg = v; |
| 65 if(nsig->flags & SigPanic) { |
| 66 if(gp == nil || m->notesig == 0) |
| 67 goto Throw; |
| 68 |
| 69 // Save error string from sigtramp's stack, |
| 70 // into gsignal->sigcode0, so we can reliably |
| 71 // access it from the panic routines. |
| 72 if(len > ERRMAX) |
| 73 len = ERRMAX; |
| 74 runtime·memmove((void*)m->notesig, (void*)s, len); |
| 75 |
| 76 gp->sig = i; |
| 77 gp->sigpc = ureg->ip; |
| 78 |
| 79 // Only push runtime·sigpanic if ureg->ip != 0. |
| 80 // If ureg->ip == 0, probably panicked because of a |
| 81 // call to a nil func. Not pushing that onto sp will |
| 82 // make the trace look like a call to runtime·sigpanic instead. |
| 83 // (Otherwise the trace will end at runtime·sigpanic and we |
| 84 // won't get to see who faulted.) |
| 85 if(ureg->ip != 0) { |
| 86 sp = (uintptr*)ureg->sp; |
| 87 *--sp = ureg->ip; |
| 88 ureg->sp = (uint64)sp; |
| 89 } |
| 90 ureg->ip = (uintptr)runtime·sigpanic; |
| 91 return NCONT; |
| 92 } |
| 93 |
| 94 if(!(nsig->flags & SigThrow)) |
| 95 return NDFLT; |
| 96 |
| 97 Throw: |
| 98 runtime·startpanic(); |
| 99 |
| 100 runtime·printf("%s\n", s); |
| 101 runtime·printf("PC=%X\n", ureg->ip); |
| 102 runtime·printf("\n"); |
| 103 |
| 104 if(runtime·gotraceback()) { |
| 105 runtime·traceback((void*)ureg->ip, (void*)ureg->sp, 0, gp); |
| 106 runtime·tracebackothers(gp); |
| 107 runtime·dumpregs(ureg); |
| 108 } |
| 109 runtime·goexitsall(""); |
| 110 runtime·exits(s); |
| 111 |
| 112 return 0; |
| 113 } |
6 | 114 |
7 void | 115 void |
8 runtime·sigenable(uint32 sig) | 116 runtime·sigenable(uint32 sig) |
9 { | 117 { |
10 USED(sig); | 118 USED(sig); |
11 } | 119 } |
12 | 120 |
13 void | 121 void |
14 runtime·resetcpuprofiler(int32 hz) | 122 runtime·resetcpuprofiler(int32 hz) |
15 { | 123 { |
16 // TODO: Enable profiling interrupts. | 124 // TODO: Enable profiling interrupts. |
17 ········ | 125 ········ |
18 m->profilehz = hz; | 126 m->profilehz = hz; |
19 } | 127 } |
OLD | NEW |