{"record":{"id":"33099aba2b3e591d","repo":"NationalSecurityAgency/ghidra","slug":"no-function-contains-pc","errorCode":null,"errorMessage":"No function contains {pc}","messagePattern":"No function contains (.+?)","errorType":"exception","errorClass":"UnwindException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/stack/UnwindAnalysis.java","lineNumber":163,"sourceCode":"\t\tprivate final DijkstraShortestPathsAlgorithm<BlockVertex, BlockEdge> pathFinder;\n\t\tprivate final Set<StackUnwindWarning> warnings = new LinkedHashSet<>();\n\n\t\t/**\n\t\t * Begin analysis for unwinding a frame, knowing only the program counter for that frame\n\t\t * \n\t\t * <p>\n\t\t * This will look up the function containing the program counter. If there's isn't one, then\n\t\t * this analysis cannot proceed.\n\t\t * \n\t\t * @param pc the program counter\n\t\t * @param monitor a monitor for progress and cancellation\n\t\t * @throws CancelledException if the monitor cancels the analysis\n\t\t */\n\t\tpublic AnalysisForPC(Address pc, TaskMonitor monitor) throws CancelledException {\n\t\t\tthis.pc = pc;\n\t\t\tthis.function = program.getFunctionManager().getFunctionContaining(pc);\n\t\t\tif (function == null) {\n\t\t\t\tthrow new UnwindException(\"No function contains \" + pc);\n\t\t\t}\n\t\t\tthis.monitor = monitor;\n\t\t\tthis.graph = new BlockGraph(monitor);\n\t\t\tthis.pathFinder =\n\t\t\t\tnew DijkstraShortestPathsAlgorithm<>(graph, GEdgeWeightMetric.unitMetric());\n\t\t\tthis.pcBlock = new BlockVertex(\n\t\t\t\tUnique.assertAtMostOne(blockModel.getCodeBlocksContaining(pc, monitor)));\n\t\t}\n\n\t\t/**\n\t\t * Compute the shortest path(s) from function entry to the program counter\n\t\t * \n\t\t * @return the paths. There's usually only one\n\t\t * @throws CancelledException if the monitor cancels the analysis\n\t\t */\n\t\tpublic Collection<Deque<BlockEdge>> getEntryPaths() throws CancelledException {\n\t\t\tBlockVertex entryBlock = new BlockVertex(Unique.assertAtMostOne(\n\t\t\t\tblockModel.getCodeBlocksContaining(function.getEntryPoint(), monitor)));","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/stack/UnwindAnalysis.java#L145-L181","documentation":"Thrown by UnwindAnalysis.AnalysisForPC constructor when the program counter address does not fall within any function in the program's FunctionManager. The analysis requires a containing function to build the basic block graph and compute unwind information, so without one, it cannot proceed.","triggerScenarios":"AnalysisForPC constructor calls program.getFunctionManager().getFunctionContaining(pc) which returns null. Occurs when the PC is in a code region that has no defined function — e.g., the address is in the middle of data, in unanalyzed code, or the function boundaries don't cover it.","commonSituations":"Auto-analysis hasn't been run or was incomplete. The PC is in a code cave, jump table, or data region that Ghidra doesn't recognize as code. The function was split or the disassembly created a gap. The program mapping points to the wrong address.","solutions":["Run auto-analysis on the program to create functions covering the PC address.","Manually create a function at or containing the PC address (right-click > Create Function in listing).","Verify the PC value is correct — check that the trace-to-program mapping resolved the right address.","If the address is legitimately not in a function (e.g., JIT, shellcode), define a function there manually."],"exampleFix":"// No code fix; ensure a function exists at the PC:\n// In Ghidra: navigate to PC address > right-click > Create Function\n// Or programmatically:\n// new CreateFunctionCmd(pcAddress).applyTo(program);","handlingStrategy":"validation","validationCode":"// Before calling UnwindAnalysis, verify a function contains the PC:\nFunction fn = program.getFunctionManager().getFunctionContaining(pc);\nif (fn == null) {\n    // trigger auto-analysis or create function before unwinding\n}","typeGuard":"private boolean isPcInFunction(Address pc, Program program) {\n    return program.getFunctionManager().getFunctionContaining(pc) != null;\n}","tryCatchPattern":"try {\n    new AnalysisForPC(pc, monitor).computeUnwindInfo();\n} catch (UnwindException e) {\n    if (e.getMessage().startsWith(\"No function contains\")) {\n        // auto-create function, then retry\n    } else { throw e; }\n}","preventionTips":["Run full auto-analysis before invoking unwind analysis.","Ensure the program mapping resolves the PC to an address within a defined function.","Create functions manually in code regions that auto-analysis missed.","Verify PC values are correct — wrong mappings produce addresses in non-code regions."],"tags":["debugger","unwind-analysis","function-manager","stack-unwinding"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}