delve/_fixtures/databpeasy.go
Alessandro Arzilli 1893c9769b
Miscellaneous fixes for Windows native backend (#2736)
* proc/native: always stop after RequestManualStop on Windows

On Windows RequestManualStop will generate an exception on a special
DbgUiRemoteBreakin thread, sometimes this thread will die before we
finish stopping the process. We need to account for that and still stop
even if the thread is gone and no other thread hit a breakpoint.

Fixes flakiness of TestIssue419.

* proc/native: fix watchpoints with new threads on Windows

When a new thread is created we must reapply all watchpoints to it,
like we do on linux.

* tests: be lenient on goroutinestackprog tests on Windows

We can not guarantee that we find all goroutines stopped in a good
place and sometimes the stacktrace fails on Windows.
2021-10-13 08:43:54 -07:00

49 lines
948 B
Go

package main
import (
"fmt"
"runtime"
"sync"
"time"
)
var globalvar1 = 0
var globalvar2 = 0
func main() { // Position 0
runtime.LockOSThread()
globalvar2 = 1
fmt.Printf("%d %d\n", globalvar1, globalvar2)
globalvar2 = globalvar1 + 1
globalvar1 = globalvar2 + 1
fmt.Printf("%d %d\n", globalvar1, globalvar2) // Position 1
globalvar2 = globalvar2 + 1 // Position 2
globalvar2 = globalvar1 + globalvar2 // Position 3
fmt.Printf("%d %d\n", globalvar1, globalvar2)
globalvar1 = globalvar2 + 1
fmt.Printf("%d %d\n", globalvar1, globalvar2)
done := make(chan struct{}) // Position 4
var wg sync.WaitGroup
for i := 0; i < 20; i++ {
wg.Add(1)
go waitfunc(i, &wg)
}
wg.Wait()
go f(done)
<-done
}
func f(done chan struct{}) {
runtime.LockOSThread()
globalvar1 = globalvar2 + 2
close(done) // Position 5
}
func waitfunc(i int, wg *sync.WaitGroup) {
runtime.LockOSThread()
wg.Done()
time.Sleep(50 * time.Second)
}