{"record":{"id":"08eaf63bd945f30f","repo":"go-delve/delve","slug":"malformed-breakpoint-location-no-line-offset-spec","errorCode":null,"errorMessage":"Malformed breakpoint location, no line offset specified","messagePattern":"Malformed breakpoint location, no line offset specified","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/locspec/locations.go","lineNumber":427,"sourceCode":"\t\t// expression that the user forgot to prefix with '*', try treating it as\n\t\t// such.\n\t\taddrSpec := &AddrLocationSpec{AddrExpr: locStr}\n\t\tlocs, subst, err := addrSpec.Find(t, processArgs, scope, locStr, includeNonExecutableLines, nil)\n\t\tif err != nil {\n\t\t\treturn nil, \"\", &ErrLocationNotFound{Spec: locStr}\n\t\t}\n\t\treturn locs, subst, nil\n\t} else if matching > 1 {\n\t\treturn nil, \"\", AmbiguousLocationError{Location: locStr, CandidatesString: append(candidateFiles, candidateFuncs...)}\n\t}\n\n\t// len(candidateFiles) + len(candidateFuncs) == 1\n\tvar addrs []uint64\n\tvar err error\n\tif len(candidateFiles) == 1 {\n\t\tif loc.LineOffset < 0 {\n\t\t\t//lint:ignore ST1005 backwards compatibility\n\t\t\treturn nil, \"\", errors.New(\"Malformed breakpoint location, no line offset specified\")\n\t\t}\n\t\taddrs, err = proc.FindFileLocation(t, candidateFiles[0], loc.LineOffset)\n\t\tif includeNonExecutableLines {\n\t\t\tif _, isCouldNotFindLine := err.(*proc.ErrCouldNotFindLine); isCouldNotFindLine {\n\t\t\t\treturn []api.Location{{File: candidateFiles[0], Line: loc.LineOffset}}, \"\", nil\n\t\t\t}\n\t\t}\n\t} else { // len(candidateFuncs) == 1\n\t\taddrs, err = proc.FindFunctionLocation(t, candidateFuncs[0], loc.LineOffset)\n\t}\n\n\tif err != nil {\n\t\treturn nil, \"\", err\n\t}\n\treturn []api.Location{addressesToLocation(addrs)}, \"\", nil\n}\n\nfunc (loc *NormalLocationSpec) findFuncCandidates(bi *proc.BinaryInfo, limit int) []string {","sourceCodeStart":409,"sourceCodeEnd":445,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/locspec/locations.go#L409-L445","documentation":"When a breakpoint location spec reduces to exactly one file (e.g. b file.go: form or a bare file name), Find needs a line number (loc.LineOffset). A negative LineOffset means no line offset was supplied, so Delve cannot compute an address and returns this malformed-location error.","triggerScenarios":"Calling Find with a location spec that resolved to a single candidate file but with LineOffset < 0 — i.e. a spec like \"main.go\" or \":\" without an explicit line number.","commonSituations":"Typing b main.go without a line number in the CLI; constructing a location spec programmatically and forgetting to set LineOffset (default -1).","solutions":["Include a line number in the location string, e.g. b main.go:42","If using the API, set LineOffset to a valid line (>= 0) on the location spec before calling Find","Use a function-name breakpoint (e.g. b main.main) if you want the entry point instead of a line"],"exampleFix":"// before\ndlv> b main.go\n// after\ndlv> b main.go:42","handlingStrategy":"validation","validationCode":"if loc.LineOffset < 0 {\n    return errors.New(\"file-only breakpoint requires a line number: use file.go:<line>\")\n}\nlocs, subst, err := loc.Find(t, funcs, scope, locStr, inclNonExec, dirs)","typeGuard":null,"tryCatchPattern":"locs, _, err := loc.Find(t, funcs, scope, locStr, false, nil)\nif err != nil && strings.Contains(err.Error(), \"no line offset\") {\n    return fmt.Errorf(\"add a line number to the breakpoint location: %w\", err)\n}","preventionTips":["Always include :<line> when specifying a bare file","Initialize LineOffset when constructing specs programmatically","Use function-based breakpoints to break at a file's first executable line"],"tags":["breakpoints","location-spec"],"backgroundTag":"malformed-breakpoint-location","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}