~ubuntu-branches/ubuntu/trusty/golang/trusty

« back to all changes in this revision

Viewing changes to src/pkg/runtime/signal_windows_amd64.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 2011 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("rax     %X\n", r->Rax);
13
 
        runtime·printf("rbx     %X\n", r->Rbx);
14
 
        runtime·printf("rcx     %X\n", r->Rcx);
15
 
        runtime·printf("rdx     %X\n", r->Rdx);
16
 
        runtime·printf("rdi     %X\n", r->Rdi);
17
 
        runtime·printf("rsi     %X\n", r->Rsi);
18
 
        runtime·printf("rbp     %X\n", r->Rbp);
19
 
        runtime·printf("rsp     %X\n", r->Rsp);
20
 
        runtime·printf("r8      %X\n", r->R8 );
21
 
        runtime·printf("r9      %X\n", r->R9 );
22
 
        runtime·printf("r10     %X\n", r->R10);
23
 
        runtime·printf("r11     %X\n", r->R11);
24
 
        runtime·printf("r12     %X\n", r->R12);
25
 
        runtime·printf("r13     %X\n", r->R13);
26
 
        runtime·printf("r14     %X\n", r->R14);
27
 
        runtime·printf("r15     %X\n", r->R15);
28
 
        runtime·printf("rip     %X\n", r->Rip);
29
 
        runtime·printf("rflags  %X\n", r->EFlags);
30
 
        runtime·printf("cs      %X\n", (uint64)r->SegCs);
31
 
        runtime·printf("fs      %X\n", (uint64)r->SegFs);
32
 
        runtime·printf("gs      %X\n", (uint64)r->SegGs);
33
 
}
34
 
 
35
 
uint32
36
 
runtime·sighandler(ExceptionRecord *info, Context *r, G *gp)
37
 
{
38
 
        uintptr *sp;
39
 
 
40
 
        switch(info->ExceptionCode) {
41
 
        case EXCEPTION_BREAKPOINT:
42
 
                return 1;
43
 
        }
44
 
 
45
 
        if(gp != nil && runtime·issigpanic(info->ExceptionCode)) {
46
 
                // Make it look like a call to the signal func.
47
 
                // Have to pass arguments out of band since
48
 
                // augmenting the stack frame would break
49
 
                // the unwinding code.
50
 
                gp->sig = info->ExceptionCode;
51
 
                gp->sigcode0 = info->ExceptionInformation[0];
52
 
                gp->sigcode1 = info->ExceptionInformation[1];
53
 
                gp->sigpc = r->Rip;
54
 
 
55
 
                // Only push runtime·sigpanic if r->rip != 0.
56
 
                // If r->rip == 0, probably panicked because of a
57
 
                // call to a nil func.  Not pushing that onto sp will
58
 
                // make the trace look like a call to runtime·sigpanic instead.
59
 
                // (Otherwise the trace will end at runtime·sigpanic and we
60
 
                // won't get to see who faulted.)
61
 
                if(r->Rip != 0) {
62
 
                        sp = (uintptr*)r->Rsp;
63
 
                        *--sp = r->Rip;
64
 
                        r->Rsp = (uintptr)sp;
65
 
                }
66
 
                r->Rip = (uintptr)runtime·sigpanic;
67
 
                return 0;
68
 
        }
69
 
 
70
 
        if(runtime·panicking)   // traceback already printed
71
 
                runtime·exit(2);
72
 
        runtime·panicking = 1;
73
 
 
74
 
        runtime·printf("Exception %x %p %p\n", info->ExceptionCode,
75
 
                info->ExceptionInformation[0], info->ExceptionInformation[1]);
76
 
 
77
 
        runtime·printf("PC=%X\n", r->Rip);
78
 
        runtime·printf("\n");
79
 
 
80
 
        if(runtime·gotraceback()){
81
 
                runtime·traceback((void*)r->Rip, (void*)r->Rsp, 0, gp);
82
 
                runtime·tracebackothers(gp);
83
 
                runtime·dumpregs(r);
84
 
        }
85
 
 
86
 
        runtime·exit(2);
87
 
        return 0;
88
 
}
89
 
 
90
 
void
91
 
runtime·sigenable(uint32 sig)
92
 
{
93
 
        USED(sig);
94
 
}
95
 
 
96
 
void
97
 
runtime·dosigprof(Context *r, G *gp)
98
 
{
99
 
        runtime·sigprof((uint8*)r->Rip, (uint8*)r->Rsp, nil, gp);
100
 
}