github.com/neilgarb/delve@v1.9.2-nobreaks/_fixtures/issue573.go (about)

     1  package main
     2  
     3  // A debugger test.
     4  //   dlv debug
     5  //   b main.foo
     6  //   c
     7  //   s
     8  //   s
     9  // Expect to be stopped in fmt.Printf or runtime.duffzero
    10  // In bug, s #2 runs to the process exit because the call
    11  // to duffzero enters duffzero well after the nominal entry
    12  // and skips the internal breakpoint placed by Step().
    13  import "fmt"
    14  
    15  var v int = 99
    16  
    17  func foo(x, y int) (z int) { // c stops here
    18  	fmt.Printf("x=%d, y=%d, z=%d\n", x, y, z) // s #1 stops here; s #2 is supposed to stop in Printf or duffzero.
    19  	z = x + y
    20  	return
    21  }
    22  
    23  func main() {
    24  	x := v
    25  	y := x * x
    26  	z := foo(x, y)
    27  	fmt.Printf("z=%d\n", z)
    28  }