{"record":{"id":"bc9304f55982b6af","repo":"go-delve/delve","slug":"could-not-find-call-instruction-for-address-x-in","errorCode":null,"errorMessage":"could not find CALL instruction for address %#x in %s","messagePattern":"could not find CALL instruction for address %#x in (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/target_exec.go","lineNumber":1492,"sourceCode":"\n\treturn deferpc, nil\n}\n\n// findCallInstrForRet returns the PC address of the CALL instruction\n// immediately preceding the instruction at ret.\nfunc findCallInstrForRet(p Process, mem MemoryReadWriter, ret uint64, fn *Function) (uint64, error) {\n\ttext, err := disassemble(mem, nil, p.Breakpoints(), p.BinInfo(), fn.Entry, fn.End, false)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tvar prevInstr AsmInstruction\n\tfor _, instr := range text {\n\t\tif instr.Loc.PC == ret {\n\t\t\treturn prevInstr.Loc.PC, nil\n\t\t}\n\t\tprevInstr = instr\n\t}\n\treturn 0, fmt.Errorf(\"could not find CALL instruction for address %#x in %s\", ret, fn.Name)\n}\n\n// stepOutReverse sets a breakpoint on the CALL instruction that created the current frame, this is either:\n//   - the CALL instruction immediately preceding the return address of the\n//     current frame\n//   - the return address of the current frame if the current frame was\n//     created by a runtime.deferreturn run\n//   - the return address of the runtime.gopanic frame if the current frame\n//     was created by a panic\n//\n// This function is used to implement reversed StepOut\nfunc stepOutReverse(p *Target, topframe, retframe Stackframe, sameGCond ast.Expr) error {\n\tcurthread := p.CurrentThread()\n\tselg := p.SelectedGoroutine()\n\n\tif selg != nil && selg.Thread != nil {\n\t\tcurthread = selg.Thread\n\t}","sourceCodeStart":1474,"sourceCodeEnd":1510,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/target_exec.go#L1474-L1510","documentation":"When stepping out in reverse (reverse step-out / reverse next), Delve must find the CALL instruction immediately preceding the return address in the caller's function disassembly. If it disassembles the function text and no instruction's PC equals the frame's return address (or no preceding CALL exists), it cannot place the reverse-step breakpoint and returns this error.","triggerScenarios":"Calling StepOut in reverse (or reverse Next crossing a frame boundary) via findCallInstrForRet, where the return address 'ret' of the current frame does not appear as an instruction PC within the disassembly text of fn.","commonSituations":"Reverse debugging (RecordGeneratebackwards via rr) over functions whose call sites were inlined or optimized so the return address does not match a disassembled instruction boundary; tail-call optimized frames; stale or mis-decoded instruction text.","solutions":["Re-run under rr with optimizations disabled (build with -gcflags=\"-N -l\") so return addresses land on decoded instruction boundaries","Avoid reverse step-out/next over code containing tail calls or hand-written assembly where no CALL precedes the return address","Re-record the execution trace (rr record) if the binary changed after recording, causing disassembly/PC mismatch","Fall back to forward stepping (non-reverse) for frames in optimized or assembly code"],"exampleFix":"// before: reverse step-out over optimized code\n//   dlv: (stepout -) with binary built with optimizations\n// after: rebuild for deterministic reverse stepping\n//   go build -gcflags=\"all=-N -l\" && rr record ./app && dlv connect :2345","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := doReverseStepOut()\nif err != nil && strings.Contains(err.Error(), \"could not find CALL instruction\") {\n    // fall back to forward stepping from the current frame\n    return doStepOut()\n}","preventionTips":["Record and debug with unoptimized builds (-gcflags=\"all=-N -l\")","Avoid reverse step-out over tail calls, assembly, or inlined call sites","Re-record rr traces whenever the binary is rebuilt","Use forward stepping when the frame's caller is not ordinary Go code"],"tags":["reverse-execution","disassembly","stepping"],"backgroundTag":"call-instruction-not-found","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}