3 // Copyright 2014 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
7 // issue 7690 - Stack and other routines did not back up initial PC
8 // into CALL instruction, instead reporting line number of next instruction,
9 // which might be on a different line.
21 buf1 := make([]byte, 1000)
22 buf2 := make([]byte, 1000)
24 runtime.Stack(buf1, false) // CALL is last instruction on this line
25 n := runtime.Stack(buf2, false) // CALL is followed by load of result from stack
27 buf1 = buf1[:bytes.IndexByte(buf1, 0)]
30 re := regexp.MustCompile(`(?m)^main\.main\(\)\n.*/issue7690.go:([0-9]+)`)
31 m1 := re.FindStringSubmatch(string(buf1))
33 println("BUG: cannot find main.main in first trace")
36 m2 := re.FindStringSubmatch(string(buf2))
38 println("BUG: cannot find main.main in second trace")
42 n1, _ := strconv.Atoi(m1[1])
43 n2, _ := strconv.Atoi(m2[1])
45 println("BUG: expect runtime.Stack on back to back lines, have", n1, n2)