mirror of
https://github.com/go-delve/delve.git
synced 2025-11-02 12:59:01 +08:00
proc/variables: bugfix: parsing of maps with zero sized value type (#851)
Buckets of maps with zero sized value types (i.e. map[T]struct{}) have
zero length value arrays.
This commit is contained in:
committed by
Derek Parker
parent
40b482130a
commit
cf84483672
@ -220,6 +220,10 @@ func main() {
|
|||||||
sliceinf := make([]interface{}, 1)
|
sliceinf := make([]interface{}, 1)
|
||||||
sliceinf[0] = sliceinf
|
sliceinf[0] = sliceinf
|
||||||
|
|
||||||
|
zsvar := struct{}{}
|
||||||
|
zsslice := make([]struct{}, 3)
|
||||||
|
zsvmap := map[string]struct{}{"testkey": struct{}{}}
|
||||||
|
|
||||||
var amb1 = 1
|
var amb1 = 1
|
||||||
runtime.Breakpoint()
|
runtime.Breakpoint()
|
||||||
for amb1 := 0; amb1 < 10; amb1++ {
|
for amb1 := 0; amb1 < 10; amb1++ {
|
||||||
@ -227,5 +231,5 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
runtime.Breakpoint()
|
runtime.Breakpoint()
|
||||||
fmt.Println(i1, i2, i3, p1, amb1, s1, s3, a1, p2, p3, s2, as1, str1, f1, fn1, fn2, nilslice, nilptr, ch1, chnil, m1, mnil, m2, m3, up1, i4, i5, i6, err1, err2, errnil, iface1, iface2, ifacenil, arr1, parr, cpx1, const1, iface3, iface4, recursive1, recursive1.x, iface5, iface2fn1, iface2fn2, bencharr, benchparr, mapinf, mainMenu, b, b2, sd, anonstruct1, anonstruct2, anoniface1, anonfunc, mapanonstruct1, ifacearr, efacearr, ni8, ni16, ni32, pinf, ninf, nan)
|
fmt.Println(i1, i2, i3, p1, amb1, s1, s3, a1, p2, p3, s2, as1, str1, f1, fn1, fn2, nilslice, nilptr, ch1, chnil, m1, mnil, m2, m3, up1, i4, i5, i6, err1, err2, errnil, iface1, iface2, ifacenil, arr1, parr, cpx1, const1, iface3, iface4, recursive1, recursive1.x, iface5, iface2fn1, iface2fn2, bencharr, benchparr, mapinf, mainMenu, b, b2, sd, anonstruct1, anonstruct2, anoniface1, anonfunc, mapanonstruct1, ifacearr, efacearr, ni8, ni16, ni32, pinf, ninf, nan, zsvmap, zsslice, zsvar)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1245,7 +1245,12 @@ func (v *Variable) loadMap(recurseLevel int, cfg LoadConfig) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
key := it.key()
|
key := it.key()
|
||||||
val := it.value()
|
var val *Variable
|
||||||
|
if it.values.fieldType.Size() > 0 {
|
||||||
|
val = it.value()
|
||||||
|
} else {
|
||||||
|
val = v.newVariable("", it.values.Addr, it.values.fieldType)
|
||||||
|
}
|
||||||
key.loadValueInternal(recurseLevel+1, cfg)
|
key.loadValueInternal(recurseLevel+1, cfg)
|
||||||
val.loadValueInternal(recurseLevel+1, cfg)
|
val.loadValueInternal(recurseLevel+1, cfg)
|
||||||
if key.Unreadable != nil || val.Unreadable != nil {
|
if key.Unreadable != nil || val.Unreadable != nil {
|
||||||
@ -1425,7 +1430,14 @@ func (it *mapIterator) nextBucket() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if it.tophashes.Len != it.keys.Len || it.tophashes.Len != it.values.Len {
|
if it.tophashes.Len != it.keys.Len {
|
||||||
|
it.v.Unreadable = mapBucketContentsInconsistentLenErr
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if it.values.fieldType.Size() > 0 && it.tophashes.Len != it.values.Len {
|
||||||
|
// if the type of the value is zero-sized (i.e. struct{}) then the values
|
||||||
|
// array's length is zero.
|
||||||
it.v.Unreadable = mapBucketContentsInconsistentLenErr
|
it.v.Unreadable = mapBucketContentsInconsistentLenErr
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@ -691,6 +691,9 @@ func TestEvalExpression(t *testing.T) {
|
|||||||
|
|
||||||
{"ifacearr", false, "[]error len: 2, cap: 2, [*main.astruct {A: 0, B: 0},nil]", "[]error len: 2, cap: 2, [...]", "[]error", nil},
|
{"ifacearr", false, "[]error len: 2, cap: 2, [*main.astruct {A: 0, B: 0},nil]", "[]error len: 2, cap: 2, [...]", "[]error", nil},
|
||||||
{"efacearr", false, `[]interface {} len: 3, cap: 3, [*main.astruct {A: 0, B: 0},*"test",nil]`, "[]interface {} len: 3, cap: 3, [...]", "[]interface {}", nil},
|
{"efacearr", false, `[]interface {} len: 3, cap: 3, [*main.astruct {A: 0, B: 0},*"test",nil]`, "[]interface {} len: 3, cap: 3, [...]", "[]interface {}", nil},
|
||||||
|
|
||||||
|
{"zsslice", false, `[]struct {} len: 3, cap: 3, [{},{},{}]`, `[]struct {} len: 3, cap: 3, [...]`, "[]struct {}", nil},
|
||||||
|
{"zsvmap", false, `map[string]struct {} ["testkey": {}, ]`, `map[string]struct {} [...]`, "map[string]struct {}", nil},
|
||||||
}
|
}
|
||||||
|
|
||||||
ver, _ := proc.ParseVersionString(runtime.Version())
|
ver, _ := proc.ParseVersionString(runtime.Version())
|
||||||
|
|||||||
Reference in New Issue
Block a user