A transparent stop can expose a thread's trapframe while it is still in
a syscall. PT_SETREGS installs new registers, but the pending syscall's
return path subsequently overwrites result registers and flags, or rewinds
the newly installed PC for ERESTART. Waking the modified sleeper does not
prevent this overwrite.
Track general-register writes separately from TDB_USERWR, which also covers
memory, floating-point and debug-register writes. Mark successful PT_SETREGS
and NT_PRSTATUS writes, and explicit continue-PC changes. At syscall return,
consume TDB_USERREGS and use EJUSTRETURN to preserve the installed trapframe.
Check the flag even if the syscall began before the debugger attached.
Clear the flag on the next syscall entry and after the entry ptrace stop.
Entry-time register edits still supply syscall arguments, and normal
results and PT_SET_SC_RET remain effective. Memory-only and FP/debug-register
writes do not suppress normal syscall return values.
Add amd64/arm64 regressions that attach during an observed blocking pipe
read, install sentinel return registers and redirect PC to a trap. Cover
PT_SETREGS and PT_SETREGSET, and extend the syscall-argument test to verify
that entry-time register writeback still receives getpid's actual result.
MFC after: 2 weeks
Sponsored by: FreeBSD Foundation