{"record":{"id":"5184b6d0ddf0148b","repo":"NationalSecurityAgency/ghidra","slug":"there-is-no-current-program","errorCode":null,"errorMessage":"There is no current program","messagePattern":"There is no current program","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/flatapi/FlatDebuggerAPI.java","lineNumber":517,"sourceCode":"\t * This is implemented by virtue of extending {@link FlatProgramAPI}, which is inherited via\n\t * {@link GhidraScript}.\n\t * \n\t * @return the current program\n\t */\n\tdefault Program getCurrentProgram() {\n\t\treturn getState().getCurrentProgram();\n\t}\n\n\t/**\n\t * Get the current program, throwing an exception if there isn't one.\n\t * \n\t * @return the current program\n\t * @throws IllegalStateException if there is no current program\n\t */\n\tdefault Program requireCurrentProgram() {\n\t\tProgram program = getCurrentProgram();\n\t\tif (program == null) {\n\t\t\tthrow new IllegalStateException(\"There is no current program\");\n\t\t}\n\t\treturn program;\n\t}\n\n\t/**\n\t * Translate the given static location to the corresponding dynamic location\n\t * \n\t * <p>\n\t * This uses the trace's static mappings (see {@link Trace#getStaticMappingManager()} and\n\t * {@link DebuggerStaticMappingService}) to translate a static location to the corresponding\n\t * dynamic location in the current trace. If there is no current trace or the location cannot be\n\t * translated to the current trace, the result is null. This accommodates link-load-time\n\t * relocation, particularly from address-space layout randomization (ASLR).\n\t * \n\t * @param location the static location, e.g., from {@link #staticLocation(String)}\n\t * @return the dynamic location, or null if not translated\n\t */\n\tdefault ProgramLocation translateStaticToDynamic(ProgramLocation location) {","sourceCodeStart":499,"sourceCodeEnd":535,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/flatapi/FlatDebuggerAPI.java#L499-L535","documentation":"Thrown by FlatDebuggerAPI.requireCurrentProgram() when there is no current static program (the Ghidra Program being analyzed, distinct from a dynamic trace view). This is the standard CodeBrowser program, used for static-to-dynamic mapping.","triggerScenarios":"Calling requireCurrentProgram() when getState().getCurrentProgram() returns null.","commonSituations":"No program imported/open in the tool; running a script that assumes a static program is open but none is; program was closed before the script ran.","solutions":["Open or import a program in the tool before running the script.","Guard with getCurrentProgram() != null before calling requireCurrentProgram().","For static/dynamic mapping flows, ensure a static program is loaded alongside the trace."],"exampleFix":"// before\nProgram p = requireCurrentProgram(); // throws if none\n\n// after\nProgram p = getCurrentProgram();\nif (p == null) {\n    println(\"Open a program first\");\n    return;\n}","handlingStrategy":"type-guard","validationCode":"Program p = getCurrentProgram();\nif (p == null) {\n    println(\"No current program; open/import one first\");\n    return;\n}","typeGuard":"static boolean hasCurrentProgram(FlatDebuggerAPI api) {\n    return api.getCurrentProgram() != null;\n}","tryCatchPattern":"try {\n    Program p = requireCurrentProgram();\n} catch (IllegalStateException e) {\n    if (e.getMessage().equals(\"There is no current program\")) {\n        // prompt to open a program, then retry\n    } else throw e;\n}","preventionTips":["Open or import a static program before running static-mapping scripts.","Check getCurrentProgram() != null as a precondition."],"tags":["flat-debugger-api","program","state","debugger"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}