delve/pkg/proc/native/threads_hardware_singlestep_linux.go
2024-10-11 12:34:25 -07:00

46 lines
1.0 KiB
Go

//go:build !riscv64
package native
import (
"github.com/go-delve/delve/pkg/proc"
sys "golang.org/x/sys/unix"
)
func (procgrp *processGroup) singleStep(t *nativeThread) (err error) {
sig := 0
for {
t.dbp.execPtraceFunc(func() { err = ptraceSingleStep(t.ID, sig) })
sig = 0
if err != nil {
return err
}
wpid, status, err := t.dbp.waitFast(t.ID)
if err != nil {
return err
}
if (status == nil || status.Exited()) && wpid == t.dbp.pid {
t.dbp.postExit()
rs := 0
if status != nil {
rs = status.ExitStatus()
}
return proc.ErrProcessExited{Pid: t.dbp.pid, Status: rs}
}
if wpid == t.ID {
switch s := status.StopSignal(); s {
case sys.SIGTRAP:
return nil
case sys.SIGSTOP:
// delayed SIGSTOP, ignore it
case sys.SIGILL, sys.SIGBUS, sys.SIGFPE, sys.SIGSEGV, sys.SIGSTKFLT:
// propagate signals that can have been caused by the current instruction
sig = int(s)
default:
// delay propagation of all other signals
t.os.delayedSignal = int(s)
}
}
}
}