platform/ptrace: specify PTRACE_O_TRACEEXIT for stub-processes

The tracee is stopped early  during  process  exit,  when registers are still
available, allowing the tracer to see where the exit occurred, whereas the
normal exit  notifi? cation  is  done  after  the process is finished exiting.

Without this option, dumpAndPanic fails to get registers.

PiperOrigin-RevId: 254852917
This commit is contained in:
Andrei Vagin
2019-06-24 15:48:58 -07:00
committed by gVisor bot
parent 87df9aab24
commit c5486f5122
+2 -2
View File
@@ -376,7 +376,7 @@ func (t *thread) init() {
syscall.PTRACE_SETOPTIONS,
uintptr(t.tid),
0,
syscall.PTRACE_O_TRACESYSGOOD,
syscall.PTRACE_O_TRACESYSGOOD|syscall.PTRACE_O_TRACEEXIT,
0, 0)
if errno != 0 {
panic(fmt.Sprintf("ptrace set options failed: %v", errno))
@@ -419,7 +419,7 @@ func (t *thread) syscall(regs *syscall.PtraceRegs) (uintptr, error) {
// between syscall-enter-stop and syscall-exit-stop; it happens *after*
// syscall-exit-stop.)" - ptrace(2), "Syscall-stops"
if sig := t.wait(stopped); sig != (syscallEvent | syscall.SIGTRAP) {
panic(fmt.Sprintf("wait failed: expected SIGTRAP, got %v [%d]", sig, sig))
t.dumpAndPanic(fmt.Sprintf("wait failed: expected SIGTRAP, got %v [%d]", sig, sig))
}
// Grab registers.