Add changes to ptrace wrappers to fix FreeBSD-related bugs