2016-02-15 15:14:07 +00:00
|
|
|
// +build linux darwin
|
|
|
|
|
2017-04-21 06:55:53 +00:00
|
|
|
package proc_test
|
2016-02-15 15:14:07 +00:00
|
|
|
|
|
|
|
import (
|
2017-04-21 06:55:53 +00:00
|
|
|
"runtime"
|
2016-02-25 09:48:42 +00:00
|
|
|
"syscall"
|
2016-02-15 15:14:07 +00:00
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
2017-04-21 06:55:53 +00:00
|
|
|
"github.com/derekparker/delve/pkg/proc"
|
2017-02-08 16:00:44 +00:00
|
|
|
protest "github.com/derekparker/delve/pkg/proc/test"
|
2016-02-15 15:14:07 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestIssue419(t *testing.T) {
|
2017-02-10 14:11:40 +00:00
|
|
|
if testBackend == "lldb" && runtime.GOOS == "darwin" {
|
|
|
|
// debugserver bug?
|
|
|
|
return
|
|
|
|
}
|
2017-05-05 22:17:52 +00:00
|
|
|
if testBackend == "rr" {
|
|
|
|
return
|
|
|
|
}
|
2016-02-15 15:14:07 +00:00
|
|
|
// SIGINT directed at the inferior should be passed along not swallowed by delve
|
2017-04-21 07:50:38 +00:00
|
|
|
withTestProcess("issue419", t, func(p proc.Process, fixture protest.Fixture) {
|
2017-02-10 14:11:40 +00:00
|
|
|
_, err := setFunctionBreakpoint(p, "main.main")
|
|
|
|
assertNoError(err, t, "SetBreakpoint()")
|
2017-04-21 06:55:53 +00:00
|
|
|
assertNoError(proc.Continue(p), t, "Continue()")
|
2017-06-06 15:26:16 +00:00
|
|
|
resumeChan := make(chan struct{})
|
2016-02-15 15:14:07 +00:00
|
|
|
go func() {
|
2017-06-06 15:26:16 +00:00
|
|
|
time.Sleep(500 * time.Millisecond)
|
|
|
|
<-resumeChan
|
|
|
|
if p.Pid() <= 0 {
|
|
|
|
// if we don't stop the inferior the test will never finish
|
|
|
|
p.RequestManualStop()
|
|
|
|
p.Kill()
|
|
|
|
t.Fatalf("Pid is zero or negative: %d", p.Pid())
|
|
|
|
return
|
2016-02-15 15:14:07 +00:00
|
|
|
}
|
2017-06-06 15:26:16 +00:00
|
|
|
err := syscall.Kill(p.Pid(), syscall.SIGINT)
|
|
|
|
assertNoError(err, t, "syscall.Kill")
|
2016-02-15 15:14:07 +00:00
|
|
|
}()
|
2017-06-06 15:26:16 +00:00
|
|
|
p.ResumeNotify(resumeChan)
|
2017-04-21 06:55:53 +00:00
|
|
|
err = proc.Continue(p)
|
|
|
|
if _, exited := err.(proc.ProcessExitedError); !exited {
|
2016-02-15 15:14:07 +00:00
|
|
|
t.Fatalf("Unexpected error after Continue(): %v\n", err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|