github.com/gidoBOSSftw5731/go/src@v0.0.0-20210226122457-d24b0edbf019/runtime/signal_arm.go (about) 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 //go:build dragonfly || freebsd || linux || netbsd || openbsd 6 // +build dragonfly freebsd linux netbsd openbsd 7 8 package runtime 9 10 import "unsafe" 11 12 func dumpregs(c *sigctxt) { 13 print("trap ", hex(c.trap()), "\n") 14 print("error ", hex(c.error()), "\n") 15 print("oldmask ", hex(c.oldmask()), "\n") 16 print("r0 ", hex(c.r0()), "\n") 17 print("r1 ", hex(c.r1()), "\n") 18 print("r2 ", hex(c.r2()), "\n") 19 print("r3 ", hex(c.r3()), "\n") 20 print("r4 ", hex(c.r4()), "\n") 21 print("r5 ", hex(c.r5()), "\n") 22 print("r6 ", hex(c.r6()), "\n") 23 print("r7 ", hex(c.r7()), "\n") 24 print("r8 ", hex(c.r8()), "\n") 25 print("r9 ", hex(c.r9()), "\n") 26 print("r10 ", hex(c.r10()), "\n") 27 print("fp ", hex(c.fp()), "\n") 28 print("ip ", hex(c.ip()), "\n") 29 print("sp ", hex(c.sp()), "\n") 30 print("lr ", hex(c.lr()), "\n") 31 print("pc ", hex(c.pc()), "\n") 32 print("cpsr ", hex(c.cpsr()), "\n") 33 print("fault ", hex(c.fault()), "\n") 34 } 35 36 //go:nosplit 37 //go:nowritebarrierrec 38 func (c *sigctxt) sigpc() uintptr { return uintptr(c.pc()) } 39 40 func (c *sigctxt) sigsp() uintptr { return uintptr(c.sp()) } 41 func (c *sigctxt) siglr() uintptr { return uintptr(c.lr()) } 42 43 // preparePanic sets up the stack to look like a call to sigpanic. 44 func (c *sigctxt) preparePanic(sig uint32, gp *g) { 45 // We arrange lr, and pc to pretend the panicking 46 // function calls sigpanic directly. 47 // Always save LR to stack so that panics in leaf 48 // functions are correctly handled. This smashes 49 // the stack frame but we're not going back there 50 // anyway. 51 sp := c.sp() - 4 52 c.set_sp(sp) 53 *(*uint32)(unsafe.Pointer(uintptr(sp))) = c.lr() 54 55 pc := gp.sigpc 56 57 if shouldPushSigpanic(gp, pc, uintptr(c.lr())) { 58 // Make it look the like faulting PC called sigpanic. 59 c.set_lr(uint32(pc)) 60 } 61 62 // In case we are panicking from external C code 63 c.set_r10(uint32(uintptr(unsafe.Pointer(gp)))) 64 c.set_pc(uint32(funcPC(sigpanic))) 65 } 66 67 func (c *sigctxt) pushCall(targetPC, resumePC uintptr) { 68 // Push the LR to stack, as we'll clobber it in order to 69 // push the call. The function being pushed is responsible 70 // for restoring the LR and setting the SP back. 71 // This extra slot is known to gentraceback. 72 sp := c.sp() - 4 73 c.set_sp(sp) 74 *(*uint32)(unsafe.Pointer(uintptr(sp))) = c.lr() 75 // Set up PC and LR to pretend the function being signaled 76 // calls targetPC at resumePC. 77 c.set_lr(uint32(resumePC)) 78 c.set_pc(uint32(targetPC)) 79 }