{"record":{"id":"29457535e8cf4a78","repo":"go-delve/delve","slug":"not-on-topmost-frame","errorCode":null,"errorMessage":"not on topmost frame","messagePattern":"not on topmost frame","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/terminal/command.go","lineNumber":1480,"sourceCode":"func (c *Commands) step(t *Term, ctx callContext, args string) error {\n\tif err := scopePrefixSwitch(t, ctx); err != nil {\n\t\treturn err\n\t}\n\tc.frame = 0\n\tstepfn := t.client.Step\n\tif ctx.Prefix == revPrefix {\n\t\tstepfn = t.client.ReverseStep\n\t}\n\tstate, err := exitedToError(stepfn())\n\tif err != nil {\n\t\tprintcontextNoState(t)\n\t\treturn err\n\t}\n\tprintcontext(t, state)\n\treturn continueUntilCompleteNext(t, state, \"step\", true)\n}\n\nvar errNotOnFrameZero = errors.New(\"not on topmost frame\")\n\n// stepInstruction implements the step-instruction (stepi) command.\nfunc (c *Commands) stepInstruction(t *Term, ctx callContext, args string) error {\n\treturn stepInstruction(t, ctx, c.frame, false)\n}\n\n// nextInstruction implements the next-instruction (nexti) command.\nfunc (c *Commands) nextInstruction(t *Term, ctx callContext, args string) error {\n\treturn stepInstruction(t, ctx, c.frame, true)\n}\n\nfunc stepInstruction(t *Term, ctx callContext, frame int, skipCalls bool) error {\n\tif err := scopePrefixSwitch(t, ctx); err != nil {\n\t\treturn err\n\t}\n\tif frame != 0 {\n\t\treturn errNotOnFrameZero\n\t}","sourceCodeStart":1462,"sourceCodeEnd":1498,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/terminal/command.go#L1462-L1498","documentation":"Stepping commands like 'step' only operate on the topmost (innermost, frame 0) frame of the selected goroutine. errNotOnFrameZero is the sentinel error returned when the currently selected frame is not frame 0. This prevents stepping semantics that only make sense at the leaf of the call stack.","triggerScenarios":"Selecting an older frame with 'frame 3' or 'up' and then running 'step', 'next', 'stepout', etc.: the command checks c.frame (or the selected frame index) and returns errNotOnFrameZero (pkg/terminal/command.go:1480).","commonSituations":"Inspecting a caller frame after a breakpoint and forgetting to switch back with 'frame 0' or 'down' before stepping; IDE-driven stepping while a non-zero frame is selected.","solutions":["Switch back to the topmost frame with 'frame 0' or 'down'","Re-select the goroutine's current frame before stepping","Use 'stack' to confirm which frame is selected"],"exampleFix":"// before\n(frame 2) step\n// after\nframe 0\nstep","handlingStrategy":"validation","validationCode":"// before stepping, ensure frame 0 is selected:\n// run: frame 0   (or verify via 'stack')","typeGuard":null,"tryCatchPattern":"if err := step(...); errors.Is(err, errNotOnFrameZero) || err.Error() == \"not on topmost frame\" { /* issue 'frame 0' then retry */ }","preventionTips":["After 'up'/'frame N', return with 'frame 0' before stepping","Check selected frame with 'stack' prior to step/next/stepout","In IDE integrations, reset frame selection on step commands"],"tags":["terminal","stepping","frame-selection"],"backgroundTag":"wrong-frame-selected","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}