go-delve/delve · critical
could not find %s register
Error message
could not find %s register
What it means
During handshake, Delve requires the PC, SP, BP and CX register names to be discovered from the stub via qRegisterInfo (lldb) or target.xml (gdb). If any of the four is missing after both lookups, connection setup fails with 'could not find <name> register'.
Source
Thrown at pkg/proc/gdbserial/gdbserver_conn.go:167
regnames.SP: false,
regnames.BP: false,
regnames.CX: false,
}
if err := conn.readRegisterInfo(regFound); err != nil {
if isProtocolErrorUnsupported(err) {
if err := conn.readTargetXml(regFound); err != nil {
return err
}
} else {
return err
}
}
for n := range regFound {
if n == "" {
continue
}
if !regFound[n] {
return fmt.Errorf("could not find %s register", n)
}
}
// We either need:
// * QListThreadsInStopReply + qThreadStopInfo (i.e. lldb-server/debugserver),
// * or a stub that runs the inferior in single threaded mode (i.e. rr).
// Otherwise we'll have problems handling breakpoints in multithreaded programs.
if _, err := conn.exec([]byte("$QListThreadsInStopReply"), "init"); err != nil {
gdberr, ok := err.(*GdbProtocolError)
if !ok {
return err
}
if gdberr.code != "" {
return err
}
}
if resp, err := conn.exec([]byte("$x0,0"), "init"); err == nil && string(resp) == "OK" {View on GitHub (pinned to a23773e6c3)
Solutions
- Verify the stub serves a correct target.xml containing pc/sp/bp/cx equivalents (check with gdb or curl of qXfer:features:read)
- Use an architecture-matching, up-to-date gdbserver/lldb-server
- If you control the stub, add the missing register entries to its target.xml or implement qRegisterInfo fully
- Check Delve's regnames mapping for your architecture in pkg/proc and update Delve if your arch support is newer than your build
Defensive patterns
Strategy: validation
Validate before calling
// verify stub exposes required registers before connecting:
requiredRegs := []string{"pc", "sp", "bp", "cx"} // per-arch regnames
ok := func(targetXml string) bool {
for _, r := range requiredRegs {
if !strings.Contains(targetXml, "name=\""+r+"\"") { return false }
}
return true
} Try / catch
grp, err := client.Connect(pid, path)
if err != nil && strings.Contains(err.Error(), "could not find ") && strings.HasSuffix(err.Error(), " register") {
return fmt.Errorf("stub target.xml is incomplete (%w); use a full-featured stub", err)
} Prevention
- Validate the stub's target.xml/qRegisterInfo exposes pc, sp, bp and cx before deployment
- Use stubs built for the exact target architecture
- Prefer mainstream gdbserver/lldb-server over hand-rolled stubs
- Test the gdbserial handshake in CI for every stub/arch combination you support
When it happens
Trigger: Connecting to a stub whose target.xml or qRegisterInfo responses omit one of the required registers (pc/rip, sp/rsp, bp/rbp, cx/rcx) — e.g. a stub with a minimal or incorrect register description file, or a target.xml for a different architecture.
Common situations: Custom embedded stubs with hand-written target.xml missing CX; stubs for non-x86 architectures where the regname mapping is incomplete; pointing Delve at a stub compiled for the wrong architecture; old gdbserver versions with abbreviated feature files.
Related errors
- could not set register %s: not found
- could not set register %s: wrong size, expected %d got %d
- direction change with internal breakpoints
- can not start a call injection while running backwards
- could not connect
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/055f6b5f651ed6ef.
Report an issue: GitHub.