{"record":{"id":"57f4345bbd95d6a5","repo":"go-delve/delve","slug":"unable-to-determine-current-package-due-to-unspeci","errorCode":null,"errorMessage":"unable to determine current package due to unspecified function location","messagePattern":"unable to determine current package due to unspecified function location","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/debugger/debugger.go","lineNumber":2079,"sourceCode":"\treturn r\n}\n\n// CurrentPackage returns the fully qualified name of the\n// package corresponding to the function location of the\n// current thread.\nfunc (d *Debugger) CurrentPackage() (string, error) {\n\td.targetMutex.Lock()\n\tdefer d.targetMutex.Unlock()\n\n\tif _, err := d.target.Valid(); err != nil {\n\t\treturn \"\", err\n\t}\n\tloc, err := proc.ThreadLocation(d.target.Selected.CurrentThread())\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif loc.Fn == nil {\n\t\treturn \"\", errors.New(\"unable to determine current package due to unspecified function location\")\n\t}\n\treturn loc.Fn.PackageName(), nil\n}\n\n// FindLocation will find the location specified by 'locStr'.\nfunc (d *Debugger) FindLocation(goid int64, frame, deferredCall int, locStr string, includeNonExecutableLines bool, substitutePathRules [][2]string) ([]api.Location, string, error) {\n\td.targetMutex.Lock()\n\tdefer d.targetMutex.Unlock()\n\n\tif _, err := d.target.Valid(); err != nil {\n\t\treturn nil, \"\", err\n\t}\n\n\tloc, err := locspec.Parse(locStr)\n\tif err != nil {\n\t\treturn nil, \"\", err\n\t}\n","sourceCodeStart":2061,"sourceCodeEnd":2097,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/service/debugger/debugger.go#L2061-L2097","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","solutions":["Build the debuggee with full debug info (avoid `-s -w` ldflags; don't use `go run`)","Use a fully qualified location (package.Func or file:line) instead of a relative one","Switch the selected goroutine/frame to a location with known symbols before using relative locations"],"exampleFix":"// before\ndlv exec ./stripped-binary   // no symbols; relative locations fail\ndlv breakpoints main.go:10   // needs current package\n// after\ngo build -gcflags=\"all=-N -l\" -o app .\ndlv exec app\nbreak main.go:10","handlingStrategy":"fallback","validationCode":"loc, err := proc.ThreadLocation(d.target.Selected.CurrentThread())\nif err != nil || loc.Fn == nil {\n    // fall back to fully-qualified locations; don't resolve package-relative ones\n}","typeGuard":"func currentFnKnown(t proc.Thread) bool {\n    loc, err := proc.ThreadLocation(t)\n    return err == nil && loc.Fn != nil\n}","tryCatchPattern":"pkg, err := dbg.CurrentPackage()\nif err != nil {\n    // prompt user for absolute location (pkg.Func or file:line) instead\n}","preventionTips":["Build targets with full debug info; avoid `-s -w` and `go run`","Prefer package-qualified locations in scripts/tools to avoid needing current package","If stopped in runtime/assembly frames, switch frames before relative lookups"],"tags":["symbols","dwarf","location-resolution"],"backgroundTag":"missing-debug-info","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}