internal/gocore: update for CL 451359

CL 451359 changed the size of mspan.nelems and mspan.freeindex. Update
for the new sizes.

Fixes golang/go#63359.

Change-Id: I3ffc0843f0238cf27ddc047f6c4ed8781862d5ad
Reviewed-on: https://go-review.googlesource.com/c/debug/+/532735
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
diff --git a/internal/gocore/process.go b/internal/gocore/process.go
index 4df8008..b76a810 100644
--- a/internal/gocore/process.go
+++ b/internal/gocore/process.go
@@ -411,7 +411,13 @@
 		switch st.Uint8() {
 		case spanInUse:
 			inUseSpanSize += spanSize
-			n := int64(s.Field("nelems").Uintptr())
+			nelems := s.Field("nelems")
+			var n int64
+			if nelems.IsUint16() { // go1.22+
+				n = int64(nelems.Uint16())
+			} else {
+				n = int64(nelems.Uintptr())
+			}
 			// An object is allocated if it is marked as
 			// allocated or it is below freeindex.
 			x := s.Field("allocBits").Address()
@@ -419,7 +425,13 @@
 			for i := int64(0); i < n; i++ {
 				alloc[i] = p.proc.ReadUint8(x.Add(i/8))>>uint(i%8)&1 != 0
 			}
-			k := int64(s.Field("freeindex").Uintptr())
+			freeindex := s.Field("freeindex")
+			var k int64
+			if freeindex.IsUint16() { // go1.22+
+				k = int64(freeindex.Uint16())
+			} else {
+				k = int64(freeindex.Uintptr())
+			}
 			for i := int64(0); i < k; i++ {
 				alloc[i] = true
 			}
diff --git a/internal/gocore/region.go b/internal/gocore/region.go
index c544c31..df09865 100644
--- a/internal/gocore/region.go
+++ b/internal/gocore/region.go
@@ -192,3 +192,7 @@
 func (r region) IsStruct() bool {
 	return r.typ.Kind == KindStruct
 }
+
+func (r region) IsUint16() bool {
+	return r.typ.Kind == KindUint && r.typ.Size == 2
+}