Merge remote-tracking branch 'origin/GP-1772_correct_langauge_usage'

Conflicts:
	Ghidra/Features/Base/ghidra_scripts/ReloadSleighLangauge.java
This commit is contained in:
Ryan Kurtz 2022-05-06 14:30:24 -04:00
commit 5e6c267093
8 changed files with 54 additions and 11 deletions

View file

@ -245,7 +245,7 @@ public class WatchRow {
Language newLanguage = trace.getBaseLanguage(); Language newLanguage = trace.getBaseLanguage();
if (language != newLanguage) { if (language != newLanguage) {
if (!(newLanguage instanceof SleighLanguage)) { if (!(newLanguage instanceof SleighLanguage)) {
error = new RuntimeException("Not a sleigh-based langauge"); error = new RuntimeException("Not a sleigh-based language");
return; return;
} }
language = (SleighLanguage) newLanguage; language = (SleighLanguage) newLanguage;

View file

@ -37,7 +37,7 @@ public class DBTraceData extends AbstractDBTraceCodeUnit<DBTraceData>
implements DBTraceDefinedDataAdapter { implements DBTraceDefinedDataAdapter {
private static final String TABLE_NAME = "Data"; private static final String TABLE_NAME = "Data";
static final String LANGUAGE_COLUMN_NAME = "Langauge"; static final String LANGUAGE_COLUMN_NAME = "Language";
static final String DATATYPE_COLUMN_NAME = "DataType"; static final String DATATYPE_COLUMN_NAME = "DataType";
@DBAnnotatedColumn(LANGUAGE_COLUMN_NAME) @DBAnnotatedColumn(LANGUAGE_COLUMN_NAME)
@ -75,7 +75,7 @@ public class DBTraceData extends AbstractDBTraceCodeUnit<DBTraceData>
} }
language = space.manager.languageManager.getLanguageByKey(langKey); language = space.manager.languageManager.getLanguageByKey(langKey);
if (language == null) { if (language == null) {
throw new IOException("Data table is corrupt. Missing langauge: " + langKey); throw new IOException("Data table is corrupt. Missing language: " + langKey);
} }
dataType = space.dataTypeManager.getDataType(dataTypeID); dataType = space.dataTypeManager.getDataType(dataTypeID);
if (dataType == null) { if (dataType == null) {

View file

@ -55,7 +55,7 @@ public class DBTraceLanguageManagerTest extends AbstractGhidraHeadlessIntegratio
} }
@Test @Test
public void testAddGuestLangauge() throws LanguageNotFoundException { public void testAddGuestLanguage() throws LanguageNotFoundException {
try (UndoableTransaction tid = b.startTransaction()) { try (UndoableTransaction tid = b.startTransaction()) {
assertEquals(0, manager.languageStore.getRecordCount()); assertEquals(0, manager.languageStore.getRecordCount());
manager.addGuestLanguage(b.getLanguage("x86:LE:32:default")); manager.addGuestLanguage(b.getLanguage("x86:LE:32:default"));

View file

@ -0,0 +1,43 @@
/* ###
* IP: GHIDRA
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Reloads the language specification associated with a program at runtime.
// @category sleigh
import ghidra.app.script.GhidraScript;
import ghidra.program.model.lang.Language;
import ghidra.util.Msg;
import java.io.IOException;
public class ReloadSleighLanguage extends GhidraScript {
@Override
public void run() throws Exception {
if (currentProgram == null) {
return;
}
Language language = currentProgram.getLanguage();
try {
language.reloadLanguage(monitor);
}
catch (IOException e) {
Msg.showError(this, this.state.getParamPanel(), "Reload Sleigh Language Failed",
e.getMessage());
return;
}
currentProgram.setLanguage(language, currentProgram.getCompilerSpec().getCompilerSpecID(),
true, monitor);
}
}

View file

@ -274,7 +274,7 @@ class ProgramUserDataDB extends DomainObjectAdapterDB implements ProgramUserData
/** /**
* Language specified by languageName was not found. Check for * Language specified by languageName was not found. Check for
* valid language translation/migration. Old langauge version specified by * valid language translation/migration. Old language version specified by
* languageVersion. * languageVersion.
* @param openMode one of: * @param openMode one of:
* READ_ONLY: the original database will not be modified * READ_ONLY: the original database will not be modified

View file

@ -1711,10 +1711,10 @@ public class Disassembler implements DisassemblerConflictHandler {
private static class InstructionContext implements ProcessorContext { private static class InstructionContext implements ProcessorContext {
private RegisterValue contextValue; private RegisterValue contextValue;
private Language langauge; private Language language;
InstructionContext(Language language, RegisterValue contextValue) { InstructionContext(Language language, RegisterValue contextValue) {
this.langauge = language; this.language = language;
this.contextValue = contextValue; this.contextValue = contextValue;
} }
@ -1729,12 +1729,12 @@ public class Disassembler implements DisassemblerConflictHandler {
@Override @Override
public List<Register> getRegisters() { public List<Register> getRegisters() {
return langauge.getRegisters(); return language.getRegisters();
} }
@Override @Override
public Register getRegister(String name) { public Register getRegister(String name) {
return langauge.getRegister(name); return language.getRegister(name);
} }
@Override @Override

View file

@ -167,7 +167,7 @@ public class RegisterBuilder {
} }
/** /**
* Rename a register. This allows generic register names declared within the langauge * Rename a register. This allows generic register names declared within the language
* specification (*.slaspec) to be renamed for a processor variant specification (*.pspec). * specification (*.slaspec) to be renamed for a processor variant specification (*.pspec).
* @param oldName original register name * @param oldName original register name
* @param newName new register name * @param newName new register name

View file

@ -214,7 +214,7 @@ public class OldLanguageFactory {
LanguageService languageService = DefaultLanguageService.getLanguageService(); LanguageService languageService = DefaultLanguageService.getLanguageService();
if (lang instanceof OldLanguage) { if (lang instanceof OldLanguage) {
throw new LanguageNotFoundException( throw new LanguageNotFoundException(
"Can't create an Old Langauge file from an OldLanguage"); "Can't create an Old Language file from an OldLanguage");
} }
LanguageDescription languageDescription = LanguageDescription languageDescription =
languageService.getLanguageDescription(lang.getLanguageID()); languageService.getLanguageDescription(lang.getLanguageID());