2021-12-13 18:25:23 +00:00
|
|
|
//go:build darwin && macnative
|
2018-10-01 08:19:06 +00:00
|
|
|
|
2017-04-21 06:55:53 +00:00
|
|
|
package native
|
2015-01-14 02:37:10 +00:00
|
|
|
|
2015-10-06 17:45:36 +00:00
|
|
|
import sys "golang.org/x/sys/unix"
|
2015-01-14 02:37:10 +00:00
|
|
|
|
2020-03-26 12:05:09 +00:00
|
|
|
// ptraceAttach executes the sys.PtraceAttach call.
|
|
|
|
func ptraceAttach(pid int) error {
|
2016-01-15 05:26:54 +00:00
|
|
|
return sys.PtraceAttach(pid)
|
|
|
|
}
|
|
|
|
|
2020-03-26 12:05:09 +00:00
|
|
|
// ptraceDetach executes the PT_DETACH ptrace call.
|
|
|
|
func ptraceDetach(tid, sig int) error {
|
2015-10-06 17:45:36 +00:00
|
|
|
return ptrace(sys.PT_DETACH, tid, 1, uintptr(sig))
|
2015-05-01 20:50:29 +00:00
|
|
|
}
|
|
|
|
|
2020-03-26 12:05:09 +00:00
|
|
|
// ptraceCont executes the PTRACE_CONT ptrace call.
|
|
|
|
func ptraceCont(tid, sig int) error {
|
2015-10-06 17:45:36 +00:00
|
|
|
return ptrace(sys.PTRACE_CONT, tid, 1, 0)
|
2015-01-14 02:37:10 +00:00
|
|
|
}
|
|
|
|
|
2020-03-26 12:05:09 +00:00
|
|
|
// ptraceSingleStep returns PT_STEP ptrace call.
|
|
|
|
func ptraceSingleStep(tid int) error {
|
2015-10-06 17:45:36 +00:00
|
|
|
return ptrace(sys.PT_STEP, tid, 1, 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
func ptrace(request, pid int, addr uintptr, data uintptr) (err error) {
|
|
|
|
_, _, err = sys.Syscall6(sys.SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
|
|
|
|
return
|
2015-01-14 02:37:10 +00:00
|
|
|
}
|