~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to src/pkg/runtime/signal_windows_386.c

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-08-20 14:06:23 UTC
  • mfrom: (14.1.23 saucy-proposed)
  • Revision ID: package-import@ubuntu.com-20130820140623-b414jfxi3m0qkmrq
Tags: 2:1.1.2-2ubuntu1
* Merge from Debian unstable (LP: #1211749, #1202027). Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - d/control,control.cross: Update Breaks/Replaces for Ubuntu
    versions to ensure smooth upgrades, regenerate control file.

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