cmd/viewcore: handle typedef'd mspan.state

mspan.state used to (go1.13) be a uint8, now (go1.14) it is a struct
with a uint8 field.

Update golang/go#38638

Change-Id: I042787a61479808d37afa0a7f8caed06b5a18567
Reviewed-on: https://go-review.googlesource.com/c/debug/+/232160
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
diff --git a/internal/gocore/process.go b/internal/gocore/process.go
index a2426a0..ca83b94 100644
--- a/internal/gocore/process.go
+++ b/internal/gocore/process.go
@@ -354,7 +354,11 @@
 				spanSize -= pageSize
 			}
 		}
-		switch s.Field("state").Uint8() {
+		st := s.Field("state")
+		if st.IsStruct() && st.HasField("s") { // go1.14+
+			st = st.Field("s")
+		}
+		switch st.Uint8() {
 		case spanInUse:
 			inUseSpanSize += spanSize
 			n := int64(s.Field("nelems").Uintptr())
diff --git a/internal/gocore/region.go b/internal/gocore/region.go
index e4fd59a..c544c31 100644
--- a/internal/gocore/region.go
+++ b/internal/gocore/region.go
@@ -188,3 +188,7 @@
 	}
 	return region{p: r.p, a: r.a.Add(i * r.typ.Elem.Size), typ: r.typ.Elem}
 }
+
+func (r region) IsStruct() bool {
+	return r.typ.Kind == KindStruct
+}