unix: correct PtraceIoDesc and define PtraceIoDesc per GOARCH on freebsd

CL 179099 introduced ptrace support for freebsd but it seems the
PtraceIoDesc type was not generated by cgo -godefs through mkall.sh
as it contains an uint member. Regenerate the type and adjust
PtraceIoDesc to deal with the type difference on 32-bit vs. 64-bit.

Change-Id: I1ec9662aa8e1b199ebe557387aa27827f23d9d40
Reviewed-on: https://go-review.googlesource.com/c/sys/+/215242
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
diff --git a/unix/syscall_freebsd.go b/unix/syscall_freebsd.go
index 34918d8..6b2eca4 100644
--- a/unix/syscall_freebsd.go
+++ b/unix/syscall_freebsd.go
@@ -529,12 +529,6 @@
 	return ptrace(PTRACE_GETREGS, pid, uintptr(unsafe.Pointer(regsout)), 0)
 }
 
-func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) {
-	ioDesc := PtraceIoDesc{Op: int32(req), Offs: (*byte)(unsafe.Pointer(addr)), Addr: (*byte)(unsafe.Pointer(&out[0])), Len: uint(countin)}
-	err = ptrace(PTRACE_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0)
-	return int(ioDesc.Len), err
-}
-
 func PtraceLwpEvents(pid int, enable int) (err error) {
 	return ptrace(PTRACE_LWPEVENTS, pid, 0, enable)
 }
diff --git a/unix/syscall_freebsd_386.go b/unix/syscall_freebsd_386.go
index dcc5645..0a5a66f 100644
--- a/unix/syscall_freebsd_386.go
+++ b/unix/syscall_freebsd_386.go
@@ -54,3 +54,9 @@
 }
 
 func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
+
+func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) {
+	ioDesc := PtraceIoDesc{Op: int32(req), Offs: (*byte)(unsafe.Pointer(addr)), Addr: (*byte)(unsafe.Pointer(&out[0])), Len: uint32(countin)}
+	err = ptrace(PTRACE_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0)
+	return int(ioDesc.Len), err
+}
diff --git a/unix/syscall_freebsd_amd64.go b/unix/syscall_freebsd_amd64.go
index 321c3ba..8025b22 100644
--- a/unix/syscall_freebsd_amd64.go
+++ b/unix/syscall_freebsd_amd64.go
@@ -54,3 +54,9 @@
 }
 
 func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
+
+func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) {
+	ioDesc := PtraceIoDesc{Op: int32(req), Offs: (*byte)(unsafe.Pointer(addr)), Addr: (*byte)(unsafe.Pointer(&out[0])), Len: uint64(countin)}
+	err = ptrace(PTRACE_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0)
+	return int(ioDesc.Len), err
+}
diff --git a/unix/syscall_freebsd_arm.go b/unix/syscall_freebsd_arm.go
index 6977008..4ea45bc 100644
--- a/unix/syscall_freebsd_arm.go
+++ b/unix/syscall_freebsd_arm.go
@@ -54,3 +54,9 @@
 }
 
 func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
+
+func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) {
+	ioDesc := PtraceIoDesc{Op: int32(req), Offs: (*byte)(unsafe.Pointer(addr)), Addr: (*byte)(unsafe.Pointer(&out[0])), Len: uint32(countin)}
+	err = ptrace(PTRACE_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0)
+	return int(ioDesc.Len), err
+}
diff --git a/unix/syscall_freebsd_arm64.go b/unix/syscall_freebsd_arm64.go
index dbbbfd6..aa5326d 100644
--- a/unix/syscall_freebsd_arm64.go
+++ b/unix/syscall_freebsd_arm64.go
@@ -54,3 +54,9 @@
 }
 
 func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
+
+func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) {
+	ioDesc := PtraceIoDesc{Op: int32(req), Offs: (*byte)(unsafe.Pointer(addr)), Addr: (*byte)(unsafe.Pointer(&out[0])), Len: uint64(countin)}
+	err = ptrace(PTRACE_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0)
+	return int(ioDesc.Len), err
+}
diff --git a/unix/ztypes_freebsd_386.go b/unix/ztypes_freebsd_386.go
index cd16bc5..0ec1596 100644
--- a/unix/ztypes_freebsd_386.go
+++ b/unix/ztypes_freebsd_386.go
@@ -423,7 +423,7 @@
 	Op   int32
 	Offs *byte
 	Addr *byte
-	Len  uint
+	Len  uint32
 }
 
 type Kevent_t struct {
diff --git a/unix/ztypes_freebsd_amd64.go b/unix/ztypes_freebsd_amd64.go
index 4eb6ae3..8340f57 100644
--- a/unix/ztypes_freebsd_amd64.go
+++ b/unix/ztypes_freebsd_amd64.go
@@ -428,7 +428,7 @@
 	Op   int32
 	Offs *byte
 	Addr *byte
-	Len  uint
+	Len  uint64
 }
 
 type Kevent_t struct {
diff --git a/unix/ztypes_freebsd_arm.go b/unix/ztypes_freebsd_arm.go
index a1d4aaf..6f79227 100644
--- a/unix/ztypes_freebsd_arm.go
+++ b/unix/ztypes_freebsd_arm.go
@@ -405,7 +405,7 @@
 	Op   int32
 	Offs *byte
 	Addr *byte
-	Len  uint
+	Len  uint32
 }
 
 type Kevent_t struct {
diff --git a/unix/ztypes_freebsd_arm64.go b/unix/ztypes_freebsd_arm64.go
index 1d27d6f..e751e00 100644
--- a/unix/ztypes_freebsd_arm64.go
+++ b/unix/ztypes_freebsd_arm64.go
@@ -406,7 +406,7 @@
 	Op   int32
 	Offs *byte
 	Addr *byte
-	Len  uint
+	Len  uint64
 }
 
 type Kevent_t struct {