gitlab.com/Raven-IO/raven-delve@v1.22.4/pkg/proc/native/threads_linux_ppc64le.go (about) 1 package native 2 3 import ( 4 "debug/elf" 5 "fmt" 6 "syscall" 7 "unsafe" 8 9 sys "golang.org/x/sys/unix" 10 11 "gitlab.com/Raven-IO/raven-delve/pkg/proc" 12 "gitlab.com/Raven-IO/raven-delve/pkg/proc/linutil" 13 ) 14 15 func (t *nativeThread) fpRegisters() ([]proc.Register, []byte, error) { 16 var regs []proc.Register 17 var fpregs linutil.PPC64LEPtraceFpRegs 18 var err error 19 20 t.dbp.execPtraceFunc(func() { fpregs.Fp, err = ptraceGetFpRegset(t.ID) }) 21 regs = fpregs.Decode() 22 if err != nil { 23 err = fmt.Errorf("could not get floating point registers: %v", err.Error()) 24 } 25 return regs, fpregs.Fp, err 26 } 27 28 func (t *nativeThread) restoreRegisters(savedRegs proc.Registers) error { 29 sr := savedRegs.(*linutil.PPC64LERegisters) 30 31 var restoreRegistersErr error 32 t.dbp.execPtraceFunc(func() { 33 restoreRegistersErr = ptraceSetGRegs(t.ID, sr.Regs) 34 if restoreRegistersErr != syscall.Errno(0) && restoreRegistersErr != nil { 35 return 36 } 37 if sr.Fpregset != nil { 38 iov := sys.Iovec{Base: &sr.Fpregset[0], Len: _PPC64LE_FPREGS_SIZE} 39 _, _, restoreRegistersErr = syscall.Syscall6(syscall.SYS_PTRACE, sys.PTRACE_SETREGSET, uintptr(t.ID), uintptr(elf.NT_FPREGSET), uintptr(unsafe.Pointer(&iov)), 0, 0) 40 } 41 }) 42 if restoreRegistersErr == syscall.Errno(0) { 43 restoreRegistersErr = nil 44 } 45 return restoreRegistersErr 46 }