github.com/varialus/godfly@v0.0.0-20130904042352-1934f9f095ab/src/pkg/runtime/os_windows_386.c (about) 1 // Copyright 2009 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 #include "runtime.h" 6 #include "defs_GOOS_GOARCH.h" 7 #include "os_GOOS.h" 8 9 void 10 runtime·dumpregs(Context *r) 11 { 12 runtime·printf("eax %x\n", r->Eax); 13 runtime·printf("ebx %x\n", r->Ebx); 14 runtime·printf("ecx %x\n", r->Ecx); 15 runtime·printf("edx %x\n", r->Edx); 16 runtime·printf("edi %x\n", r->Edi); 17 runtime·printf("esi %x\n", r->Esi); 18 runtime·printf("ebp %x\n", r->Ebp); 19 runtime·printf("esp %x\n", r->Esp); 20 runtime·printf("eip %x\n", r->Eip); 21 runtime·printf("eflags %x\n", r->EFlags); 22 runtime·printf("cs %x\n", r->SegCs); 23 runtime·printf("fs %x\n", r->SegFs); 24 runtime·printf("gs %x\n", r->SegGs); 25 } 26 27 uint32 28 runtime·sighandler(ExceptionRecord *info, Context *r, G *gp) 29 { 30 bool crash; 31 uintptr *sp; 32 33 switch(info->ExceptionCode) { 34 case EXCEPTION_BREAKPOINT: 35 r->Eip--; // because 8l generates 2 bytes for INT3 36 return 1; 37 } 38 39 if(gp != nil && runtime·issigpanic(info->ExceptionCode)) { 40 // Make it look like a call to the signal func. 41 // Have to pass arguments out of band since 42 // augmenting the stack frame would break 43 // the unwinding code. 44 gp->sig = info->ExceptionCode; 45 gp->sigcode0 = info->ExceptionInformation[0]; 46 gp->sigcode1 = info->ExceptionInformation[1]; 47 gp->sigpc = r->Eip; 48 49 // Only push runtime·sigpanic if r->eip != 0. 50 // If r->eip == 0, probably panicked because of a 51 // call to a nil func. Not pushing that onto sp will 52 // make the trace look like a call to runtime·sigpanic instead. 53 // (Otherwise the trace will end at runtime·sigpanic and we 54 // won't get to see who faulted.) 55 if(r->Eip != 0) { 56 sp = (uintptr*)r->Esp; 57 *--sp = r->Eip; 58 r->Esp = (uintptr)sp; 59 } 60 r->Eip = (uintptr)runtime·sigpanic; 61 return 0; 62 } 63 64 if(runtime·panicking) // traceback already printed 65 runtime·exit(2); 66 runtime·panicking = 1; 67 68 runtime·printf("Exception %x %p %p\n", info->ExceptionCode, 69 info->ExceptionInformation[0], info->ExceptionInformation[1]); 70 71 runtime·printf("PC=%x\n", r->Eip); 72 if(m->lockedg != nil && m->ncgo > 0 && gp == m->g0) { 73 runtime·printf("signal arrived during cgo execution\n"); 74 gp = m->lockedg; 75 } 76 runtime·printf("\n"); 77 78 if(runtime·gotraceback(&crash)){ 79 runtime·traceback(r->Eip, r->Esp, 0, gp); 80 runtime·tracebackothers(gp); 81 runtime·dumpregs(r); 82 } 83 84 if(crash) 85 runtime·crash(); 86 87 88 runtime·exit(2); 89 return 0; 90 } 91 92 void 93 runtime·sigenable(uint32 sig) 94 { 95 USED(sig); 96 } 97 98 void 99 runtime·sigdisable(uint32 sig) 100 { 101 USED(sig); 102 } 103 104 void 105 runtime·dosigprof(Context *r, G *gp) 106 { 107 runtime·sigprof((uint8*)r->Eip, (uint8*)r->Esp, nil, gp); 108 }