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