github.com/ice-blockchain/go/src@v0.0.0-20240403114104-1564d284e521/runtime/signal_386.go (about) 1 // Copyright 2013 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 //go:build dragonfly || freebsd || linux || netbsd || openbsd 6 7 package runtime 8 9 import ( 10 "internal/abi" 11 "internal/goarch" 12 "unsafe" 13 ) 14 15 func dumpregs(c *sigctxt) { 16 print("eax ", hex(c.eax()), "\n") 17 print("ebx ", hex(c.ebx()), "\n") 18 print("ecx ", hex(c.ecx()), "\n") 19 print("edx ", hex(c.edx()), "\n") 20 print("edi ", hex(c.edi()), "\n") 21 print("esi ", hex(c.esi()), "\n") 22 print("ebp ", hex(c.ebp()), "\n") 23 print("esp ", hex(c.esp()), "\n") 24 print("eip ", hex(c.eip()), "\n") 25 print("eflags ", hex(c.eflags()), "\n") 26 print("cs ", hex(c.cs()), "\n") 27 print("fs ", hex(c.fs()), "\n") 28 print("gs ", hex(c.gs()), "\n") 29 } 30 31 //go:nosplit 32 //go:nowritebarrierrec 33 func (c *sigctxt) sigpc() uintptr { return uintptr(c.eip()) } 34 35 func (c *sigctxt) sigsp() uintptr { return uintptr(c.esp()) } 36 func (c *sigctxt) siglr() uintptr { return 0 } 37 func (c *sigctxt) fault() uintptr { return uintptr(c.sigaddr()) } 38 39 // preparePanic sets up the stack to look like a call to sigpanic. 40 func (c *sigctxt) preparePanic(sig uint32, gp *g) { 41 pc := uintptr(c.eip()) 42 sp := uintptr(c.esp()) 43 44 if shouldPushSigpanic(gp, pc, *(*uintptr)(unsafe.Pointer(sp))) { 45 c.pushCall(abi.FuncPCABIInternal(sigpanic), pc) 46 } else { 47 // Not safe to push the call. Just clobber the frame. 48 c.set_eip(uint32(abi.FuncPCABIInternal(sigpanic))) 49 } 50 } 51 52 func (c *sigctxt) pushCall(targetPC, resumePC uintptr) { 53 // Make it look like we called target at resumePC. 54 sp := uintptr(c.esp()) 55 sp -= goarch.PtrSize 56 *(*uintptr)(unsafe.Pointer(sp)) = resumePC 57 c.set_esp(uint32(sp)) 58 c.set_eip(uint32(targetPC)) 59 }