This sbz-golang-freebsd-ptrace.diff is an *alpha* patch to start ptrace support on FreeBSD amd64 platform. So it exports ptrace API in the syscall package using cgo and regenerate z* files using commands below in src/pkg/syscall directory: % arch=$(sysctl -n hw.machine) mkerrors.sh -m${arch:3}. % mkall.sh -n On my system below: FreeBSD ogoshi.lan 10.0-CURRENT FreeBSD 10.0-CURRENT #4 r251383M: Tue Jun 4 18:17:24 CEST 2013 root@ogoshi.lan:/usr/obj/usr/home/sbz/freebsd/svn/src/sys/GENERIC amd64 Install lang/go: % sudo make -C /usr/ports/lang/golang install clean % fetch ptrace.go it does exactly the same as ptrace.c without PT_GETREGS part. Before: % /usr/local/go/bin/go run ptrace.go # command-line-arguments ./ptrace.go:17: undefined: syscall.PtraceRegs ./ptrace.go:50: undefined: syscall.PtraceRegs ./ptrace.go:57: undefined: syscall.PtraceAttach ./ptrace.go:61: undefined: syscall.PtraceSingleStep ./ptrace.go:64: undefined: syscall.PtraceGetRegs ./ptrace.go:76: undefined: syscall.PtraceDetach Apply patch from upstream: % mkdir ~/tmp % cd ~/tmp && hg clone https://code.google.com/p/go/ % cd go && patch -p1 ./sbz-golang-freebsd-ptrace.diff See patch.log for details. Then rebuild it: % cd src && sh make.bash See build.log for details. After: % ~/tmp/go/bin/go run /tmp/ptrace.go usage: /tmp/go-build929942693/command-line-arguments/_obj/exe/ptrace exit status 1 Trying to attach an already launched pid: % xterm & [1] 46757 % ~/tmp/go/bin/go run /tmp/ptrace.go $! [+] Attaching pid 46757 [+] SingleStep pid 46757 [+] GetRegs pid 46757 R15: 0 R14: 0 R13: 0 R12: 0 R11: 0 R10: 0 R9: 0 R8: 0 RDI: 0 RSP: 0 RSI: 0 RBP: 0 RBX: 0 RCX: 0 RAX: 0 RIP: 0 RFLAGS: 0 TRAPNO: 0 ERR: 0 FS: 0 GS: 0 ES: 0 DS: 0 CS: 0 SS: 0 [+] Detaching pid 46757 Status: WIP - ATTACH [OK] - DETACH [OK] - STEP [OK] - GETREGS [KO] - ...