github.com/x04/go/src@v0.0.0-20200202162449-3d481ceb3525/runtime/signal_riscv64.go (about)

     1  // Copyright 2016 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  // +build linux,riscv64
     6  
     7  package runtime
     8  
     9  import (
    10  	"github.com/x04/go/src/runtime/internal/sys"
    11  	"github.com/x04/go/src/unsafe"
    12  )
    13  
    14  func dumpregs(c *sigctxt) {
    15  	print("ra  ", hex(c.ra()), "\t")
    16  	print("sp  ", hex(c.sp()), "\n")
    17  	print("gp  ", hex(c.gp()), "\t")
    18  	print("tp  ", hex(c.tp()), "\n")
    19  	print("t0  ", hex(c.t0()), "\t")
    20  	print("t1  ", hex(c.t1()), "\n")
    21  	print("t2  ", hex(c.t2()), "\t")
    22  	print("s0  ", hex(c.s0()), "\n")
    23  	print("s1  ", hex(c.s1()), "\t")
    24  	print("a0  ", hex(c.a0()), "\n")
    25  	print("a1  ", hex(c.a1()), "\t")
    26  	print("a2  ", hex(c.a2()), "\n")
    27  	print("a3  ", hex(c.a3()), "\t")
    28  	print("a4  ", hex(c.a4()), "\n")
    29  	print("a5  ", hex(c.a5()), "\t")
    30  	print("a6  ", hex(c.a6()), "\n")
    31  	print("a7  ", hex(c.a7()), "\t")
    32  	print("s2  ", hex(c.s2()), "\n")
    33  	print("s3  ", hex(c.s3()), "\t")
    34  	print("s4  ", hex(c.s4()), "\n")
    35  	print("s5  ", hex(c.s5()), "\t")
    36  	print("s6  ", hex(c.s6()), "\n")
    37  	print("s7  ", hex(c.s7()), "\t")
    38  	print("s8  ", hex(c.s8()), "\n")
    39  	print("s9  ", hex(c.s9()), "\t")
    40  	print("s10 ", hex(c.s10()), "\n")
    41  	print("s11 ", hex(c.s11()), "\t")
    42  	print("t3  ", hex(c.t3()), "\n")
    43  	print("t4  ", hex(c.t4()), "\t")
    44  	print("t5  ", hex(c.t5()), "\n")
    45  	print("t6  ", hex(c.t6()), "\t")
    46  	print("pc  ", hex(c.pc()), "\n")
    47  }
    48  
    49  //go:nosplit
    50  //go:nowritebarrierrec
    51  func (c *sigctxt) sigpc() uintptr	{ return uintptr(c.pc()) }
    52  
    53  func (c *sigctxt) sigsp() uintptr	{ return uintptr(c.sp()) }
    54  func (c *sigctxt) siglr() uintptr	{ return uintptr(c.ra()) }
    55  func (c *sigctxt) fault() uintptr	{ return uintptr(c.sigaddr()) }
    56  
    57  // preparePanic sets up the stack to look like a call to sigpanic.
    58  func (c *sigctxt) preparePanic(sig uint32, gp *g) {
    59  	// We arrange RA, and pc to pretend the panicking
    60  	// function calls sigpanic directly.
    61  	// Always save RA to stack so that panics in leaf
    62  	// functions are correctly handled. This smashes
    63  	// the stack frame but we're not going back there
    64  	// anyway.
    65  	sp := c.sp() - sys.PtrSize
    66  	c.set_sp(sp)
    67  	*(*uint64)(unsafe.Pointer(uintptr(sp))) = c.ra()
    68  
    69  	pc := gp.sigpc
    70  
    71  	if shouldPushSigpanic(gp, pc, uintptr(c.ra())) {
    72  		// Make it look the like faulting PC called sigpanic.
    73  		c.set_ra(uint64(pc))
    74  	}
    75  
    76  	// In case we are panicking from external C code
    77  	c.set_gp(uint64(uintptr(unsafe.Pointer(gp))))
    78  	c.set_pc(uint64(funcPC(sigpanic)))
    79  }
    80  
    81  const pushCallSupported = false
    82  
    83  func (c *sigctxt) pushCall(targetPC uintptr) {
    84  	throw("unimplemented")
    85  }