unix: implement Ptrace{Set,Get}Regs using PTRACE_{GET,SET}REGSET for Linux
The same change was already done in CL 501756.
Fixes #60679.
Change-Id: I5d1f4ad89cabb0ac120b3d72876944fb3283ec6f
Reviewed-on: https://go-review.googlesource.com/c/sys/+/501795
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
diff --git a/unix/syscall_linux.go b/unix/syscall_linux.go
index aa0c551..ec24fae 100644
--- a/unix/syscall_linux.go
+++ b/unix/syscall_linux.go
@@ -12,6 +12,7 @@
package unix
import (
+ "debug/elf"
"encoding/binary"
"strconv"
"syscall"
@@ -1700,11 +1701,17 @@
}
func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) {
- return ptracePtr(PTRACE_GETREGS, pid, 0, unsafe.Pointer(regsout))
+ var iov Iovec
+ iov.Base = (*byte)(unsafe.Pointer(regsout))
+ iov.SetLen(int(unsafe.Sizeof(*regsout)))
+ return ptracePtr(PTRACE_GETREGSET, pid, uintptr(elf.NT_PRSTATUS), unsafe.Pointer(&iov))
}
func PtraceSetRegs(pid int, regs *PtraceRegs) (err error) {
- return ptracePtr(PTRACE_SETREGS, pid, 0, unsafe.Pointer(regs))
+ var iov Iovec
+ iov.Base = (*byte)(unsafe.Pointer(regs))
+ iov.SetLen(int(unsafe.Sizeof(*regs)))
+ return ptracePtr(PTRACE_SETREGSET, pid, uintptr(elf.NT_PRSTATUS), unsafe.Pointer(&iov))
}
func PtraceSetOptions(pid int, options int) (err error) {