go-delve/delve · error

unknown CPU register type conversion to %q

Error message

unknown CPU register type conversion to %q

What it means

When converting a CPU register's bytes to a typed value (e.g. in disassembly/register views), Delve accepts a requested type like 'uint64'/'int32' and derives the byte count n; n must be nonzero and a power of two. Otherwise it refuses with this error.

Source

Thrown at pkg/proc/variables.go:2244

			child = newConstant(constant.MakeFloat64(float64(x)), v.bi, v.mem)
			child.Kind = reflect.Float32
			n = 4
		case "float64":
			a := binary.LittleEndian.Uint64(v.reg.Bytes[i:])
			x := *(*float64)(unsafe.Pointer(&a))
			child = newConstant(constant.MakeFloat64(x), v.bi, v.mem)
			child.Kind = reflect.Float64
			n = 8
		default:
			if n == 0 {
				for _, pfx := range []string{"uint", "int"} {
					if strings.HasPrefix(newtyp, pfx) {
						n, _ = strconv.Atoi(newtyp[len(pfx):])
						break
					}
				}
				if n == 0 || bits.OnesCount64(uint64(n)) != 1 {
					return nil, fmt.Errorf("unknown CPU register type conversion to %q", newtyp)
				}
				n = n / 8
			}
			child = newConstant(constant.MakeString(fmt.Sprintf("%x", v.reg.Bytes[i:][:n])), v.bi, v.mem)
		}
		v.Children = append(v.Children, *child)
	}

	v.loaded = true
	v.Kind = reflect.Array
	v.Len = int64(len(v.Children))
	v.Base = fakeAddressUnresolv
	v.DwarfType = fakeArrayType(uint64(len(v.Children)), &godwarf.VoidType{CommonType: godwarf.CommonType{ByteSize: int64(n)}})
	v.RealType = v.DwarfType
	return v, nil
}

func isCgoType(bi *BinaryInfo, typ godwarf.Type) bool {

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Use a standard width type name: uint8/16/32/64, int8/16/32/64, float32/64
  2. Remove zero or non-power-of-two widths (e.g. 'uint24' -> 'uint32')
  3. Check casing/spelling: the prefix match is exact (e.g. 'uint64', not 'UINT64')
  4. If you need unusual widths, read raw bytes and decode manually in your tool

Example fix

// before
conv := convertReg(reg, "uint24")   // error: unknown CPU register type conversion to "uint24"
// after
conv := convertReg(reg, "uint32")
Defensive patterns

Strategy: validation

Validate before calling

// Validate conversion target before requesting it
var n int
for _, pfx := range []string{"uint", "int", "float"} {
    if strings.HasPrefix(typ, pfx) { n, _ = strconv.Atoi(typ[len(pfx):]) }
}
valid := n > 0 && bits.OnesCount64(uint64(n)) == 1

Prevention

When it happens

Trigger: Requesting a register type conversion to a name that has no recognized 'uintN'/'intN'/'floatN' prefix, or one whose parsed width is not a power of two (e.g. 'uint24', 'int0', arbitrary strings).

Common situations: Typo'd register type names in custom tooling/scripting against delve internals; passing C-style types like 'long' or 'size_t' that aren't uintN/intN forms.

Related errors


AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31). Data as JSON: /api/errors/531bac18c3b75168. Report an issue: GitHub.