delve/_fixtures/goroutinebreak.go
Suzy Mueller f8deab8522
service/dap: fix goroutine id selection for hardcoded breakpoints (#2748)
* service/dap: fix goroutine id selection for hardcoded breakpoints

Determining the stopped goroutine id on a breakpoint required
checking for breakpoints since some may be tracepoints. However,
there may be goroutines stopped on hardcoded breakpoints with
no breakpoint. We fix this by checking for runtime.breakpoint or
StopReason=proc.StopHardcodedBreakpoint.
2021-10-29 19:40:16 -07:00

27 lines
425 B
Go

package main
import "runtime"
const N = 10
func agoroutine(started chan<- struct{}, done chan<- struct{}, i int) {
started <- struct{}{}
done <- struct{}{}
}
func main() {
done := make(chan struct{})
started := make(chan struct{})
for i := 0; i < N; i++ {
runtime.Breakpoint()
go agoroutine(started, done, i)
}
for i := 0; i < N; i++ {
<-started
}
runtime.Gosched()
for i := 0; i < N; i++ {
<-done
}
}