go-delve/delve · error

unable to determine current package due to unspecified funct

Error message

unable to determine current package due to unspecified function location

What it means

To determine the current package, Delve inspects the function containing the selected thread's current PC. If ThreadLocation succeeds but reports no function (loc.Fn == nil) — meaning the symbols for the current PC are unknown — the package cannot be determined and this error is returned.

Source

Thrown at service/debugger/debugger.go:2079

	return r
}

// CurrentPackage returns the fully qualified name of the
// package corresponding to the function location of the
// current thread.
func (d *Debugger) CurrentPackage() (string, error) {
	d.targetMutex.Lock()
	defer d.targetMutex.Unlock()

	if _, err := d.target.Valid(); err != nil {
		return "", err
	}
	loc, err := proc.ThreadLocation(d.target.Selected.CurrentThread())
	if err != nil {
		return "", err
	}
	if loc.Fn == nil {
		return "", errors.New("unable to determine current package due to unspecified function location")
	}
	return loc.Fn.PackageName(), nil
}

// FindLocation will find the location specified by 'locStr'.
func (d *Debugger) FindLocation(goid int64, frame, deferredCall int, locStr string, includeNonExecutableLines bool, substitutePathRules [][2]string) ([]api.Location, string, error) {
	d.targetMutex.Lock()
	defer d.targetMutex.Unlock()

	if _, err := d.target.Valid(); err != nil {
		return nil, "", err
	}

	loc, err := locspec.Parse(locStr)
	if err != nil {
		return nil, "", err
	}

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Build the debuggee with full debug info (avoid `-s -w` ldflags; don't use `go run`)
  2. Use a fully qualified location (package.Func or file:line) instead of a relative one
  3. Switch the selected goroutine/frame to a location with known symbols before using relative locations

Example fix

// before
dlv exec ./stripped-binary   // no symbols; relative locations fail
dlv breakpoints main.go:10   // needs current package
// after
go build -gcflags="all=-N -l" -o app .
dlv exec app
break main.go:10
Defensive patterns

Strategy: fallback

Validate before calling

loc, err := proc.ThreadLocation(d.target.Selected.CurrentThread())
if err != nil || loc.Fn == nil {
    // fall back to fully-qualified locations; don't resolve package-relative ones
}

Type guard

func currentFnKnown(t proc.Thread) bool {
    loc, err := proc.ThreadLocation(t)
    return err == nil && loc.Fn != nil
}

Try / catch

pkg, err := dbg.CurrentPackage()
if err != nil {
    // prompt user for absolute location (pkg.Func or file:line) instead
}

Prevention

When it happens

Trigger: Calling the currentPackage helper (used by functions like FindLocation's package-relative path resolution) when the current thread's PC is in code without debug symbols, or the current thread is nil/invalid so ThreadLocation yields a location with no Fn.

Common situations: Stopping in runtime frames, assembly, or third-party code stripped of debug info; debugging binaries built with -ldflags="-s -w"; being stopped while the thread is not at a valid user frame (e.g. in a signal trampoline).

Related errors


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