Skip to content

Commit

Permalink
unix: implement Ptrace{Set,Get}Regs using PTRACE_{GET,SET}REGSET for …
Browse files Browse the repository at this point in the history
…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]>
  • Loading branch information
abner-chenc authored and gopherbot committed Jun 9, 2023
1 parent 304f187 commit 5059a07
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions unix/syscall_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
package unix

import (
"debug/elf"
"encoding/binary"
"strconv"
"syscall"
Expand Down Expand Up @@ -1700,11 +1701,17 @@ func PtracePokeUser(pid int, addr uintptr, data []byte) (count int, err error) {
}

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) {
Expand Down

0 comments on commit 5059a07

Please sign in to comment.