parent
16f30d0738
commit
58913527db
@ -1556,3 +1556,23 @@ func TestIssue396(t *testing.T) {
|
||||
assertNoError(err, t, "FindFunctionLocation()")
|
||||
})
|
||||
}
|
||||
|
||||
func TestIssue414(t *testing.T) {
|
||||
// Stepping until the program exits
|
||||
withTestProcess("math", t, func(p *Process, fixture protest.Fixture) {
|
||||
start, _, err := p.goSymTable.LineToPC(fixture.Source, 9)
|
||||
assertNoError(err, t, "LineToPC()")
|
||||
_, err = p.SetBreakpoint(start)
|
||||
assertNoError(err, t, "SetBreakpoint()")
|
||||
assertNoError(p.Continue(), t, "Continue()")
|
||||
for {
|
||||
err := p.Step()
|
||||
if err != nil {
|
||||
if _, exited := err.(ProcessExitedError); exited {
|
||||
break
|
||||
}
|
||||
}
|
||||
assertNoError(err, t, "Step()")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -95,6 +95,9 @@ func (thread *Thread) StepInstruction() (err error) {
|
||||
|
||||
err = thread.singleStep()
|
||||
if err != nil {
|
||||
if _, exited := err.(ProcessExitedError); exited {
|
||||
return err
|
||||
}
|
||||
return fmt.Errorf("step failed: %s", err.Error())
|
||||
}
|
||||
return nil
|
||||
|
@ -39,8 +39,11 @@ func (t *Thread) singleStep() error {
|
||||
return fmt.Errorf("could not single step")
|
||||
}
|
||||
for {
|
||||
port := C.mach_port_wait(t.dbp.os.portSet, C.int(0))
|
||||
if port == C.mach_port_t(t.ID) {
|
||||
twthread, err := t.dbp.trapWait(t.dbp.Pid)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if twthread.ID == t.ID {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,14 @@ func (t *Thread) singleStep() (err error) {
|
||||
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 ProcessExitedError{Pid: t.dbp.Pid, Status: rs}
|
||||
}
|
||||
if wpid == t.ID && status.StopSignal() == sys.SIGTRAP {
|
||||
return nil
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package proc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"syscall"
|
||||
|
||||
sys "golang.org/x/sys/windows"
|
||||
@ -48,10 +47,7 @@ func (t *Thread) singleStep() error {
|
||||
if thread.ID == t.ID {
|
||||
continue
|
||||
}
|
||||
_, err := _SuspendThread(thread.os.hThread)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not suspend thread: %d: %v", thread.ID, err)
|
||||
}
|
||||
_, _ = _SuspendThread(thread.os.hThread)
|
||||
}
|
||||
|
||||
// Continue and wait for the step to complete
|
||||
@ -72,10 +68,7 @@ func (t *Thread) singleStep() error {
|
||||
if thread.ID == t.ID {
|
||||
continue
|
||||
}
|
||||
_, err := _ResumeThread(thread.os.hThread)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not resume thread: %d: %v", thread.ID, err)
|
||||
}
|
||||
_, _ = _ResumeThread(thread.os.hThread)
|
||||
}
|
||||
|
||||
// Unset the processor TRAP flag
|
||||
|
Loading…
Reference in New Issue
Block a user