go-delve/delve · warning · ErrUnknownRegister
unknown register
Error message
unknown register
What it means
ErrUnknownRegister is returned when a register is requested by name that the architecture's register set does not define. GetReg/Get (and DWARF register name resolution via getAsmRegister) look up names in the arch-specific register table and return this sentinel when the name is not present.
Source
Thrown at pkg/proc/registers.go:50
Name string
Reg *op.DwarfRegister
}
// AppendUint64Register will create a new Register struct with the name and value
// specified and append it to the `regs` slice.
func AppendUint64Register(regs []Register, name string, value uint64) []Register {
return append(regs, Register{name, op.DwarfRegisterFromUint64(value)})
}
// AppendBytesRegister will create a new Register struct with the name and value
// specified and append it to the `regs` slice.
func AppendBytesRegister(regs []Register, name string, value []byte) []Register {
return append(regs, Register{name, op.DwarfRegisterFromBytes(value)})
}
// ErrUnknownRegister is returned when the value of an unknown
// register is requested.
var ErrUnknownRegister = errors.New("unknown register")
type flagRegisterDescr []flagDescr
type flagDescr struct {
name string
mask uint64
}
var mxcsrDescription flagRegisterDescr = []flagDescr{
{"FZ", 1 << 15},
{"RZ/RN", 1<<14 | 1<<13},
{"PM", 1 << 12},
{"UM", 1 << 11},
{"OM", 1 << 10},
{"ZM", 1 << 9},
{"DM", 1 << 8},
{"IM", 1 << 7},
{"DAZ", 1 << 6},
{"PE", 1 << 5},View on GitHub (pinned to a23773e6c3)
Solutions
- Use a register name valid for the target architecture (list them via the appropriate regs/API for the arch)
- Fix the register name spelling and case in your script/command
- Check runtime.GOARCH of the debugged binary before naming registers
Example fix
// before
val, err := regs.Get("eax") // on arm64
// after
val, err := regs.Get("x0") // arch-appropriate register name Defensive patterns
Strategy: validation
Validate before calling
// check arch before naming registers
var reg string
switch runtime.GOARCH {
case "arm64":
reg = "x0"
case "amd64":
reg = "rax"
case "386":
reg = "eax"
} Try / catch
val, err := regs.Get(name)
if errors.Is(err, proc.ErrUnknownRegister) {
return fmt.Errorf("register %q not valid for %s", name, runtime.GOARCH)
} Prevention
- Derive register names from runtime.GOARCH instead of hardcoding
- Consult the arch register list in pkg/proc/<arch>regs before scripting
- Trim/normalize user-provided register names
When it happens
Trigger: Evaluating an expression that references a register name not valid for the target architecture (e.g. 'xmm0' on arm64, 'r15' on 386); RPC calls to GetReg with misspelled names; DWARF CFA/rules referencing registers the backend does not model.
Common situations: Scripts or IDE plugins hardcoding x86 register names while debugging arm64; cross-arch debugging sessions; using DWARF files that reference pseudo-registers the backend lacks.
Related errors
- read out of bounds
- could not read %d bytes from register %d (size: %d), also er
- could not read %d bytes from register %d (size: %d)
- bad address size
- ErrStackUnderflow
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/871ff8c84f12d5d9.
Report an issue: GitHub.