NationalSecurityAgency/ghidra · error · IllegalArgumentException
Given platform is not from the current trace
Error message
Given platform is not from the current trace
What it means
Thrown by FlatDebuggerAPI.readRegister(platform, register) when the supplied platform's trace does not match the current trace. Register reads operate on the current debugger coordinates, so the platform must belong to that trace.
Source
Thrown at Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/flatapi/FlatDebuggerAPI.java:1104
* @return the list of register values, or null on error
* @throws IllegalArgumentException if any name is invalid
* @see #readRegisters(TracePlatform, TraceThread, int, long, Collection)
*/
default List<RegisterValue> readRegistersNamed(Collection<String> names) {
return readRegisters(validateRegisterNames(requireCurrentTrace().getBaseLanguage(), names));
}
/**
* Read a register from the current context, refreshing from the target if needed
*
* @param platform the platform whose language defines the register
* @param register the register
* @return the value, or null on error
*/
default RegisterValue readRegister(TracePlatform platform, Register register) {
DebuggerCoordinates current = getCurrentDebuggerCoordinates();
if (platform.getTrace() != current.getTrace()) {
throw new IllegalArgumentException("Given platform is not from the current trace");
}
Language language = platform.getLanguage();
if (!register.equals(language.getRegister(register.getName()))) {
throw new IllegalArgumentException(
"Register " + register + " is not in language " + language);
}
return readRegister(platform, requireThread(current.getThread()), current.getFrame(),
current.getSnap(), register);
}
/**
* Read a register from the current context, refreshing from the target if needed
*
* @param register the register
* @return the value, or null on error
*/
default RegisterValue readRegister(Register register) {
return readRegister(requireCurrentPlatform(), register);View on GitHub (pinned to d5f144c24d)
Solutions
- Obtain the platform from the current trace via getCurrentPlatform().
- Before calling readRegister(), assert platform.getTrace() equals the current trace.
- Discard cached platform references when the active trace changes.
Example fix
// before TracePlatform stale = cachedPlatform; RegisterValue v = readRegister(stale, reg); // throws if trace changed // after TracePlatform platform = getCurrentPlatform(); RegisterValue v = readRegister(platform, reg);
Defensive patterns
Strategy: validation
Validate before calling
DebuggerCoordinates cur = getCurrentDebuggerCoordinates();
if (platform.getTrace() != cur.getTrace()) {
throw new IllegalStateException(
"Platform is not from the current trace");
} Type guard
static boolean platformFromCurrentTrace(FlatDebuggerAPI api,
TracePlatform platform) {
return platform.getTrace() == api.getCurrentDebuggerCoordinates().getTrace();
} Try / catch
try {
RegisterValue v = readRegister(platform, reg);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("current trace")) {
platform = getCurrentPlatform(); // refresh and retry
} else throw e;
} Prevention
- Always obtain the platform via getCurrentPlatform() at call time.
- Discard cached platform references when the active trace changes.
When it happens
Trigger: Calling readRegister(platform, register) where platform.getTrace() differs from getCurrentDebuggerCoordinates().getTrace().
Common situations: Caching a platform object from a previous trace and reusing it after switching targets; passing a platform from a stale trace after a target restart.
Related errors
- Register {} is not in language {}
- There is no platform
- One or more invalid register names: {}
- Invalid register name: {}
- Tool does not have service {cls}! This script should be run
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/2f82a36b351d044a.
Report an issue: GitHub.