~john-koepi/ubuntu/trusty/golang/default

« back to all changes in this revision

Viewing changes to src/pkg/runtime/windows/386/signal.c

  • Committer: Bazaar Package Importer
  • Author(s): Ondřej Surý
  • Date: 2011-04-20 17:36:48 UTC
  • Revision ID: james.westby@ubuntu.com-20110420173648-ifergoxyrm832trd
Tags: upstream-2011.03.07.1
Import upstream version 2011.03.07.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.h"
 
7
#include "os.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
void
 
28
runtime·initsig(int32)
 
29
{
 
30
        runtime·siginit();
 
31
}
 
32
 
 
33
uint32
 
34
runtime·sighandler(ExceptionRecord *info, void *frame, Context *r)
 
35
{
 
36
        uintptr *sp;
 
37
        G *gp;
 
38
 
 
39
        USED(frame);
 
40
 
 
41
        switch(info->ExceptionCode) {
 
42
        case EXCEPTION_BREAKPOINT:
 
43
                r->Eip--;       // because 8l generates 2 bytes for INT3
 
44
                return 1;
 
45
        }
 
46
 
 
47
        if((gp = m->curg) != nil && runtime·issigpanic(info->ExceptionCode)) {
 
48
                // Make it look like a call to the signal func.
 
49
                // Have to pass arguments out of band since
 
50
                // augmenting the stack frame would break
 
51
                // the unwinding code.
 
52
                gp->sig = info->ExceptionCode;
 
53
                gp->sigcode0 = info->ExceptionInformation[0];
 
54
                gp->sigcode1 = info->ExceptionInformation[1];
 
55
                gp->sigpc = r->Eip;
 
56
 
 
57
                // Only push runtime·sigpanic if r->eip != 0.
 
58
                // If r->eip == 0, probably panicked because of a
 
59
                // call to a nil func.  Not pushing that onto sp will
 
60
                // make the trace look like a call to runtime·sigpanic instead.
 
61
                // (Otherwise the trace will end at runtime·sigpanic and we
 
62
                // won't get to see who faulted.)
 
63
                if(r->Eip != 0) {
 
64
                        sp = (uintptr*)r->Esp;
 
65
                        *--sp = r->Eip;
 
66
                        r->Esp = (uintptr)sp;
 
67
                }
 
68
                r->Eip = (uintptr)runtime·sigpanic;
 
69
                return 0;
 
70
        }
 
71
 
 
72
        if(runtime·panicking)   // traceback already printed
 
73
                runtime·exit(2);
 
74
        runtime·panicking = 1;
 
75
 
 
76
        runtime·printf("Exception %x %p %p\n", info->ExceptionCode,
 
77
                info->ExceptionInformation[0], info->ExceptionInformation[1]);
 
78
 
 
79
        runtime·printf("PC=%x\n", r->Eip);
 
80
        runtime·printf("\n");
 
81
 
 
82
        if(runtime·gotraceback()){
 
83
                runtime·traceback((void*)r->Eip, (void*)r->Esp, 0, m->curg);
 
84
                runtime·tracebackothers(m->curg);
 
85
                runtime·dumpregs(r);
 
86
        }
 
87
 
 
88
        runtime·exit(2);
 
89
        return 0;
 
90
}