go-delve/delve · error

unsupported expression type: %s

Error message

unsupported expression type: %s

What it means

examineMemory's -x expression must evaluate to a pointer, an integer, or an unsigned integer kind; the resulting value's Kind is converted to a uint64 address. Any other kind (float, string, struct, map, etc.) hits the default case and produces this error naming the reflect.Kind.

Source

Thrown at service/dap/command.go:187

		val, err := s.debugger.EvalVariableInScope(int64(goid), frame, 0, args.Operand, s.loadConfig())
		if err != nil {
			return "", err
		}

		switch val.Kind {
		case reflect.Pointer: // "-x &myVar" or "-x myPtrVar"
			if len(val.Children) < 1 {
				return fmt.Errorf("bug? invalid pointer: %#v", val).Error(), nil
			}
			address = val.Children[0].Addr

		case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: // "-x 0xc000079f20 + 8" or -x 824634220320 + 8
			n, _ := constant.Int64Val(val.Value)
			address = uint64(n)
		case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: // "-x 0xc000079f20 + 8" or -x 824634220320 + 8
			address, _ = constant.Uint64Val(val.Value)
		default:
			return fmt.Errorf("unsupported expression type: %s", val.Kind).Error(), nil
		}
	} else {
		address, err = strconv.ParseUint(args.Operand, 0, 64)
		if err != nil {
			return fmt.Errorf("convert address into uintptr type failed, %s", err).Error(), nil
		}
	}

	memory, err := s.debugger.ExamineMemory(
		address,
		min(int(args.Count*args.Size), rpc2.ExamineMemoryLengthLimit),
	)
	if err != nil {
		return fmt.Errorf("examine memory error: %w", err).Error(), nil
	}

	return api.PrettyExamineMemory(uintptr(address), memory, true, args.Format, int(args.Size)), nil
}

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Use an expression of integer/pointer type, or cast: '-x int(myVar)'.
  2. Pass the raw address string without -x (it is parsed with strconv.ParseUint).
  3. Convert a string address manually to a hex literal: '-x 0xc000010000' or plain '0xc000010000'.

Example fix

// before
examineMemory -x addrString   // addrString is a string
// after
examineMemory 0xc000010000
Defensive patterns

Strategy: type-guard

Validate before calling

func isAddressKind(k reflect.Kind) bool {
	switch k {
	case reflect.Pointer, reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
		reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
		return true
	}
	return false
} // check the evaluated Variable's Kind before invoking examineMemory -x

Type guard

func canUseAsAddress(val api.Variable) bool {
	return isAddressKind(val.Kind)
}

Try / catch

out, err := s.examineMemory(goid, frame, "-x "+expr)
if err != nil {
	log.Printf("%v - cast the expression to int or pass a literal address", err)
	return ""
}

Prevention

When it happens

Trigger: Calling examineMemory with '-x myFloatVar', '-x myStruct', or an arithmetic expression evaluating to a non-integer type, e.g. '-x addr + 0.5'.

Common situations: Passing a string variable holding a hex address instead of the literal; using float addresses from another tool's output; arithmetic that promotes to float; passing a struct field of non-integer type.

Related errors


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