Source file src/runtime/defs_windows_arm.go

     1  // Copyright 2018 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  package runtime
     6  
     7  // NOTE(rsc): _CONTEXT_CONTROL is actually 0x200001 and should include PC, SP, and LR.
     8  // However, empirically, LR doesn't come along on Windows 10
     9  // unless you also set _CONTEXT_INTEGER (0x200002).
    10  // Without LR, we skip over the next-to-bottom function in profiles
    11  // when the bottom function is frameless.
    12  // So we set both here, to make a working _CONTEXT_CONTROL.
    13  const _CONTEXT_CONTROL = 0x200003
    14  
    15  type neon128 struct {
    16  	low  uint64
    17  	high int64
    18  }
    19  
    20  type context struct {
    21  	contextflags uint32
    22  	r0           uint32
    23  	r1           uint32
    24  	r2           uint32
    25  	r3           uint32
    26  	r4           uint32
    27  	r5           uint32
    28  	r6           uint32
    29  	r7           uint32
    30  	r8           uint32
    31  	r9           uint32
    32  	r10          uint32
    33  	r11          uint32
    34  	r12          uint32
    35  
    36  	spr  uint32
    37  	lrr  uint32
    38  	pc   uint32
    39  	cpsr uint32
    40  
    41  	fpscr   uint32
    42  	padding uint32
    43  
    44  	floatNeon [16]neon128
    45  
    46  	bvr      [8]uint32
    47  	bcr      [8]uint32
    48  	wvr      [1]uint32
    49  	wcr      [1]uint32
    50  	padding2 [2]uint32
    51  }
    52  
    53  func (c *context) ip() uintptr { return uintptr(c.pc) }
    54  func (c *context) sp() uintptr { return uintptr(c.spr) }
    55  func (c *context) lr() uintptr { return uintptr(c.lrr) }
    56  
    57  func (c *context) set_ip(x uintptr) { c.pc = uint32(x) }
    58  func (c *context) set_sp(x uintptr) { c.spr = uint32(x) }
    59  func (c *context) set_lr(x uintptr) { c.lrr = uint32(x) }
    60  
    61  // arm does not have frame pointer register.
    62  func (c *context) set_fp(x uintptr) {}
    63  
    64  func prepareContextForSigResume(c *context) {
    65  	c.r0 = c.spr
    66  	c.r1 = c.pc
    67  }
    68  
    69  func dumpregs(r *context) {
    70  	print("r0   ", hex(r.r0), "\n")
    71  	print("r1   ", hex(r.r1), "\n")
    72  	print("r2   ", hex(r.r2), "\n")
    73  	print("r3   ", hex(r.r3), "\n")
    74  	print("r4   ", hex(r.r4), "\n")
    75  	print("r5   ", hex(r.r5), "\n")
    76  	print("r6   ", hex(r.r6), "\n")
    77  	print("r7   ", hex(r.r7), "\n")
    78  	print("r8   ", hex(r.r8), "\n")
    79  	print("r9   ", hex(r.r9), "\n")
    80  	print("r10  ", hex(r.r10), "\n")
    81  	print("r11  ", hex(r.r11), "\n")
    82  	print("r12  ", hex(r.r12), "\n")
    83  	print("sp   ", hex(r.spr), "\n")
    84  	print("lr   ", hex(r.lrr), "\n")
    85  	print("pc   ", hex(r.pc), "\n")
    86  	print("cpsr ", hex(r.cpsr), "\n")
    87  }
    88  
    89  func stackcheck() {
    90  	// TODO: not implemented on ARM
    91  }
    92  
    93  type _DISPATCHER_CONTEXT struct {
    94  	controlPc        uint32
    95  	imageBase        uint32
    96  	functionEntry    uintptr
    97  	establisherFrame uint32
    98  	targetIp         uint32
    99  	context          *context
   100  	languageHandler  uintptr
   101  	handlerData      uintptr
   102  }
   103  
   104  func (c *_DISPATCHER_CONTEXT) ctx() *context {
   105  	return c.context
   106  }
   107  

View as plain text