syscall_aix_ppc64.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // syscall_aix_ppc64.go -- AIX 64-bit specific support
  2. // Copyright 2017 The Go Authors. All rights reserved.
  3. // Use of this source code is governed by a BSD-style
  4. // license that can be found in the LICENSE file.
  5. package syscall
  6. import "unsafe"
  7. // AIX does not define a specific structure but instead uses separate
  8. // ptrace calls for the different registers.
  9. type PtraceRegs struct {
  10. Gpr [32]uint64
  11. Iar uint64
  12. Msr uint64
  13. Cr uint64
  14. Lr uint64
  15. Ctr uint64
  16. Xer uint64
  17. }
  18. func (r *PtraceRegs) PC() uint64 { return r.Iar }
  19. func (r *PtraceRegs) SetPC(pc uint64) { r.Iar = pc }
  20. func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) {
  21. ptrace64(_PT_REGSET, int64(pid), int64(uintptr(unsafe.Pointer(&regsout.Gpr[0]))), 0, 0)
  22. ptrace64(_PT_READ_GPR, int64(pid), 128, 0, uintptr(unsafe.Pointer(&regsout.Iar)))
  23. ptrace64(_PT_READ_GPR, int64(pid), 129, 0, uintptr(unsafe.Pointer(&regsout.Msr)))
  24. ptrace64(_PT_READ_GPR, int64(pid), 130, 0, uintptr(unsafe.Pointer(&regsout.Cr)))
  25. ptrace64(_PT_READ_GPR, int64(pid), 131, 0, uintptr(unsafe.Pointer(&regsout.Lr)))
  26. ptrace64(_PT_READ_GPR, int64(pid), 132, 0, uintptr(unsafe.Pointer(&regsout.Ctr)))
  27. ptrace64(_PT_READ_GPR, int64(pid), 133, 0, uintptr(unsafe.Pointer(&regsout.Xer)))
  28. return nil
  29. }
  30. func PtraceSetRegs(pid int, regs *PtraceRegs) (err error) {
  31. for i := 0; i < len(regs.Gpr); i++ {
  32. ptrace64(_PT_WRITE_GPR, int64(pid), int64(i), 0, uintptr(unsafe.Pointer(&regs.Gpr[i])))
  33. }
  34. ptrace64(_PT_WRITE_GPR, int64(pid), 128, 0, uintptr(unsafe.Pointer(&regs.Iar)))
  35. ptrace64(_PT_WRITE_GPR, int64(pid), 129, 0, uintptr(unsafe.Pointer(&regs.Msr)))
  36. ptrace64(_PT_WRITE_GPR, int64(pid), 130, 0, uintptr(unsafe.Pointer(&regs.Cr)))
  37. ptrace64(_PT_WRITE_GPR, int64(pid), 131, 0, uintptr(unsafe.Pointer(&regs.Lr)))
  38. ptrace64(_PT_WRITE_GPR, int64(pid), 132, 0, uintptr(unsafe.Pointer(&regs.Ctr)))
  39. ptrace64(_PT_WRITE_GPR, int64(pid), 133, 0, uintptr(unsafe.Pointer(&regs.Xer)))
  40. return nil
  41. }