diff --git a/_fixtures/testvariables2.go b/_fixtures/testvariables2.go index ae1d7952..f800ae2d 100644 --- a/_fixtures/testvariables2.go +++ b/_fixtures/testvariables2.go @@ -151,6 +151,8 @@ type ThreeInts struct { var _ I = (*W2)(nil) +type pptr *pptr + func main() { i1 := 1 i2 := 2 @@ -388,6 +390,9 @@ func main() { int3chan <- ThreeInts{a: 2} int3chan <- ThreeInts{a: 3} + var ptrinf2 pptr + ptrinf2 = &ptrinf2 + var amb1 = 1 runtime.Breakpoint() for amb1 := 0; amb1 < 10; amb1++ { diff --git a/pkg/proc/variables.go b/pkg/proc/variables.go index 49ccbf76..c1b391ca 100644 --- a/pkg/proc/variables.go +++ b/pkg/proc/variables.go @@ -1305,10 +1305,21 @@ func (v *Variable) loadValueInternal(recurseLevel int, cfg LoadConfig) { // Don't increase the recursion level when dereferencing pointers // unless this is a pointer to interface (which could cause an infinite loop) nextLvl := recurseLevel + checkLvl := false if v.Children[0].Kind == reflect.Interface { nextLvl++ + } else if ptyp, isptr := v.RealType.(*godwarf.PtrType); isptr { + _, elemTypIsPtr := resolveTypedef(ptyp.Type).(*godwarf.PtrType) + if elemTypIsPtr { + nextLvl++ + checkLvl = true + } + } + if checkLvl && recurseLevel > cfg.MaxVariableRecurse { + v.Children[0].OnlyAddr = true + } else { + v.Children[0].loadValueInternal(nextLvl, cfg) } - v.Children[0].loadValueInternal(nextLvl, cfg) } else { v.Children[0].OnlyAddr = true } diff --git a/pkg/proc/variables_test.go b/pkg/proc/variables_test.go index 01435e2b..95da5216 100644 --- a/pkg/proc/variables_test.go +++ b/pkg/proc/variables_test.go @@ -741,6 +741,8 @@ func getEvalExpressionTestCases() []varTest { {"emptymap", false, `map[string]string []`, `map[string]string []`, "map[string]string", nil}, {"mnil", false, `map[string]main.astruct nil`, `map[string]main.astruct nil`, "map[string]main.astruct", nil}, + {"ptrinf2", false, `**(main.pptr)(…`, `(main.pptr)(…`, "main.pptr", nil}, + // conversions between string/[]byte/[]rune (issue #548) {"runeslice", true, `[]int32 len: 4, cap: 4, [116,232,115,116]`, `[]int32 len: 4, cap: 4, [...]`, "[]int32", nil}, {"byteslice", true, `[]uint8 len: 5, cap: 5, [116,195,168,115,116]`, `[]uint8 len: 5, cap: 5, [...]`, "[]uint8", nil},