ogle/debug/dwarf: copy update to ArrayType from main repo.
code from https://golang.org/cl/111230044
LGTM=rsc
R=rsc
https://golang.org/cl/110690045
diff --git a/debug/dwarf/type.go b/debug/dwarf/type.go
index 9a1ea2e..27baa63 100644
--- a/debug/dwarf/type.go
+++ b/debug/dwarf/type.go
@@ -422,16 +422,22 @@
// but haven't seen that in the wild yet.
switch kid.Tag {
case TagSubrangeType:
- max, ok := kid.Val(AttrUpperBound).(int64)
+ count, ok := kid.Val(AttrCount).(int64)
if !ok {
- max = -2 // Count == -1, as in x[].
+ // Old binaries may have an upper bound instead.
+ count, ok = kid.Val(AttrUpperBound).(int64)
+ if ok {
+ count++ // Length is one more than upper bound.
+ } else {
+ count = -1 // As in x[].
+ }
}
if ndim == 0 {
- t.Count = max + 1
+ t.Count = count
} else {
// Multidimensional array.
// Create new array type underneath this one.
- t.Type = &ArrayType{Type: t.Type, Count: max + 1}
+ t.Type = &ArrayType{Type: t.Type, Count: count}
}
ndim++
case TagEnumerationType: