delve/_fixtures/testvariables.go
Alessandro Arzilli f9c8f7f55b
Go 1.15 support (#2011)
* proc: start variable visibility one line after their decl line

In most cases variables shouldn't be visible on their declaration line
because they won't be initialized there.
Function arguments are treated as an exception.

This fix is only applied to programs compiled with Go 1.15 or later as
previous versions of Go did not report the correct declaration line for
variables captured by closures.

Fixes #1134

* proc: silence go vet error

* Makefile: enable PIE tests on windows/Go 1.15

* core: support core files for PIEs on windows

* goversion: add Go 1.15 to supported versions

* proc: fix function call injection for Go 1.15

Go 1.15 changed the call injection protocol so that the runtime will
execute the injected call on a different (new) goroutine.

This commit changes the function call support in delve to:

1. correctly track down the call injection state after the runtime
   switches to a different goroutine.
2. correctly perform the escapeCheck when stack values can come from
   multiple goroutine stacks.

* proc: miscellaneous fixed for call injection under macOS with go 1.15

- create copy of SP in debugCallAXCompleteCall case because the code
  used to assume that regs doesn't change
- fix automatic address calculation for function arguments when an
  argument has a spurious DW_OP_piece at entry
2020-07-28 09:19:51 -07:00

71 lines
1.5 KiB
Go

package main
import "fmt"
import "runtime"
type FooBar struct {
Baz int
Bur string
}
// same member names, different order / types
type FooBar2 struct {
Bur int
Baz string
}
type Nest struct {
Level int
Nest *Nest
}
func barfoo() {
a1 := "bur"
runtime.Breakpoint()
fmt.Println(a1)
}
func foobar(baz string, bar FooBar) {
var (
a1 = "foofoofoofoofoofoo"
a2 = 6
a3 = 7.23
a4 = [2]int{1, 2}
a5 = []int{1, 2, 3, 4, 5}
a6 = FooBar{Baz: 8, Bur: "word"}
a7 = &FooBar{Baz: 5, Bur: "strum"}
a8 = FooBar2{Bur: 10, Baz: "feh"}
a9 = (*FooBar)(nil)
a10 = a1[2:5]
a11 = [3]FooBar{{1, "a"}, {2, "b"}, {3, "c"}}
a12 = []FooBar{{4, "d"}, {5, "e"}}
a13 = []*FooBar{{6, "f"}, {7, "g"}, {8, "h"}}
b1 = true
b2 = false
neg = -1
i8 = int8(1)
u8 = uint8(255)
u16 = uint16(65535)
u32 = uint32(4294967295)
u64 = uint64(18446744073709551615)
up = uintptr(5)
f32 = float32(1.2)
c64 = complex(float32(1), float32(2))
c128 = complex(float64(2), float64(3))
i32 = [2]int32{1, 2}
f = barfoo
ms = Nest{0, &Nest{1, &Nest{2, &Nest{3, &Nest{4, nil}}}}} // Test recursion capping
ba = make([]int, 200, 200) // Test array size capping
)
runtime.Breakpoint()
barfoo()
fmt.Println(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, b1, b2, baz, neg, i8, u8, u16, u32, u64, up, f32, c64, c128, i32, bar, f, ms, ba, p1)
}
var p1 = 10
func main() {
foobar("bazburzum", FooBar{Baz: 10, Bur: "lorem"})
}