NationalSecurityAgency/ghidra · error · IllegalArgumentException

Invalid register name: {}

Error message

Invalid register name: {}

What it means

Thrown by FlatDebuggerAPI.validateRegisterName(language, name) when the single supplied register name does not exist in the given language. This is the single-name counterpart to the bulk validator.

Source

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

		}
		if (!invalid.isEmpty()) {
			throw new IllegalArgumentException("One or more invalid register names: " + invalid);
		}
		return result;
	}

	/**
	 * Validate and retrieve the name register
	 * 
	 * @param language the language defining the register
	 * @param name the name
	 * @return the register
	 * @throws IllegalArgumentException if the name is invalid
	 */
	default Register validateRegisterName(Language language, String name) {
		Register register = language.getRegister(name);
		if (register == null) {
			throw new IllegalArgumentException("Invalid register name: " + name);
		}
		return register;
	}

	/**
	 * Read several registers from the current context, refreshing from the target if needed
	 * 
	 * @param names the source register names
	 * @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

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Check language.getRegister(name) != null before calling validateRegisterName().
  2. Use language.getRegister(name) directly instead of the validator if you just need the register.
  3. Confirm the register name is correct for the platform's architecture.

Example fix

// before
Register r = validateRegisterName(lang, "r15x"); // typo, throws

// after
String name = "r15";
if (lang.getRegister(name) == null) {
    println("Unknown register: " + name);
    return;
}
Register r = validateRegisterName(lang, name);
Defensive patterns

Strategy: validation

Validate before calling

if (language.getRegister(name) == null) {
    println("Unknown register: " + name);
    return;
}

Type guard

static boolean isValidRegisterName(Language lang, String name) {
    return lang.getRegister(name) != null;
}

Try / catch

try {
    Register r = validateRegisterName(lang, name);
} catch (IllegalArgumentException e) {
    if (e.getMessage().startsWith("Invalid register name")) {
        // list valid registers for the user, then retry
    } else throw e;
}

Prevention

When it happens

Trigger: Calling validateRegisterName(lang, name) where language.getRegister(name) returns null.

Common situations: Architecture mismatch (register name from a different ISA); typo in the register name; the register is not exposed by this particular language definition.

Related errors


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