go-delve/delve · error
could not determine current location
Error message
could not determine current location
What it means
OffsetLocationSpec.Find maps scope.PC to file/line via PCToLine; if that returns a nil function (the PC is not attributable to any known function), Delve cannot determine the current location to apply the offset to and returns this error.
Source
Thrown at pkg/locspec/locations.go:639
}
return api.Location{PC: addrs[0], PCs: addrs}
}
// Find returns the location after adding the offset amount to the current line number.
func (loc *OffsetLocationSpec) Find(t *proc.Target, _ []string, scope *proc.EvalScope, _ string, includeNonExecutableLines bool, _ [][2]string) ([]api.Location, string, error) {
if scope == nil {
return nil, "", errors.New("could not determine current location (scope is nil)")
}
file, line, fn := scope.BinInfo.PCToLine(scope.PC)
if loc.Offset == 0 {
subst := ""
if fn != nil {
subst = fmt.Sprintf("%s:%d", file, line)
}
return []api.Location{{PC: scope.PC}}, subst, nil
}
if fn == nil {
return nil, "", errors.New("could not determine current location")
}
subst := fmt.Sprintf("%s:%d", file, line+loc.Offset)
addrs, err := proc.FindFileLocation(t, file, line+loc.Offset)
if includeNonExecutableLines {
if _, isCouldNotFindLine := err.(*proc.ErrCouldNotFindLine); isCouldNotFindLine {
return []api.Location{{File: file, Line: line + loc.Offset}}, subst, nil
}
}
return []api.Location{addressesToLocation(addrs)}, subst, err
}
// Find will return the location at the given line in the current file.
func (loc *LineLocationSpec) Find(t *proc.Target, _ []string, scope *proc.EvalScope, _ string, includeNonExecutableLines bool, _ [][2]string) ([]api.Location, string, error) {
if scope == nil {
return nil, "", errors.New("could not determine current location (scope is nil)")
}
file, _, fn := scope.BinInfo.PCToLine(scope.PC)
if fn == nil {View on GitHub (pinned to a23773e6c3)
Solutions
- Move to a frame inside your own Go code (frame up/down) before using relative breakpoints
- Use an absolute file:line breakpoint instead of a line offset
- Ensure the binary was built with debug info (no -w -s) so PCToLine can resolve the PC
Example fix
// before // stopped in runtime.asmcgocall dlv> b +2 // after dlv> frame up dlv> b +2 // or: b main.go:42
Defensive patterns
Strategy: validation
Validate before calling
file, _, fn := scope.BinInfo.PCToLine(scope.PC)
if fn == nil {
return errors.New("current PC has no line info; use an absolute file:line breakpoint")
}
locs, subst, err := loc.Find(t, funcs, scope, locStr, false, nil) Try / catch
locs, _, err := loc.Find(t, funcs, scope, "+2", false, nil)
if err != nil && strings.Contains(err.Error(), "could not determine current location") {
return fmt.Errorf("move to a Go frame or use file:line: %w", err)
} Prevention
- Avoid +N breakpoints while in runtime/assembly/cgo frames
- Build targets with full DWARF info (-gcflags=all=-N -l for dev builds)
- Switch frames (up/down) before relative breakpoints
When it happens
Trigger: Calling Find with a non-nil scope whose PC lies outside known code — e.g. in runtime/asm code, cgo frames, or addresses with no line-table entry.
Common situations: Stepping into assembly or runtime frames and then trying b +N; using offset breakpoints when stopped at a PC in a file without debug line info.
Related errors
- unable to set breakpoint
- ErrTypeNotFound
- entry has no location attribute
- could not determine location (scope is nil)
- could not determine current location (scope is nil)
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/4f57061d80f81964.
Report an issue: GitHub.