NationalSecurityAgency/ghidra · error · IllegalArgumentException

One or more invalid register names: {}

Error message

One or more invalid register names: {}

What it means

Thrown by the bulk register-name validation method when one or more of the supplied register names are not defined in the given language. It collects all invalid names and reports them together.

Source

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

	 * @param language the language defining the registers
	 * @param names the names
	 * @return the registers, in the same order
	 * @throws IllegalArgumentException if any name is invalid
	 */
	default List<Register> validateRegisterNames(Language language, Collection<String> names) {
		List<String> invalid = new ArrayList<>();
		List<Register> result = new ArrayList<>();
		for (String n : names) {
			Register register = language.getRegister(n);
			if (register != null) {
				result.add(register);
			}
			else {
				invalid.add(n);
			}
		}
		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;

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Query language.getRegisters() to enumerate valid register names before calling.
  2. Filter input names against the language's register set, removing or correcting unknown ones.
  3. Confirm the platform/language matches the architecture whose register names you are using.

Example fix

// before
List<Register> regs = validateRegisters(lang, Arrays.asList("RAX","FOOBAR")); // throws

// after
Set<String> valid = lang.getRegisters().stream()
    .map(Register::getName).collect(Collectors.toSet());
List<String> names = requested.stream().filter(valid::contains).toList();
List<Register> regs = validateRegisters(lang, names);
Defensive patterns

Strategy: validation

Validate before calling

Set<String> valid = language.getRegisters().stream()
    .map(Register::getName)
    .collect(Collectors.toSet());
List<String> bad = names.stream().filter(n -> !valid.contains(n)).toList();
if (!bad.isEmpty()) {
    throw new IllegalStateException("Invalid registers: " + bad);
}

Type guard

static boolean allValidRegisters(Language lang, Collection<String> names) {
    return names.stream().allMatch(n -> lang.getRegister(n) != null);
}

Try / catch

try {
    List<Register> regs = validateRegisters(lang, names);
} catch (IllegalArgumentException e) {
    if (e.getMessage().startsWith("One or more invalid register names")) {
        // filter names against lang.getRegisters() and retry
    } else throw e;
}

Prevention

When it happens

Trigger: Calling the registers-validation method with a collection of names where at least one does not map to a Register in the platform's language.

Common situations: Using register names from a different architecture (e.g., x86 names on ARM); typos in register names; version differences where a register was renamed or removed; passing generic names not present in the specific language definition.

Related errors


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