{"record":{"id":"75c8a17b414ccacb","repo":"NationalSecurityAgency/ghidra","slug":"there-is-no-current-trace","errorCode":null,"errorMessage":"There is no current trace","messagePattern":"There is no current trace","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/flatapi/FlatDebuggerAPI.java","lineNumber":180,"sourceCode":"\t * Get the current trace\n\t * \n\t * @see #getCurrentDebuggerCoordinates()\n\t * @return the trace, or null\n\t */\n\tdefault Trace getCurrentTrace() {\n\t\treturn getTraceManager().getCurrentTrace();\n\t}\n\n\t/**\n\t * Get the current trace, throwing an exception if there isn't one\n\t * \n\t * @return the trace\n\t * @throws IllegalStateException if there is no current trace\n\t */\n\tdefault Trace requireCurrentTrace() {\n\t\tTrace trace = getCurrentTrace();\n\t\tif (trace == null) {\n\t\t\tthrow new IllegalStateException(\"There is no current trace\");\n\t\t}\n\t\treturn trace;\n\t}\n\n\t/**\n\t * Require that the given trace is not null\n\t * \n\t * @param trace the trace\n\t * @return the trace\n\t * @throws IllegalStateException if the trace is null\n\t */\n\tdefault Trace requireTrace(Trace trace) {\n\t\tif (trace == null) {\n\t\t\tthrow new IllegalStateException(\"There is no trace\");\n\t\t}\n\t\treturn trace;\n\t}\n","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/flatapi/FlatDebuggerAPI.java#L162-L198","documentation":"Thrown by FlatDebuggerAPI.requireCurrentTrace() when the trace manager has no currently-active trace. Many flat debugger operations (reading memory, registers, stepping) require a target trace to be open and selected.","triggerScenarios":"Calling requireCurrentTrace() (directly or via methods like readMemory that call it) when no trace is loaded, or before the first target has been launched/attached.","commonSituations":"Calling flat API methods before launching or attaching a target; after a target's trace was closed; running a script at a point in the lifecycle where no trace is active yet.","solutions":["Ensure a target is launched/attached and a trace is open before calling trace-dependent methods.","Guard with getCurrentTrace() != null before calling requireCurrentTrace().","Check the trace manager's open traces and prompt the user to open one if empty."],"exampleFix":"// before\nTrace t = requireCurrentTrace(); // throws if none\n\n// after\nTrace t = getCurrentTrace();\nif (t == null) {\n    println(\"Open or launch a target first\");\n    return;\n}\nrequireTrace(t);","handlingStrategy":"type-guard","validationCode":"Trace t = getCurrentTrace();\nif (t == null) {\n    println(\"No active trace; launch/attach a target first\");\n    return;\n}","typeGuard":"static boolean hasCurrentTrace(FlatDebuggerAPI api) {\n    return api.getCurrentTrace() != null;\n}","tryCatchPattern":"try {\n    Trace t = requireCurrentTrace();\n} catch (IllegalStateException e) {\n    if (e.getMessage().equals(\"There is no current trace\")) {\n        // prompt user to launch/attach, then retry\n    } else throw e;\n}","preventionTips":["Check getCurrentTrace() != null at script start before trace-dependent work.","Ensure a target is attached/launched before running trace-dependent methods."],"tags":["flat-debugger-api","trace","state","debugger"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}