{"record":{"id":"055f6b5f651ed6ef","repo":"go-delve/delve","slug":"could-not-find-s-register","errorCode":null,"errorMessage":"could not find %s register","messagePattern":"could not find (.+?) register","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/proc/gdbserial/gdbserver_conn.go","lineNumber":167,"sourceCode":"\t\tregnames.SP: false,\n\t\tregnames.BP: false,\n\t\tregnames.CX: false,\n\t}\n\tif err := conn.readRegisterInfo(regFound); err != nil {\n\t\tif isProtocolErrorUnsupported(err) {\n\t\t\tif err := conn.readTargetXml(regFound); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t} else {\n\t\t\treturn err\n\t\t}\n\t}\n\tfor n := range regFound {\n\t\tif n == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tif !regFound[n] {\n\t\t\treturn fmt.Errorf(\"could not find %s register\", n)\n\t\t}\n\t}\n\n\t// We either need:\n\t//  * QListThreadsInStopReply + qThreadStopInfo (i.e. lldb-server/debugserver),\n\t//  * or a stub that runs the inferior in single threaded mode (i.e. rr).\n\t// Otherwise we'll have problems handling breakpoints in multithreaded programs.\n\tif _, err := conn.exec([]byte(\"$QListThreadsInStopReply\"), \"init\"); err != nil {\n\t\tgdberr, ok := err.(*GdbProtocolError)\n\t\tif !ok {\n\t\t\treturn err\n\t\t}\n\t\tif gdberr.code != \"\" {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif resp, err := conn.exec([]byte(\"$x0,0\"), \"init\"); err == nil && string(resp) == \"OK\" {","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/gdbserial/gdbserver_conn.go#L149-L185","documentation":"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'.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// verify stub exposes required registers before connecting:\nrequiredRegs := []string{\"pc\", \"sp\", \"bp\", \"cx\"} // per-arch regnames\nok := func(targetXml string) bool {\n    for _, r := range requiredRegs {\n        if !strings.Contains(targetXml, \"name=\\\"\"+r+\"\\\"\") { return false }\n    }\n    return true\n}","typeGuard":null,"tryCatchPattern":"grp, err := client.Connect(pid, path)\nif err != nil && strings.Contains(err.Error(), \"could not find \") && strings.HasSuffix(err.Error(), \" register\") {\n    return fmt.Errorf(\"stub target.xml is incomplete (%w); use a full-featured stub\", err)\n}","preventionTips":["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"],"tags":["gdbserial","handshake","register","target-xml"],"backgroundTag":"register-not-found","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}