Black Lives Matter. Support the Equal Justice Initiative.

Source file src/runtime/signal_mips64x.go

Documentation: runtime

     1  // Copyright 2015 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 (linux || openbsd) && (mips64 || mips64le)
     6  // +build linux openbsd
     7  // +build mips64 mips64le
     8  
     9  package runtime
    10  
    11  import (
    12  	"runtime/internal/sys"
    13  	"unsafe"
    14  )
    15  
    16  func dumpregs(c *sigctxt) {
    17  	print("r0   ", hex(c.r0()), "\t")
    18  	print("r1   ", hex(c.r1()), "\n")
    19  	print("r2   ", hex(c.r2()), "\t")
    20  	print("r3   ", hex(c.r3()), "\n")
    21  	print("r4   ", hex(c.r4()), "\t")
    22  	print("r5   ", hex(c.r5()), "\n")
    23  	print("r6   ", hex(c.r6()), "\t")
    24  	print("r7   ", hex(c.r7()), "\n")
    25  	print("r8   ", hex(c.r8()), "\t")
    26  	print("r9   ", hex(c.r9()), "\n")
    27  	print("r10  ", hex(c.r10()), "\t")
    28  	print("r11  ", hex(c.r11()), "\n")
    29  	print("r12  ", hex(c.r12()), "\t")
    30  	print("r13  ", hex(c.r13()), "\n")
    31  	print("r14  ", hex(c.r14()), "\t")
    32  	print("r15  ", hex(c.r15()), "\n")
    33  	print("r16  ", hex(c.r16()), "\t")
    34  	print("r17  ", hex(c.r17()), "\n")
    35  	print("r18  ", hex(c.r18()), "\t")
    36  	print("r19  ", hex(c.r19()), "\n")
    37  	print("r20  ", hex(c.r20()), "\t")
    38  	print("r21  ", hex(c.r21()), "\n")
    39  	print("r22  ", hex(c.r22()), "\t")
    40  	print("r23  ", hex(c.r23()), "\n")
    41  	print("r24  ", hex(c.r24()), "\t")
    42  	print("r25  ", hex(c.r25()), "\n")
    43  	print("r26  ", hex(c.r26()), "\t")
    44  	print("r27  ", hex(c.r27()), "\n")
    45  	print("r28  ", hex(c.r28()), "\t")
    46  	print("r29  ", hex(c.r29()), "\n")
    47  	print("r30  ", hex(c.r30()), "\t")
    48  	print("r31  ", hex(c.r31()), "\n")
    49  	print("pc   ", hex(c.pc()), "\t")
    50  	print("link ", hex(c.link()), "\n")
    51  	print("lo   ", hex(c.lo()), "\t")
    52  	print("hi   ", hex(c.hi()), "\n")
    53  }
    54  
    55  //go:nosplit
    56  //go:nowritebarrierrec
    57  func (c *sigctxt) sigpc() uintptr { return uintptr(c.pc()) }
    58  
    59  func (c *sigctxt) sigsp() uintptr { return uintptr(c.sp()) }
    60  func (c *sigctxt) siglr() uintptr { return uintptr(c.link()) }
    61  func (c *sigctxt) fault() uintptr { return uintptr(c.sigaddr()) }
    62  
    63  // preparePanic sets up the stack to look like a call to sigpanic.
    64  func (c *sigctxt) preparePanic(sig uint32, gp *g) {
    65  	// We arrange link, and pc to pretend the panicking
    66  	// function calls sigpanic directly.
    67  	// Always save LINK to stack so that panics in leaf
    68  	// functions are correctly handled. This smashes
    69  	// the stack frame but we're not going back there
    70  	// anyway.
    71  	sp := c.sp() - sys.PtrSize
    72  	c.set_sp(sp)
    73  	*(*uint64)(unsafe.Pointer(uintptr(sp))) = c.link()
    74  
    75  	pc := gp.sigpc
    76  
    77  	if shouldPushSigpanic(gp, pc, uintptr(c.link())) {
    78  		// Make it look the like faulting PC called sigpanic.
    79  		c.set_link(uint64(pc))
    80  	}
    81  
    82  	// In case we are panicking from external C code
    83  	sigpanicPC := uint64(funcPC(sigpanic))
    84  	c.set_r28(sigpanicPC >> 32 << 32) // RSB register
    85  	c.set_r30(uint64(uintptr(unsafe.Pointer(gp))))
    86  	c.set_pc(sigpanicPC)
    87  }
    88  
    89  func (c *sigctxt) pushCall(targetPC, resumePC uintptr) {
    90  	// Push the LR to stack, as we'll clobber it in order to
    91  	// push the call. The function being pushed is responsible
    92  	// for restoring the LR and setting the SP back.
    93  	// This extra slot is known to gentraceback.
    94  	sp := c.sp() - 8
    95  	c.set_sp(sp)
    96  	*(*uint64)(unsafe.Pointer(uintptr(sp))) = c.link()
    97  	// Set up PC and LR to pretend the function being signaled
    98  	// calls targetPC at resumePC.
    99  	c.set_link(uint64(resumePC))
   100  	c.set_pc(uint64(targetPC))
   101  }
   102  

View as plain text