go-delve/delve · error

could not attach to pid %d: %s

Error message

could not attach to pid %d: %s

What it means

Error "could not attach to pid %d: %s" thrown in go-delve/delve.

Source

Thrown at service/debugger/debugger.go:2570

	case "linux", "freebsd":
		exe, err = elf.NewFile(f)
	case "windows":
		exe, err = pe.NewFile(f)
	default:
		panic("attempting to open file Delve cannot parse")
	}

	if err != nil {
		return "", api.ErrNotExecutable
	}
	exe.Close()
	return fullpath, nil
}

var attachErrorMessage = attachErrorMessageDefault

func attachErrorMessageDefault(pid int, err error) error {
	return fmt.Errorf("could not attach to pid %d: %s", pid, err)
}

func (d *Debugger) maybePrintUnattendedStopWarning(stopReason proc.StopReason, currentThread *api.Thread, clientStatusCh <-chan struct{}) {
	select {
	case <-clientStatusCh:
		// the channel will be closed if the client that sends the command has left
		// i.e. closed the connection.
	default:
		return
	}

	if currentThread == nil || currentThread.Breakpoint == nil {
		switch stopReason {
		case proc.StopManual:
			// print nothing
			return
		default:
			fmt.Fprintln(os.Stderr, "Stop reason: "+stopReason.String())

View on GitHub (pinned to a23773e6c3)

When it happens

Trigger: Thrown at service/debugger/debugger.go:2570 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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