go-delve/delve · warning

unsupported constant kind

Error message

unsupported constant kind %v

What it means

When a name resolves to a DWARF constant, findGlobalInternal builds a Variable and materializes its value. Only signed and unsigned integer kinds are supported; if the constant's reflect.Kind is anything else (float, string, bool constants recorded in DWARF with unsupported representation), the lookup aborts with this error instead of returning a wrong value.

Solutions

  1. Use the constant's literal value directly in the expression instead of the symbol name (e.g. `x == "mystring"` rather than `x == MyStringConst`).
  2. Check the constant's declared type; give it an explicit typed form (typed const of int kind) if you control the code.
  3. Compare against a variable holding the constant's value in the debuggee.
  4. If a legitimately integer constant hits this, verify DWARF is not corrupted; otherwise treat as unsupported and work around with literals.

Example fix

// before
scope.EvalExpression("MyConst", cfg) // unsupported constant kind string
// after
scope.EvalExpression("\"myconst value\"", cfg) // use the literal value
Defensive patterns

Strategy: fallback

Validate before calling

// prefer inlining the constant's literal into the expression
expr := strings.ReplaceAll(expr, constName, constLiteralValue)

Try / catch

v, err := scope.EvalExpression(name, cfg)
if err != nil && strings.Contains(err.Error(), "unsupported constant kind") {
    v, err = scope.EvalExpression(constLiteral, cfg) // substitute the literal value
}

Prevention

When it happens

Trigger: Evaluating an expression whose name matches an entry in BinInfo.consts whose DWARF-derived Variable kind is not one of the Int*/Uint* kinds handled in the switch — e.g. an untyped float, string, or bool constant whose kind materialized as something outside the supported set.

Common situations: Evaluating string or float constants that the DWARF producer recorded without an address (const with no memory location); version/toolchain changes altering how constants are emitted; suffix matching pulling in an unexpected constant kind.

Related errors


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

Appendix: source

Thrown at pkg/proc/eval.go:851

			}
			return r, nil
		}
	}
	for dwref, ctyp := range scope.BinInfo.consts {
		for _, cval := range ctyp.values {
			if cval.fullName == name || strings.HasSuffix(cval.fullName, "/"+name) {
				t, err := scope.BinInfo.Images[dwref.imageIndex].Type(dwref.offset)
				if err != nil {
					return nil, err
				}
				v := newVariable(name, 0x0, t, scope.BinInfo, scope.Mem)
				switch v.Kind {
				case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
					v.Value = constant.MakeInt64(cval.value)
				case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
					v.Value = constant.MakeUint64(uint64(cval.value))
				default:
					return nil, fmt.Errorf("unsupported constant kind %v", v.Kind)
				}
				v.Flags |= VariableConstant
				v.loaded = true
				return v, nil
			}
		}
	}
	return nil, nil
}

// image returns the image containing the current function.
func (scope *EvalScope) image() *Image {
	return scope.BinInfo.funcToImage(scope.Fn)
}

// evalStack stores the stack machine used to evaluate a program made of
// evalop.Ops.
// When an opcode sets callInjectionContinue execution of the program will be suspended

View on GitHub (pinned to a23773e6c3)