Skip to content

Commit 5059a07

Browse files
abner-chencgopherbot
authored andcommitted
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 <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> Reviewed-by: David Chase <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 304f187 commit 5059a07

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

unix/syscall_linux.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
package unix
1313

1414
import (
15+
"debug/elf"
1516
"encoding/binary"
1617
"strconv"
1718
"syscall"
@@ -1700,11 +1701,17 @@ func PtracePokeUser(pid int, addr uintptr, data []byte) (count int, err error) {
17001701
}
17011702

17021703
func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) {
1703-
return ptracePtr(PTRACE_GETREGS, pid, 0, unsafe.Pointer(regsout))
1704+
var iov Iovec
1705+
iov.Base = (*byte)(unsafe.Pointer(regsout))
1706+
iov.SetLen(int(unsafe.Sizeof(*regsout)))
1707+
return ptracePtr(PTRACE_GETREGSET, pid, uintptr(elf.NT_PRSTATUS), unsafe.Pointer(&iov))
17041708
}
17051709

17061710
func PtraceSetRegs(pid int, regs *PtraceRegs) (err error) {
1707-
return ptracePtr(PTRACE_SETREGS, pid, 0, unsafe.Pointer(regs))
1711+
var iov Iovec
1712+
iov.Base = (*byte)(unsafe.Pointer(regs))
1713+
iov.SetLen(int(unsafe.Sizeof(*regs)))
1714+
return ptracePtr(PTRACE_SETREGSET, pid, uintptr(elf.NT_PRSTATUS), unsafe.Pointer(&iov))
17081715
}
17091716

17101717
func PtraceSetOptions(pid int, options int) (err error) {

0 commit comments

Comments
 (0)