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:
Alessandro Arzilli
2017-05-26 20:36:28 +02:00
committed by Derek Parker
parent 40b482130a
commit cf84483672
3 changed files with 22 additions and 3 deletions

View File

@ -1245,7 +1245,12 @@ func (v *Variable) loadMap(recurseLevel int, cfg LoadConfig) {
break
}
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)
val.loadValueInternal(recurseLevel+1, cfg)
if key.Unreadable != nil || val.Unreadable != nil {
@ -1425,7 +1430,14 @@ func (it *mapIterator) nextBucket() bool {
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
return false
}