{"record":{"id":"2798215856a58327","repo":"go-delve/delve","slug":"could-not-determine-executable-path-v","errorCode":null,"errorMessage":"could not determine executable path: %v","messagePattern":"could not determine executable path: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/gdbserial/gdbserver.go","lineNumber":719,"sourceCode":"func (p *gdbProcess) initialize(path, cmdline string, debugInfoDirs []string, stopReason proc.StopReason) (*proc.TargetGroup, error) {\n\tvar err error\n\tif path == \"\" {\n\t\t// If we are attaching to a running process and the user didn't specify\n\t\t// the executable file manually we must ask the stub for it.\n\t\t// We support both qXfer:exec-file:read:: (the gdb way) and calling\n\t\t// qProcessInfo (the lldb way).\n\t\t// Unfortunately debugserver on macOS supports neither.\n\t\tpath, err = p.conn.readExecFile()\n\t\tif err != nil {\n\t\t\tif isProtocolErrorUnsupported(err) {\n\t\t\t\t_, path, err = queryProcessInfo(p, p.Pid())\n\t\t\t\tif err != nil {\n\t\t\t\t\tp.conn.conn.Close()\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tp.conn.conn.Close()\n\t\t\t\treturn nil, fmt.Errorf(\"could not determine executable path: %v\", err)\n\t\t\t}\n\t\t}\n\t}\n\n\tif path == \"\" {\n\t\t// try using jGetLoadedDynamicLibrariesInfos which is the only way to do\n\t\t// this supported on debugserver (but only on macOS >= 12.10)\n\t\timages, _ := p.conn.getLoadedDynamicLibraries()\n\t\tfor _, image := range images {\n\t\t\tif image.MachHeader.FileType == macho.TypeExec {\n\t\t\t\tpath = image.Pathname\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\terr = p.updateThreadList(&threadUpdater{p: p}, nil)\n\tif err != nil {","sourceCodeStart":701,"sourceCodeEnd":737,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/gdbserial/gdbserver.go#L701-L737","documentation":"During gdbserial connection initialization, Delve must learn the inferior's executable path when the user did not supply one (attach mode). It first tries qXfer:exec-file:read (gdb way), then qProcessInfo (lldb way); if a non-'unsupported' protocol error comes back from readExecFile, the connection is closed and this error is thrown wrapping the underlying cause.","triggerScenarios":"Connecting to a stub (gdbserver/debugserver/lldb-server/rr) in attach mode with an empty executable path where the qXfer:exec-file:read packet fails with a real protocol error (not a plain 'unsupported' reply) — e.g. malformed stub reply, connection-level failure, or a stub that returns an error other than the empty unsupported response.","commonSituations":"Attaching to a process through a nonstandard or buggy GDB remote stub; a stub that replies to qXfer:exec-file with an error string instead of the expected empty/unsupported packet; custom or older debugserver builds; networked gdbserver connections that corrupt replies.","solutions":["Pass the executable path explicitly when attaching (dlv attach <pid> with the binary, or the gdbserial API's path argument) so readExecFile is never called","Check the wrapped '%v' cause to see the actual protocol error and fix the stub/connection","Use a known-good stub (recent gdbserver, lldb-server, or macOS debugserver) that supports qXfer:exec-file:read or qProcessInfo","Verify the connection is stable (no proxy/firewall mangling packets) since transport errors surface here"],"exampleFix":"// before\ntarget, err := client.Connect(pid, \"\") // empty path forces exec-file query\n// after\ntarget, err := client.Connect(pid, \"/path/to/inferior\") // path supplied, no exec-file lookup","handlingStrategy":"validation","validationCode":"if path == \"\" {\n    if fi, err := os.Stat(fmt.Sprintf(\"/proc/%d/exe\", pid)); err == nil {\n        path, _ = os.Readlink(fmt.Sprintf(\"/proc/%d/exe\", pid))\n    }\n}\n// pass resolved path to Connect so readExecFile is skipped","typeGuard":null,"tryCatchPattern":"tgt, err := client.Connect(pid, path)\nif err != nil && strings.Contains(err.Error(), \"could not determine executable path\") {\n    // fall back: supply the path explicitly and reconnect\n    tgt, err = client.Connect(pid, resolvedPath)\n}","preventionTips":["Always pass the executable path explicitly when attaching","Verify the stub supports qXfer:exec-file:read or qProcessInfo before connect","Read the wrapped cause (%v) to distinguish protocol bugs from unsupported features","Test attachments against your stub version in CI"],"tags":["gdbserial","attach","executable-path","protocol"],"backgroundTag":"executable-path-not-determined","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}