]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: make windows exception handler code arch independent
authorAlex Brainman <alex.brainman@gmail.com>
Thu, 9 Apr 2015 05:13:48 +0000 (15:13 +1000)
committerAlex Brainman <alex.brainman@gmail.com>
Thu, 9 Apr 2015 09:55:38 +0000 (09:55 +0000)
Mainly it is simple copy. But I had to change amd64
lastcontinuehandler return value from uint32 to int32.
I don't remember how it happened to be uint32, but new
int32 is matching better with Windows documentation (LONG).
I don't think it matters one way or the others.

Change-Id: I6935224a2470ad6301e27590f2baa86c13bbe8d5
Reviewed-on: https://go-review.googlesource.com/8686
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/runtime/os1_windows_386.go [deleted file]
src/runtime/signal_windows.go [moved from src/runtime/os1_windows_amd64.go with 99% similarity]

diff --git a/src/runtime/os1_windows_386.go b/src/runtime/os1_windows_386.go
deleted file mode 100644 (file)
index f7d5fa7..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package runtime
-
-import (
-       "unsafe"
-)
-
-func isgoexception(info *exceptionrecord, r *context) bool {
-       // Only handle exception if executing instructions in Go binary
-       // (not Windows library code).
-       if r.ip() < themoduledata.text || themoduledata.etext < r.ip() {
-               return false
-       }
-
-       if issigpanic(info.exceptioncode) == 0 {
-               return false
-       }
-
-       return true
-}
-
-// Called by sigtramp from Windows VEH handler.
-// Return value signals whether the exception has been handled (EXCEPTION_CONTINUE_EXECUTION)
-// or should be made available to other handlers in the chain (EXCEPTION_CONTINUE_SEARCH).
-func exceptionhandler(info *exceptionrecord, r *context, gp *g) int32 {
-       if !isgoexception(info, r) {
-               return _EXCEPTION_CONTINUE_SEARCH
-       }
-
-       // Make it look like a call to the signal func.
-       // Have to pass arguments out of band since
-       // augmenting the stack frame would break
-       // the unwinding code.
-       gp.sig = info.exceptioncode
-       gp.sigcode0 = uintptr(info.exceptioninformation[0])
-       gp.sigcode1 = uintptr(info.exceptioninformation[1])
-       gp.sigpc = r.ip()
-
-       // Only push runtime·sigpanic if r.ip() != 0.
-       // If r.ip() == 0, probably panicked because of a
-       // call to a nil func.  Not pushing that onto sp will
-       // make the trace look like a call to runtime·sigpanic instead.
-       // (Otherwise the trace will end at runtime·sigpanic and we
-       // won't get to see who faulted.)
-       if r.ip() != 0 {
-               sp := unsafe.Pointer(r.sp())
-               sp = add(sp, ^uintptr(unsafe.Sizeof(uintptr(0))-1)) // sp--
-               *((*uintptr)(sp)) = r.ip()
-               r.setsp(uintptr(sp))
-       }
-       r.setip(funcPC(sigpanic))
-       return _EXCEPTION_CONTINUE_EXECUTION
-}
-
-var testingWER bool
-
-// lastcontinuehandler is reached, because runtime cannot handle
-// current exception. lastcontinuehandler will print crash info and exit.
-func lastcontinuehandler(info *exceptionrecord, r *context, gp *g) int32 {
-       if testingWER {
-               return _EXCEPTION_CONTINUE_SEARCH
-       }
-
-       _g_ := getg()
-
-       if panicking != 0 { // traceback already printed
-               exit(2)
-       }
-       panicking = 1
-
-       print("Exception ", hex(info.exceptioncode), " ", hex(info.exceptioninformation[0]), " ", hex(info.exceptioninformation[1]), " ", hex(r.ip()), "\n")
-
-       print("PC=", hex(r.ip()), "\n")
-       if _g_.m.lockedg != nil && _g_.m.ncgo > 0 && gp == _g_.m.g0 {
-               print("signal arrived during cgo execution\n")
-               gp = _g_.m.lockedg
-       }
-       print("\n")
-
-       var docrash bool
-       if gotraceback(&docrash) > 0 {
-               tracebacktrap(r.ip(), r.sp(), 0, gp)
-               tracebackothers(gp)
-               dumpregs(r)
-       }
-
-       if docrash {
-               crash()
-       }
-
-       exit(2)
-       return 0 // not reached
-}
-
-func sigenable(sig uint32) {
-}
-
-func sigdisable(sig uint32) {
-}
-
-func sigignore(sig uint32) {
-}
similarity index 99%
rename from src/runtime/os1_windows_amd64.go
rename to src/runtime/signal_windows.go
index a681f0f12b4259e9fc6fea18d4eda9d6d12d615d..ab8fe206c795685db0273864a48c7f3fe78bba31 100644 (file)
@@ -71,7 +71,7 @@ var testingWER bool
 
 // lastcontinuehandler is reached, because runtime cannot handle
 // current exception. lastcontinuehandler will print crash info and exit.
-func lastcontinuehandler(info *exceptionrecord, r *context, gp *g) uint32 {
+func lastcontinuehandler(info *exceptionrecord, r *context, gp *g) int32 {
        if testingWER {
                return _EXCEPTION_CONTINUE_SEARCH
        }