github.com/undoio/delve@v1.9.0/pkg/proc/native/ptrace_darwin.go (about)

     1  //go:build darwin && macnative
     2  // +build darwin,macnative
     3  
     4  package native
     5  
     6  import sys "golang.org/x/sys/unix"
     7  
     8  // ptraceAttach executes the sys.PtraceAttach call.
     9  func ptraceAttach(pid int) error {
    10  	return sys.PtraceAttach(pid)
    11  }
    12  
    13  // ptraceDetach executes the PT_DETACH ptrace call.
    14  func ptraceDetach(tid, sig int) error {
    15  	return ptrace(sys.PT_DETACH, tid, 1, uintptr(sig))
    16  }
    17  
    18  // ptraceCont executes the PTRACE_CONT ptrace call.
    19  func ptraceCont(tid, sig int) error {
    20  	return ptrace(sys.PTRACE_CONT, tid, 1, 0)
    21  }
    22  
    23  // ptraceSingleStep returns PT_STEP ptrace call.
    24  func ptraceSingleStep(tid int) error {
    25  	return ptrace(sys.PT_STEP, tid, 1, 0)
    26  }
    27  
    28  func ptrace(request, pid int, addr uintptr, data uintptr) (err error) {
    29  	_, _, err = sys.Syscall6(sys.SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
    30  	return
    31  }