NationalSecurityAgency/ghidra · error · IllegalStateException

There is no current trace

Error message

There is no current trace

What it means

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.

Source

Thrown at Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/flatapi/FlatDebuggerAPI.java:180

	 * Get the current trace
	 * 
	 * @see #getCurrentDebuggerCoordinates()
	 * @return the trace, or null
	 */
	default Trace getCurrentTrace() {
		return getTraceManager().getCurrentTrace();
	}

	/**
	 * Get the current trace, throwing an exception if there isn't one
	 * 
	 * @return the trace
	 * @throws IllegalStateException if there is no current trace
	 */
	default Trace requireCurrentTrace() {
		Trace trace = getCurrentTrace();
		if (trace == null) {
			throw new IllegalStateException("There is no current trace");
		}
		return trace;
	}

	/**
	 * Require that the given trace is not null
	 * 
	 * @param trace the trace
	 * @return the trace
	 * @throws IllegalStateException if the trace is null
	 */
	default Trace requireTrace(Trace trace) {
		if (trace == null) {
			throw new IllegalStateException("There is no trace");
		}
		return trace;
	}

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Ensure a target is launched/attached and a trace is open before calling trace-dependent methods.
  2. Guard with getCurrentTrace() != null before calling requireCurrentTrace().
  3. Check the trace manager's open traces and prompt the user to open one if empty.

Example fix

// before
Trace t = requireCurrentTrace(); // throws if none

// after
Trace t = getCurrentTrace();
if (t == null) {
    println("Open or launch a target first");
    return;
}
requireTrace(t);
Defensive patterns

Strategy: type-guard

Validate before calling

Trace t = getCurrentTrace();
if (t == null) {
    println("No active trace; launch/attach a target first");
    return;
}

Type guard

static boolean hasCurrentTrace(FlatDebuggerAPI api) {
    return api.getCurrentTrace() != null;
}

Try / catch

try {
    Trace t = requireCurrentTrace();
} catch (IllegalStateException e) {
    if (e.getMessage().equals("There is no current trace")) {
        // prompt user to launch/attach, then retry
    } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/75c8a17b414ccacb. Report an issue: GitHub.