mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-10-23 13:41:04 +00:00
Merge remote-tracking branch 'origin/GP-1216_emteere_additionalFixes' into patch
This commit is contained in:
commit
caaa28c23d
|
@ -61,7 +61,7 @@ public class DebuggerTracePcodeEmulator extends TracePcodeEmulator {
|
|||
protected BytesPcodeThread createThread(String name) {
|
||||
BytesPcodeThread thread = super.createThread(name);
|
||||
Register contextreg = language.getContextBaseRegister();
|
||||
if (contextreg != null && !isRegisterKnown(name, contextreg)) {
|
||||
if (contextreg != Register.NO_CONTEXT && !isRegisterKnown(name, contextreg)) {
|
||||
RegisterValue context = trace.getRegisterContextManager()
|
||||
.getValueWithDefault(language, contextreg, snap, thread.getCounter());
|
||||
thread.overrideContext(context);
|
||||
|
@ -71,8 +71,7 @@ public class DebuggerTracePcodeEmulator extends TracePcodeEmulator {
|
|||
|
||||
@Override
|
||||
protected PcodeExecutorState<byte[]> createMemoryState() {
|
||||
return new ReadsTargetMemoryPcodeExecutorState(tool, trace, snap, null, 0,
|
||||
recorder);
|
||||
return new ReadsTargetMemoryPcodeExecutorState(tool, trace, snap, null, 0, recorder);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package ghidra.trace.database.listing;
|
||||
|
||||
import static ghidra.lifecycle.Unfinished.TODO;
|
||||
import static ghidra.lifecycle.Unfinished.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
|
@ -149,7 +149,7 @@ public class DBTraceCodeManager
|
|||
static RegisterValue getBaseContextValue(Language language, byte[] context,
|
||||
Address address) {
|
||||
Register register = language.getContextBaseRegister();
|
||||
if (register == null) {
|
||||
if (register == Register.NO_CONTEXT) {
|
||||
return null;
|
||||
}
|
||||
if (context == null) {
|
||||
|
@ -193,8 +193,7 @@ public class DBTraceCodeManager
|
|||
|
||||
protected final Map<AddressSnap, UndefinedDBTraceData> undefinedCache =
|
||||
CacheBuilder.newBuilder()
|
||||
.removalListener(
|
||||
this::undefinedRemovedFromCache)
|
||||
.removalListener(this::undefinedRemovedFromCache)
|
||||
.weakValues()
|
||||
.build()
|
||||
.asMap();
|
||||
|
@ -356,8 +355,8 @@ public class DBTraceCodeManager
|
|||
}
|
||||
monitor.setMessage("Clearing instruction prototypes");
|
||||
monitor.setMaximum(protoStore.getRecordCount());
|
||||
for (Iterator<DBTraceCodePrototypeEntry> it =
|
||||
protoStore.asMap().values().iterator(); it.hasNext();) {
|
||||
for (Iterator<DBTraceCodePrototypeEntry> it = protoStore.asMap().values().iterator(); it
|
||||
.hasNext();) {
|
||||
monitor.checkCanceled();
|
||||
monitor.incrementProgress(1);
|
||||
DBTraceCodePrototypeEntry protoEnt = it.next();
|
||||
|
@ -491,9 +490,9 @@ public class DBTraceCodeManager
|
|||
}
|
||||
Collection<AbstractDBTraceCodeUnit<?>> changes = new ArrayList<>();
|
||||
for (DBTraceCodeSpace space : memSpaces.values()) {
|
||||
changes.addAll(space.dataMapSpace
|
||||
.reduce(TraceAddressSnapRangeQuery.added(from, to, space.space))
|
||||
.values());
|
||||
changes.addAll(
|
||||
space.dataMapSpace.reduce(TraceAddressSnapRangeQuery.added(from, to, space.space))
|
||||
.values());
|
||||
changes.addAll(space.instructionMapSpace
|
||||
.reduce(TraceAddressSnapRangeQuery.added(from, to, space.space))
|
||||
.values());
|
||||
|
@ -512,9 +511,9 @@ public class DBTraceCodeManager
|
|||
}
|
||||
Collection<AbstractDBTraceCodeUnit<?>> changes = new ArrayList<>();
|
||||
for (DBTraceCodeSpace space : memSpaces.values()) {
|
||||
changes.addAll(space.dataMapSpace
|
||||
.reduce(TraceAddressSnapRangeQuery.removed(from, to, space.space))
|
||||
.values());
|
||||
changes.addAll(
|
||||
space.dataMapSpace.reduce(TraceAddressSnapRangeQuery.removed(from, to, space.space))
|
||||
.values());
|
||||
changes.addAll(space.instructionMapSpace
|
||||
.reduce(TraceAddressSnapRangeQuery.removed(from, to, space.space))
|
||||
.values());
|
||||
|
|
|
@ -296,7 +296,7 @@ public class TracePcodeEmulatorTest extends AbstractGhidraHeadlessIntegrationTes
|
|||
@Test
|
||||
public void testIMM() throws Throwable {
|
||||
try (ToyDBTraceBuilder tb = new ToyDBTraceBuilder("Test", "Toy:BE:64:default")) {
|
||||
assertEquals(Register.DEFAULT_CONTEXT, tb.language.getContextBaseRegister());
|
||||
assertEquals(Register.NO_CONTEXT, tb.language.getContextBaseRegister());
|
||||
|
||||
TraceThread thread = initTrace(tb,
|
||||
List.of(
|
||||
|
|
|
@ -1196,7 +1196,7 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
|
|||
}
|
||||
|
||||
// TODO: Test with non-default context
|
||||
assertEquals(Register.DEFAULT_CONTEXT, i4004.getBaseContextRegister());
|
||||
assertEquals(Register.NO_CONTEXT, i4004.getBaseContextRegister());
|
||||
|
||||
assertEquals(b.language.getRegisters(), i4004.getRegisters());
|
||||
assertEquals(r4, i4004.getRegister("r4"));
|
||||
|
|
|
@ -126,7 +126,7 @@ public class DefaultPcodeThread<T> implements PcodeThread<T> {
|
|||
this.pc = language.getProgramCounter();
|
||||
this.contextreg = language.getContextBaseRegister();
|
||||
|
||||
if (contextreg != Register.DEFAULT_CONTEXT) {
|
||||
if (contextreg != Register.NO_CONTEXT) {
|
||||
defaultContext = new ProgramContextImpl(language);
|
||||
language.applyContextSettings(defaultContext);
|
||||
this.context = defaultContext.getDefaultDisassemblyContext();
|
||||
|
@ -190,7 +190,7 @@ public class DefaultPcodeThread<T> implements PcodeThread<T> {
|
|||
|
||||
@Override
|
||||
public void overrideContextWithDefault() {
|
||||
if (contextreg != Register.DEFAULT_CONTEXT) {
|
||||
if (contextreg != Register.NO_CONTEXT) {
|
||||
overrideContext(defaultContext.getDefaultValue(contextreg, counter));
|
||||
}
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ public class DefaultPcodeThread<T> implements PcodeThread<T> {
|
|||
long offset = arithmetic.toConcrete(state.getVar(pc)).longValue();
|
||||
setCounter(language.getDefaultSpace().getAddress(offset));
|
||||
|
||||
if (contextreg != Register.DEFAULT_CONTEXT) {
|
||||
if (contextreg != Register.NO_CONTEXT) {
|
||||
try {
|
||||
BigInteger ctx = arithmetic.toConcrete(state.getVar(contextreg));
|
||||
assignContext(new RegisterValue(contextreg, ctx));
|
||||
|
@ -271,7 +271,7 @@ public class DefaultPcodeThread<T> implements PcodeThread<T> {
|
|||
if (frame.isFallThrough()) {
|
||||
overrideCounter(counter.addWrap(decoder.getLastLengthWithDelays()));
|
||||
}
|
||||
if (contextreg != Register.DEFAULT_CONTEXT) {
|
||||
if (contextreg != Register.NO_CONTEXT) {
|
||||
overrideContext(instruction.getRegisterValue(contextreg));
|
||||
}
|
||||
postExecuteInstruction();
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -23,44 +22,48 @@ import ghidra.program.util.LanguageTranslatorAdapter;
|
|||
import ghidra.util.Msg;
|
||||
import ghidra.util.exception.AssertException;
|
||||
|
||||
|
||||
public class ForceRedisassembly extends GhidraScript {
|
||||
|
||||
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
|
||||
public void run() throws Exception {
|
||||
|
||||
if (currentProgram == null) {
|
||||
Msg.showError(this, null, "No Program Error", "No active program found");
|
||||
return;
|
||||
}
|
||||
ProgramDB program = (ProgramDB)currentProgram;
|
||||
|
||||
ProgramDB program = (ProgramDB) currentProgram;
|
||||
|
||||
Language lang = program.getLanguage();
|
||||
|
||||
LanguageTranslator translator = new MyLanguageTranslator(lang.getLanguageID(), lang.getVersion());
|
||||
|
||||
LanguageTranslator translator =
|
||||
new MyLanguageTranslator(lang.getLanguageID(), lang.getVersion());
|
||||
if (!translator.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
program.setLanguage(translator, program.getCompilerSpec().getCompilerSpecID(), true, monitor);
|
||||
|
||||
program.setLanguage(translator, program.getCompilerSpec().getCompilerSpecID(), true,
|
||||
monitor);
|
||||
}
|
||||
|
||||
private static class MyLanguageTranslator extends LanguageTranslatorAdapter {
|
||||
protected MyLanguageTranslator(LanguageID languageId, int version) {
|
||||
super(languageId, version, languageId, version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
if (super.isValid()) {
|
||||
try {
|
||||
validateDefaultSpaceMap();
|
||||
} catch (IncompatibleLanguageException e) {
|
||||
throw new AssertException();
|
||||
}
|
||||
catch (IncompatibleLanguageException e) {
|
||||
throw new AssertException();
|
||||
}
|
||||
Register newContextReg = getNewLanguage().getContextBaseRegister();
|
||||
if (newContextReg != null) {
|
||||
if (newContextReg != Register.NO_CONTEXT) {
|
||||
Register oldContextReg = getOldLanguage().getContextBaseRegister();
|
||||
if (oldContextReg == null || !isSameRegisterConstruction(oldContextReg, newContextReg)) {
|
||||
if (oldContextReg != Register.NO_CONTEXT ||
|
||||
!isSameRegisterConstruction(oldContextReg, newContextReg)) {
|
||||
throw new AssertException();
|
||||
}
|
||||
}
|
||||
|
@ -68,11 +71,12 @@ public class ForceRedisassembly extends GhidraScript {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[" + getOldLanguageID() + " (Version " + getOldVersion() + ")] -> [" +
|
||||
getNewLanguageID() + " (Version " + getNewVersion() + ")] {Forced Re-Disassembly Translator}";
|
||||
return "[" + getOldLanguageID() + " (Version " + getOldVersion() + ")] -> [" +
|
||||
getNewLanguageID() + " (Version " + getNewVersion() +
|
||||
")] {Forced Re-Disassembly Translator}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -147,10 +147,10 @@ class CodeUnitMerger extends AbstractListingMerger {
|
|||
mergeLatest = listingMergeMgr.mergeLatest;
|
||||
mergeOriginal = listingMergeMgr.mergeOriginal;
|
||||
|
||||
myResolvedDts = (Map<Long, DataType>) mergeManager.getResolveInformation(
|
||||
MergeConstants.RESOLVED_MY_DTS);
|
||||
origResolvedDts = (Map<Long, DataType>) mergeManager.getResolveInformation(
|
||||
MergeConstants.RESOLVED_ORIGINAL_DTS);
|
||||
myResolvedDts = (Map<Long, DataType>) mergeManager
|
||||
.getResolveInformation(MergeConstants.RESOLVED_MY_DTS);
|
||||
origResolvedDts = (Map<Long, DataType>) mergeManager
|
||||
.getResolveInformation(MergeConstants.RESOLVED_ORIGINAL_DTS);
|
||||
|
||||
mergedCodeUnits = new AddressSet();
|
||||
|
||||
|
@ -775,7 +775,7 @@ class CodeUnitMerger extends AbstractListingMerger {
|
|||
// May cause the merge code unit to lose info attached to it, such as references.
|
||||
resultListing.clearCodeUnits(range.getMinAddress(), range.getMaxAddress(), false);
|
||||
|
||||
if (contextReg != null) {
|
||||
if (contextReg != Register.NO_CONTEXT) {
|
||||
// Copy context register value
|
||||
mergeProgramContext(resultContext, originContext,
|
||||
originContext.getBaseContextRegister(), range, monitor);
|
||||
|
|
|
@ -366,8 +366,8 @@ public class ClearFlowAndRepairCmd extends BackgroundCommand {
|
|||
// re-parse instruction to regenerate fall-through context
|
||||
program.getLanguage().parse(instr, context, instr.isInDelaySlot());
|
||||
RegisterValue contextValue = context.getFlowContextValue(fallThroughAddr, true);
|
||||
program.getProgramContext().setRegisterValue(fallThroughAddr, fallThroughAddr,
|
||||
contextValue);
|
||||
program.getProgramContext()
|
||||
.setRegisterValue(fallThroughAddr, fallThroughAddr, contextValue);
|
||||
}
|
||||
catch (Exception e) {
|
||||
return;
|
||||
|
@ -413,7 +413,7 @@ public class ClearFlowAndRepairCmd extends BackgroundCommand {
|
|||
continue;
|
||||
}
|
||||
disassemblePoints.addRange(addr, addr);
|
||||
if (contextReg != null) {
|
||||
if (contextReg != Register.NO_CONTEXT) {
|
||||
if (seedContext == null) {
|
||||
seedContext = new DisassemblerContextImpl(programContext);
|
||||
}
|
||||
|
@ -503,7 +503,7 @@ public class ClearFlowAndRepairCmd extends BackgroundCommand {
|
|||
if (ftAddr != null && (ignoreStart == null || !ftAddr.equals(ignoreStart))) {
|
||||
// alreadyCleared.addRange(ftAddr, addr);
|
||||
disassemblePoints.addRange(ftAddr, ftAddr);
|
||||
if (contextReg != null) {
|
||||
if (contextReg != Register.NO_CONTEXT) {
|
||||
if (seedContext == null) {
|
||||
seedContext = new DisassemblerContextImpl(programContext);
|
||||
}
|
||||
|
@ -523,8 +523,9 @@ public class ClearFlowAndRepairCmd extends BackgroundCommand {
|
|||
// clearSet.add(alreadyCleared);
|
||||
|
||||
// Get rid of any bad bookmarks at seed points, will be put back if they are still bad.
|
||||
program.getBookmarkManager().removeBookmarks(disassemblePoints, BookmarkType.ERROR,
|
||||
Disassembler.ERROR_BOOKMARK_CATEGORY, monitor);
|
||||
program.getBookmarkManager()
|
||||
.removeBookmarks(disassemblePoints, BookmarkType.ERROR,
|
||||
Disassembler.ERROR_BOOKMARK_CATEGORY, monitor);
|
||||
|
||||
// Disassemble fallthrough reference points
|
||||
DisassembleCommand cmd = new DisassembleCommand(disassemblePoints, null);
|
||||
|
@ -651,9 +652,10 @@ public class ClearFlowAndRepairCmd extends BackgroundCommand {
|
|||
if (protectedSet.contains(fromBlock.getMinAddress())) {
|
||||
continue;
|
||||
}
|
||||
fromBlock = adjustBlockForSplitProtectedBlock(program, blockModel, fromBlock.getFirstStartAddress(), fromBlock);
|
||||
fromBlock = adjustBlockForSplitProtectedBlock(program, blockModel,
|
||||
fromBlock.getFirstStartAddress(), fromBlock);
|
||||
|
||||
// HOT SPOT - getDestinations()
|
||||
// HOT SPOT - getDestinations()
|
||||
CodeBlockReferenceIterator blockRefIter = fromBlock.getDestinations(monitor);
|
||||
if (clearOffcut) {
|
||||
findDestAddrs(fromBlock, destAddrs); // Needed for detecting offcut flows
|
||||
|
@ -661,7 +663,7 @@ public class ClearFlowAndRepairCmd extends BackgroundCommand {
|
|||
while (blockRefIter.hasNext()) {
|
||||
monitor.checkCanceled();
|
||||
CodeBlockReference cbRef = blockRefIter.next();
|
||||
|
||||
|
||||
Address blockAddr = cbRef.getReference();
|
||||
if (protectedSet.contains(blockAddr)) {
|
||||
continue;
|
||||
|
@ -671,7 +673,8 @@ public class ClearFlowAndRepairCmd extends BackgroundCommand {
|
|||
}
|
||||
CodeBlock destBlock = cbRef.getDestinationBlock();
|
||||
if (blockAddr.equals(destBlock.getFirstStartAddress())) {
|
||||
destBlock = adjustBlockForSplitProtectedBlock(program, blockModel, blockAddr, destBlock);
|
||||
destBlock = adjustBlockForSplitProtectedBlock(program, blockModel, blockAddr,
|
||||
destBlock);
|
||||
}
|
||||
if (neverSnipStartBlock && destBlock.equals(startBlock)) {
|
||||
continue; // do not allow incoming edges to startBlock vertex
|
||||
|
@ -696,13 +699,13 @@ public class ClearFlowAndRepairCmd extends BackgroundCommand {
|
|||
continue;
|
||||
}
|
||||
}
|
||||
// TODO: check disassembly hint
|
||||
// TODO: check disassembly hint
|
||||
blockSet.add(destBlock);
|
||||
destVertex = new BlockVertex(destBlock);
|
||||
vertexMap.put(blockAddr, destVertex);
|
||||
todoVertices.push(destVertex);
|
||||
}
|
||||
// HOT SPOT - HashSet.add()
|
||||
// HOT SPOT - HashSet.add()
|
||||
fromVertex.destVertices.add(destVertex);
|
||||
destVertex.srcVertices.add(fromVertex);
|
||||
}
|
||||
|
@ -767,8 +770,8 @@ public class ClearFlowAndRepairCmd extends BackgroundCommand {
|
|||
return blockSet;
|
||||
}
|
||||
|
||||
private CodeBlock adjustBlockForSplitProtectedBlock(Program program, SimpleBlockModel blockModel, Address blockAddr,
|
||||
CodeBlock blockToAdjust) {
|
||||
private CodeBlock adjustBlockForSplitProtectedBlock(Program program,
|
||||
SimpleBlockModel blockModel, Address blockAddr, CodeBlock blockToAdjust) {
|
||||
if (!protectedSet.isEmpty()) {
|
||||
AddressSet intersect = protectedSet.intersectRange(blockToAdjust.getMinAddress(),
|
||||
blockToAdjust.getMaxAddress());
|
||||
|
@ -857,8 +860,9 @@ public class ClearFlowAndRepairCmd extends BackgroundCommand {
|
|||
public static void clearBadBookmarks(Program program, Address start, Address end,
|
||||
TaskMonitor monitor) throws CancelledException {
|
||||
AddressSet set = new AddressSet(start, end);
|
||||
program.getBookmarkManager().removeBookmarks(set, BookmarkType.ERROR,
|
||||
Disassembler.ERROR_BOOKMARK_CATEGORY, monitor);
|
||||
program.getBookmarkManager()
|
||||
.removeBookmarks(set, BookmarkType.ERROR, Disassembler.ERROR_BOOKMARK_CATEGORY,
|
||||
monitor);
|
||||
}
|
||||
|
||||
public static void clearBadBookmarks(Program program, AddressSetView set, TaskMonitor monitor)
|
||||
|
|
|
@ -149,15 +149,12 @@ public class DisassemblerPlugin extends Plugin {
|
|||
return;
|
||||
}
|
||||
Options options = program.getOptions(Program.DISASSEMBLER_PROPERTIES);
|
||||
options.registerOption(Disassembler.MARK_BAD_INSTRUCTION_PROPERTY, true,
|
||||
null, "Place ERROR Bookmark at locations where disassembly could not be perfomed.");
|
||||
options.registerOption(
|
||||
Disassembler.MARK_UNIMPL_PCODE_PROPERTY,
|
||||
true,
|
||||
null,
|
||||
options.registerOption(Disassembler.MARK_BAD_INSTRUCTION_PROPERTY, true, null,
|
||||
"Place ERROR Bookmark at locations where disassembly could not be perfomed.");
|
||||
options.registerOption(Disassembler.MARK_UNIMPL_PCODE_PROPERTY, true, null,
|
||||
"Place WARNING Bookmark at locations where a disassembled instruction has unimplemented pcode.");
|
||||
options.registerOption(Disassembler.RESTRICT_DISASSEMBLY_TO_EXECUTE_MEMORY_PROPERTY,
|
||||
false, null, "Restrict disassembly to executable memory blocks.");
|
||||
options.registerOption(Disassembler.RESTRICT_DISASSEMBLY_TO_EXECUTE_MEMORY_PROPERTY, false,
|
||||
null, "Restrict disassembly to executable memory blocks.");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
@ -179,7 +176,7 @@ public class DisassemblerPlugin extends Plugin {
|
|||
mipsDisassembleAction = new MipsDisassembleAction(this, GROUP_NAME, false);
|
||||
mips16DisassembleAction = new MipsDisassembleAction(this, GROUP_NAME, true);
|
||||
ppcDisassembleAction = new PowerPCDisassembleAction(this, GROUP_NAME, false);
|
||||
ppcVleDisassembleAction= new PowerPCDisassembleAction(this, GROUP_NAME, true);
|
||||
ppcVleDisassembleAction = new PowerPCDisassembleAction(this, GROUP_NAME, true);
|
||||
setFlowOverrideAction = new SetFlowOverrideAction(this, GROUP_NAME);
|
||||
|
||||
tool.addAction(disassembleAction);
|
||||
|
@ -236,8 +233,8 @@ public class DisassemblerPlugin extends Plugin {
|
|||
Program currentProgram = context.getProgram();
|
||||
DisassembleCommand cmd = null;
|
||||
|
||||
boolean isDynamicListing =
|
||||
(context instanceof CodeViewerActionContext && ((CodeViewerActionContext) context).isDyanmicListing());
|
||||
boolean isDynamicListing = (context instanceof CodeViewerActionContext &&
|
||||
((CodeViewerActionContext) context).isDyanmicListing());
|
||||
|
||||
if ((currentSelection != null) && (!currentSelection.isEmpty())) {
|
||||
cmd = new DisassembleCommand(currentSelection, null, true);
|
||||
|
@ -276,7 +273,8 @@ public class DisassemblerPlugin extends Plugin {
|
|||
}
|
||||
}
|
||||
|
||||
boolean checkDisassemblyEnabled(ListingActionContext context, Address address, boolean followPtr) {
|
||||
boolean checkDisassemblyEnabled(ListingActionContext context, Address address,
|
||||
boolean followPtr) {
|
||||
ProgramSelection currentSelection = context.getSelection();
|
||||
Program currentProgram = context.getProgram();
|
||||
if ((currentSelection != null) && (!currentSelection.isEmpty())) {
|
||||
|
@ -304,7 +302,7 @@ public class DisassemblerPlugin extends Plugin {
|
|||
public void setDefaultContext(ListingActionContext context) {
|
||||
Program contextProgram = context.getProgram();
|
||||
Register baseContextReg = contextProgram.getLanguage().getContextBaseRegister();
|
||||
if (baseContextReg != null && baseContextReg.hasChildren()) {
|
||||
if (baseContextReg != Register.NO_CONTEXT && baseContextReg.hasChildren()) {
|
||||
tool.showDialog(new ProcessorStateDialog(contextProgram.getProgramContext()),
|
||||
context.getComponentProvider());
|
||||
}
|
||||
|
@ -312,7 +310,7 @@ public class DisassemblerPlugin extends Plugin {
|
|||
|
||||
public boolean hasContextRegisters(Program currentProgram) {
|
||||
Register baseContextReg = currentProgram.getLanguage().getContextBaseRegister();
|
||||
return baseContextReg != null && baseContextReg.hasChildren();
|
||||
return baseContextReg != Register.NO_CONTEXT && baseContextReg.hasChildren();
|
||||
}
|
||||
|
||||
public void disassembleArmCallback(ListingActionContext context, boolean thumbMode) {
|
||||
|
@ -338,7 +336,7 @@ public class DisassemblerPlugin extends Plugin {
|
|||
tool.executeBackgroundCommand(cmd, currentProgram);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void disassembleHcs12Callback(ListingActionContext context, boolean xgMode) {
|
||||
ProgramSelection currentSelection = context.getSelection();
|
||||
ProgramLocation currentLocation = context.getLocation();
|
||||
|
@ -362,7 +360,7 @@ public class DisassemblerPlugin extends Plugin {
|
|||
tool.executeBackgroundCommand(cmd, currentProgram);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void disassembleMipsCallback(ListingActionContext context, boolean mips16) {
|
||||
ProgramSelection currentSelection = context.getSelection();
|
||||
ProgramLocation currentLocation = context.getLocation();
|
||||
|
@ -392,7 +390,7 @@ public class DisassemblerPlugin extends Plugin {
|
|||
ProgramLocation currentLocation = context.getLocation();
|
||||
Program currentProgram = context.getProgram();
|
||||
PowerPCDisassembleCommand cmd = null;
|
||||
|
||||
|
||||
if ((currentSelection != null) && (!currentSelection.isEmpty())) {
|
||||
cmd = new PowerPCDisassembleCommand(currentSelection, null, vle);
|
||||
}
|
||||
|
|
|
@ -66,10 +66,10 @@ import ghidra.util.xml.GenericXMLOutputter;
|
|||
//@formatter:on
|
||||
public class GenerateOldLanguagePlugin extends Plugin implements FrontEndable {
|
||||
|
||||
private static final ExtensionFileFilter OLD_LANG_FILTER = new ExtensionFileFilter("lang",
|
||||
"Old Language File");
|
||||
private static final ExtensionFileFilter TRANSLATOR_FILTER = new ExtensionFileFilter("trans",
|
||||
"Simple Translator File");
|
||||
private static final ExtensionFileFilter OLD_LANG_FILTER =
|
||||
new ExtensionFileFilter("lang", "Old Language File");
|
||||
private static final ExtensionFileFilter TRANSLATOR_FILTER =
|
||||
new ExtensionFileFilter("trans", "Simple Translator File");
|
||||
|
||||
private DockingAction generateOldLanguageAction;
|
||||
private DockingAction generateTranslatorAction;
|
||||
|
@ -95,8 +95,8 @@ public class GenerateOldLanguagePlugin extends Plugin implements FrontEndable {
|
|||
}
|
||||
};
|
||||
// ACTIONS - auto generated
|
||||
generateOldLanguageAction.setMenuBarData(new MenuData(new String[] { "File",
|
||||
"Generate Old Language File..." }, null, "Language"));
|
||||
generateOldLanguageAction.setMenuBarData(new MenuData(
|
||||
new String[] { "File", "Generate Old Language File..." }, null, "Language"));
|
||||
|
||||
generateOldLanguageAction.setEnabled(true);
|
||||
tool.addAction(generateOldLanguageAction);
|
||||
|
@ -116,8 +116,8 @@ public class GenerateOldLanguagePlugin extends Plugin implements FrontEndable {
|
|||
}
|
||||
};
|
||||
// ACTIONS - auto generated
|
||||
generateTranslatorAction.setMenuBarData(new MenuData(new String[] { "File",
|
||||
"Generate Simple Language Translator..." }, null, "Language"));
|
||||
generateTranslatorAction.setMenuBarData(new MenuData(
|
||||
new String[] { "File", "Generate Simple Language Translator..." }, null, "Language"));
|
||||
|
||||
generateTranslatorAction.setEnabled(true);
|
||||
tool.addAction(generateTranslatorAction);
|
||||
|
@ -176,17 +176,16 @@ public class GenerateOldLanguagePlugin extends Plugin implements FrontEndable {
|
|||
chooser.setApproveButtonText("Create");
|
||||
// there's no single directory; you need to pick it yourself now
|
||||
// chooser.setCurrentDirectory(LANGUAGE_DIR);
|
||||
chooser.setCurrentDirectory(Application.getApplicationRootDirectory().getFile(
|
||||
false));
|
||||
chooser.setCurrentDirectory(
|
||||
Application.getApplicationRootDirectory().getFile(false));
|
||||
}
|
||||
File file = chooser.getSelectedFile(true);
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
if (!file.getName().endsWith(OldLanguageFactory.OLD_LANGUAGE_FILE_EXT)) {
|
||||
file =
|
||||
new File(file.getParent(), file.getName() +
|
||||
OldLanguageFactory.OLD_LANGUAGE_FILE_EXT);
|
||||
file = new File(file.getParent(),
|
||||
file.getName() + OldLanguageFactory.OLD_LANGUAGE_FILE_EXT);
|
||||
}
|
||||
if (file.exists()) {
|
||||
if (OptionDialog.showYesNoDialog(panel, "Confirm Overwrite",
|
||||
|
@ -199,12 +198,11 @@ public class GenerateOldLanguagePlugin extends Plugin implements FrontEndable {
|
|||
OldLanguageFactory.createOldLanguageFile(lang, file);
|
||||
close();
|
||||
|
||||
int resp =
|
||||
OptionDialog.showYesNoDialog(
|
||||
GenerateOldLanguagePlugin.this.tool.getToolFrame(),
|
||||
"Create Simple Translator?",
|
||||
"Old language file generated successfully.\n \n"
|
||||
+ "Would you like to create a simple translator to another language?");
|
||||
int resp = OptionDialog.showYesNoDialog(
|
||||
GenerateOldLanguagePlugin.this.tool.getToolFrame(),
|
||||
"Create Simple Translator?",
|
||||
"Old language file generated successfully.\n \n" +
|
||||
"Would you like to create a simple translator to another language?");
|
||||
if (resp == OptionDialog.YES_OPTION) {
|
||||
GenerateTranslatorDialog translatorDlgProvider =
|
||||
new GenerateTranslatorDialog(lang, file);
|
||||
|
@ -278,35 +276,33 @@ public class GenerateOldLanguagePlugin extends Plugin implements FrontEndable {
|
|||
chooser.setApproveButtonText("Create");
|
||||
// there's no single directory; you need to pick it yourself now
|
||||
// chooser.setCurrentDirectory(LANGUAGE_DIR);
|
||||
chooser.setCurrentDirectory(Application.getApplicationRootDirectory().getFile(
|
||||
false));
|
||||
chooser.setCurrentDirectory(
|
||||
Application.getApplicationRootDirectory().getFile(false));
|
||||
}
|
||||
transFile = chooser.getSelectedFile(true);
|
||||
if (transFile == null) {
|
||||
return;
|
||||
}
|
||||
if (!transFile.getName().endsWith(
|
||||
LanguageTranslatorFactory.LANGUAGE_TRANSLATOR_FILE_EXT)) {
|
||||
transFile =
|
||||
new File(transFile.getParent(), transFile.getName() +
|
||||
LanguageTranslatorFactory.LANGUAGE_TRANSLATOR_FILE_EXT);
|
||||
if (!transFile.getName()
|
||||
.endsWith(LanguageTranslatorFactory.LANGUAGE_TRANSLATOR_FILE_EXT)) {
|
||||
transFile = new File(transFile.getParent(), transFile.getName() +
|
||||
LanguageTranslatorFactory.LANGUAGE_TRANSLATOR_FILE_EXT);
|
||||
}
|
||||
}
|
||||
else {
|
||||
String filename = GenerateTranslatorDialog.this.oldLangFile.getName();
|
||||
int index = filename.indexOf(OldLanguageFactory.OLD_LANGUAGE_FILE_EXT);
|
||||
if (index > 0) {
|
||||
filename =
|
||||
filename.substring(0, index) +
|
||||
LanguageTranslatorFactory.LANGUAGE_TRANSLATOR_FILE_EXT;
|
||||
filename = filename.substring(0, index) +
|
||||
LanguageTranslatorFactory.LANGUAGE_TRANSLATOR_FILE_EXT;
|
||||
}
|
||||
transFile =
|
||||
new File(GenerateTranslatorDialog.this.oldLangFile.getParentFile(),
|
||||
filename);
|
||||
transFile = new File(
|
||||
GenerateTranslatorDialog.this.oldLangFile.getParentFile(), filename);
|
||||
}
|
||||
if (transFile.exists()) {
|
||||
if (OptionDialog.showYesNoDialog(panel, "Confirm Overwrite",
|
||||
"Overwrite file " + transFile.getName() + "?") != OptionDialog.YES_OPTION) {
|
||||
"Overwrite file " + transFile.getName() +
|
||||
"?") != OptionDialog.YES_OPTION) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -353,12 +349,14 @@ public class GenerateOldLanguagePlugin extends Plugin implements FrontEndable {
|
|||
toLang.setText(newLang.getLanguageID().getIdAsString());
|
||||
root.addContent(toLang);
|
||||
|
||||
for (CompilerSpecDescription oldCompilerSpecDescription : oldLang.getCompatibleCompilerSpecDescriptions()) {
|
||||
for (CompilerSpecDescription oldCompilerSpecDescription : oldLang
|
||||
.getCompatibleCompilerSpecDescriptions()) {
|
||||
CompilerSpecID oldCompilerSpecID = oldCompilerSpecDescription.getCompilerSpecID();
|
||||
String newId;
|
||||
try {
|
||||
newId =
|
||||
newLang.getCompilerSpecByID(oldCompilerSpecID).getCompilerSpecID().getIdAsString();
|
||||
newId = newLang.getCompilerSpecByID(oldCompilerSpecID)
|
||||
.getCompilerSpecID()
|
||||
.getIdAsString();
|
||||
}
|
||||
catch (CompilerSpecNotFoundException e) {
|
||||
newId = newLang.getDefaultCompilerSpec().getCompilerSpecID().getIdAsString();
|
||||
|
@ -398,16 +396,17 @@ public class GenerateOldLanguagePlugin extends Plugin implements FrontEndable {
|
|||
Register oldCtx = oldLang.getContextBaseRegister();
|
||||
Register newCtx = newLang.getContextBaseRegister();
|
||||
boolean contextWarning = false;
|
||||
if (oldCtx != null && defaultTrans.isValueTranslationRequired(oldCtx)) {
|
||||
if (oldCtx != Register.NO_CONTEXT &&
|
||||
defaultTrans.isValueTranslationRequired(oldCtx)) {
|
||||
contextWarning = true;
|
||||
}
|
||||
else if (oldCtx == null && newCtx != null) {
|
||||
else if (oldCtx == Register.NO_CONTEXT && newCtx != Register.NO_CONTEXT) {
|
||||
contextWarning = true;
|
||||
}
|
||||
if (contextWarning) {
|
||||
Msg.showWarn(getClass(), tool.getToolFrame(), "Translator Warning",
|
||||
"The new context register differs from the old context!\n"
|
||||
+ "A set_context element or custom translator may be required.");
|
||||
"The new context register differs from the old context!\n" +
|
||||
"A set_context element or custom translator may be required.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -531,7 +530,8 @@ public class GenerateOldLanguagePlugin extends Plugin implements FrontEndable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<LanguageDescription> getLanguageDescriptions(boolean includeDeprecatedLanguages) {
|
||||
public List<LanguageDescription> getLanguageDescriptions(
|
||||
boolean includeDeprecatedLanguages) {
|
||||
// Include deprecated languages
|
||||
List<LanguageDescription> list = new ArrayList<LanguageDescription>();
|
||||
list.addAll(langService.getLanguageDescriptions(true));
|
||||
|
|
|
@ -474,14 +474,14 @@ public class ProgramMerge implements PropertyVisitor {
|
|||
Address max = range.getMaxAddress();
|
||||
Instruction instr = listing.getInstructionContaining(min);
|
||||
if (instr != null) {
|
||||
instructionSet.add(
|
||||
new AddressRangeImpl(instr.getMinAddress(), instr.getMaxAddress()));
|
||||
instructionSet
|
||||
.add(new AddressRangeImpl(instr.getMinAddress(), instr.getMaxAddress()));
|
||||
}
|
||||
InstructionIterator instIter = listing.getInstructions(new AddressSet(min, max), true);
|
||||
while (instIter.hasNext()) {
|
||||
instr = instIter.next();
|
||||
instructionSet.add(
|
||||
new AddressRangeImpl(instr.getMinAddress(), instr.getMaxAddress()));
|
||||
instructionSet
|
||||
.add(new AddressRangeImpl(instr.getMinAddress(), instr.getMaxAddress()));
|
||||
}
|
||||
}
|
||||
return instructionSet;
|
||||
|
@ -563,8 +563,8 @@ public class ProgramMerge implements PropertyVisitor {
|
|||
resultRange.getMaxAddress(), false);
|
||||
|
||||
try {
|
||||
if (resultContextReg != null) {
|
||||
if (originContextReg != null) {
|
||||
if (resultContextReg != Register.NO_CONTEXT) {
|
||||
if (originContextReg != Register.NO_CONTEXT) {
|
||||
// Copy context register value
|
||||
mergeProgramContext(resultContext, originContext,
|
||||
originContext.getBaseContextRegister(), newOriginRange, resultRange,
|
||||
|
@ -759,15 +759,16 @@ public class ProgramMerge implements PropertyVisitor {
|
|||
DisassemblerContextImpl context = new DisassemblerContextImpl(program.getProgramContext());
|
||||
context.flowStart(addr);
|
||||
try {
|
||||
InstructionPrototype proto = program.getLanguage().parse(
|
||||
new DumbMemBufferImpl(program.getMemory(), addr), context, false);
|
||||
InstructionPrototype proto = program.getLanguage()
|
||||
.parse(new DumbMemBufferImpl(program.getMemory(), addr), context, false);
|
||||
return resultListing.createInstruction(addr, proto,
|
||||
new DumbMemBufferImpl(program.getMemory(), addr),
|
||||
new ProgramProcessorContext(program.getProgramContext(), addr));
|
||||
}
|
||||
catch (Exception e) {
|
||||
program.getBookmarkManager().setBookmark(addr, BookmarkType.ERROR,
|
||||
Disassembler.ERROR_BOOKMARK_CATEGORY, "Diff/Merge applied bad instruction");
|
||||
program.getBookmarkManager()
|
||||
.setBookmark(addr, BookmarkType.ERROR, Disassembler.ERROR_BOOKMARK_CATEGORY,
|
||||
"Diff/Merge applied bad instruction");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -1251,8 +1252,8 @@ public class ProgramMerge implements PropertyVisitor {
|
|||
}
|
||||
ReferenceManager resultRM = resultProgram.getReferenceManager();
|
||||
Reference[] resultRefs = resultRM.getReferencesFrom(resultCu.getMinAddress(), opIndex);
|
||||
Reference[] originRefs = originProgram.getReferenceManager().getReferencesFrom(
|
||||
originCu.getMinAddress(), opIndex);
|
||||
Reference[] originRefs = originProgram.getReferenceManager()
|
||||
.getReferencesFrom(originCu.getMinAddress(), opIndex);
|
||||
HashMap<Reference, Reference> resultsToKeep = new HashMap<>(); // key=OriginRef, value=ResultRef
|
||||
// Determine the result references to keep that match the origin references.
|
||||
for (Reference originRef : originRefs) {
|
||||
|
|
|
@ -195,7 +195,7 @@ public class SleighAssembler implements Assembler {
|
|||
throw new AssemblyError(
|
||||
"Context must be fully-specified (full length, no shift, no unknowns)");
|
||||
}
|
||||
if (lang.getContextBaseRegister() != null &&
|
||||
if (lang.getContextBaseRegister() != Register.NO_CONTEXT &&
|
||||
ctx.length() < lang.getContextBaseRegister().getMinimumByteSize()) {
|
||||
throw new AssemblyError(
|
||||
"Context must be fully-specified (full length, no shift, no unknowns)");
|
||||
|
|
|
@ -57,7 +57,7 @@ public class AssemblyDefaultContext implements DisassemblerContext, DefaultProgr
|
|||
this.lang = lang;
|
||||
this.at = at;
|
||||
Register ctxreg = lang.getContextBaseRegister();
|
||||
if (null == ctxreg) {
|
||||
if (ctxreg == Register.NO_CONTEXT) {
|
||||
this.defctx = AssemblyPatternBlock.nop();
|
||||
this.curctx = AssemblyPatternBlock.nop();
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ public class SleighDebugLogger {
|
|||
|
||||
ContextCache contextCache = new ContextCache();
|
||||
contextBaseRegister = language.getContextBaseRegister();
|
||||
if (contextBaseRegister != null) {
|
||||
if (contextBaseRegister != Register.NO_CONTEXT) {
|
||||
contextCache.registerVariable(contextBaseRegister);
|
||||
}
|
||||
|
||||
|
|
|
@ -101,8 +101,8 @@ public class Emulate {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void initInstuctionStateModifier() {
|
||||
String classname = language.getProperty(
|
||||
GhidraLanguagePropertyKeys.EMULATE_INSTRUCTION_STATE_MODIFIER_CLASS);
|
||||
String classname = language
|
||||
.getProperty(GhidraLanguagePropertyKeys.EMULATE_INSTRUCTION_STATE_MODIFIER_CLASS);
|
||||
if (classname == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ public class Emulate {
|
|||
*/
|
||||
public RegisterValue getContextRegisterValue() {
|
||||
Register contextReg = language.getContextBaseRegister();
|
||||
if (contextReg == null) {
|
||||
if (contextReg == Register.NO_CONTEXT) {
|
||||
return null;
|
||||
}
|
||||
if (pseudoInstruction != null) {
|
||||
|
|
|
@ -58,7 +58,7 @@ public class EmulateDisassemblerContext implements DisassemblerContext {
|
|||
|
||||
public void setCurrentAddress(Address addr) {
|
||||
|
||||
if (contextReg == null) {
|
||||
if (contextReg == Register.NO_CONTEXT) {
|
||||
return;
|
||||
}
|
||||
RegisterValue partialValue = null;
|
||||
|
@ -99,7 +99,7 @@ public class EmulateDisassemblerContext implements DisassemblerContext {
|
|||
}
|
||||
|
||||
private void initContext() {
|
||||
if (contextReg == null) {
|
||||
if (contextReg == Register.NO_CONTEXT) {
|
||||
return;
|
||||
}
|
||||
flowingContextRegisterMask = contextReg.getBaseMask().clone();
|
||||
|
@ -203,8 +203,7 @@ public class EmulateDisassemblerContext implements DisassemblerContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setFutureRegisterValue(Address fromAddr, Address toAddr,
|
||||
RegisterValue value) {
|
||||
public void setFutureRegisterValue(Address fromAddr, Address toAddr, RegisterValue value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -819,8 +819,8 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
|||
* @param oldValue the old datatype.
|
||||
* @param newValue the new datatype.
|
||||
*/
|
||||
public void dataTypeChanged(long dataTypeID, int type, boolean isAutoChange,
|
||||
Object oldValue, Object newValue) {
|
||||
public void dataTypeChanged(long dataTypeID, int type, boolean isAutoChange, Object oldValue,
|
||||
Object newValue) {
|
||||
// TODO: do not need to record type changes for packed composite change which is in repsonse
|
||||
// to component size or alignment change.
|
||||
if (recordChanges && !isAutoChange) {
|
||||
|
@ -2174,7 +2174,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
|||
|
||||
ProgramContext context = getProgramContext();
|
||||
Register contextReg = context.getBaseContextRegister();
|
||||
if (contextReg == null) {
|
||||
if (contextReg == Register.NO_CONTEXT) {
|
||||
return;
|
||||
}
|
||||
Register thumbBitReg = context.getRegister("TMode");
|
||||
|
|
|
@ -472,8 +472,11 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
|||
if (prototype.hasDelaySlots()) {
|
||||
// perform bounds check on entire delay slot instruction group
|
||||
try {
|
||||
endAddr = startAddr.addNoWrap(prototype.getFallThroughOffset(
|
||||
protoInstr.getInstructionContext())).previous();
|
||||
endAddr =
|
||||
startAddr
|
||||
.addNoWrap(prototype.getFallThroughOffset(
|
||||
protoInstr.getInstructionContext()))
|
||||
.previous();
|
||||
}
|
||||
catch (AddressOverflowException e) {
|
||||
break;
|
||||
|
@ -553,9 +556,10 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
|||
InstructionPrototype prototype = lastInstruction.getPrototype();
|
||||
if (prototype.hasDelaySlots()) {
|
||||
try {
|
||||
maxAddr = lastInstruction.getAddress().addNoWrap(
|
||||
prototype.getFallThroughOffset(
|
||||
lastInstruction.getInstructionContext())).previous();
|
||||
maxAddr = lastInstruction.getAddress()
|
||||
.addNoWrap(prototype.getFallThroughOffset(
|
||||
lastInstruction.getInstructionContext()))
|
||||
.previous();
|
||||
}
|
||||
catch (AddressOverflowException e) {
|
||||
// ignore
|
||||
|
@ -630,7 +634,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
|||
prototype = protoMgr.getPrototype(protoID);
|
||||
|
||||
Register contextReg = contextMgr.getBaseContextRegister();
|
||||
if (contextReg != null) {
|
||||
if (contextReg != Register.NO_CONTEXT) {
|
||||
try {
|
||||
RegisterValue contextValue = context.getRegisterValue(contextReg);
|
||||
Address start = address;
|
||||
|
@ -2989,8 +2993,8 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
|||
boolean isFallthrough =
|
||||
(flowType.isJump() && flowAddr.equals(inst.getMaxAddress().next()));
|
||||
if (!isFallthrough) {
|
||||
mnemonicPrimaryRef = addDefaultMemoryReferenceIfMissing(inst, Reference.MNEMONIC,
|
||||
flowAddr, flowType, oldRefList, mnemonicPrimaryRef);
|
||||
mnemonicPrimaryRef = addDefaultMemoryReferenceIfMissing(inst,
|
||||
Reference.MNEMONIC, flowAddr, flowType, oldRefList, mnemonicPrimaryRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3020,8 +3024,8 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
|||
* @param operandPrimaryRef current preferred primary reference for operand
|
||||
* @return updated preferred primary address for operand (i.e., operandPrimaryRef)
|
||||
*/
|
||||
private Reference addDefaultMemoryReferenceIfMissing(Instruction inst,
|
||||
int opIndex, Address refAddr, RefType refType, List<Reference> oldRefList,
|
||||
private Reference addDefaultMemoryReferenceIfMissing(Instruction inst, int opIndex,
|
||||
Address refAddr, RefType refType, List<Reference> oldRefList,
|
||||
Reference operandPrimaryRef) {
|
||||
|
||||
Reference ref = removeOldReference(oldRefList, refAddr, opIndex, refType);
|
||||
|
|
|
@ -86,10 +86,6 @@ public class OldProgramContextDB implements ProgramContext, DefaultProgramContex
|
|||
valueMaps = new HashMap<>();
|
||||
|
||||
baseContextRegister = language.getContextBaseRegister();
|
||||
if (baseContextRegister == null) {
|
||||
baseContextRegister = new Register("DEFAULT_CONTEXT", "DEFAULT_CONTEXT",
|
||||
addrMap.getAddressFactory().getRegisterSpace().getAddress(0x0), 4, true, 0);
|
||||
}
|
||||
defaultDisassemblyContext = new RegisterValue(baseContextRegister);
|
||||
|
||||
initializeDefaultValues(language);
|
||||
|
|
|
@ -88,8 +88,7 @@ public class ProgramRegisterContextDB extends AbstractStoredProgramContext imple
|
|||
return false;
|
||||
}
|
||||
|
||||
private void upgrade(AddressMap addressMapExt, TaskMonitor monitor)
|
||||
throws CancelledException {
|
||||
private void upgrade(AddressMap addressMapExt, TaskMonitor monitor) throws CancelledException {
|
||||
|
||||
OldProgramContextDB oldContext =
|
||||
new OldProgramContextDB(dbHandle, errorHandler, language, addressMapExt, lock);
|
||||
|
@ -358,7 +357,7 @@ public class ProgramRegisterContextDB extends AbstractStoredProgramContext imple
|
|||
|
||||
// May need to fill-in blank context areas with a new specified context value
|
||||
Register ctxReg = newLanguage.getContextBaseRegister();
|
||||
if (ctxReg != null && translator.isValueTranslationRequired(ctxReg)) {
|
||||
if (ctxReg != Register.NO_CONTEXT && translator.isValueTranslationRequired(ctxReg)) {
|
||||
RegisterValue gapValue = new RegisterValue(ctxReg);
|
||||
gapValue = translator.getNewRegisterValue(gapValue);
|
||||
if (gapValue != null && gapValue.hasAnyValue()) {
|
||||
|
|
|
@ -254,7 +254,7 @@ public interface Language {
|
|||
/**
|
||||
* Returns processor context base register or null if one has not been defined by the
|
||||
* language.
|
||||
* @return base context register or null if not defined
|
||||
* @return base context register or Register.NO_CONTEXT if not defined
|
||||
*/
|
||||
public Register getContextBaseRegister();
|
||||
|
||||
|
|
|
@ -43,8 +43,9 @@ public class Register implements java.io.Serializable, Comparable<Register> {
|
|||
/** Register can be used in SIMD operations **/
|
||||
public final static int TYPE_VECTOR = 128;
|
||||
|
||||
public final static Register DEFAULT_CONTEXT =
|
||||
new Register("DEFAULT_CONTEXT", "DEFAULT_CONTEXT", Address.NO_ADDRESS, 4, true, 0);
|
||||
/** Register used to denote NO defined context for a language **/
|
||||
public final static Register NO_CONTEXT =
|
||||
new Register("NO_CONTEXT", "NO_CONTEXT", Address.NO_ADDRESS, 4, true, 0);
|
||||
|
||||
private String name;
|
||||
private String description; // description of the register
|
||||
|
|
|
@ -127,7 +127,7 @@ public class RegisterManager {
|
|||
}
|
||||
// if there is no context register, force a default one
|
||||
if (contextBaseRegister == null) {
|
||||
contextBaseRegister = Register.DEFAULT_CONTEXT;
|
||||
contextBaseRegister = Register.NO_CONTEXT;
|
||||
}
|
||||
// handle the register size 0 case;
|
||||
Collections.reverse(registerListSortedBySize);
|
||||
|
|
|
@ -50,8 +50,8 @@ public class InstructionUtils {
|
|||
FlowType flowType = instruction.getFlowType();
|
||||
textBuf.append("\nFlow Type : " + flowType.toString());
|
||||
FlowOverride flowOverride = instruction.getFlowOverride();
|
||||
if (flowOverride != FlowOverride.NONE &&
|
||||
instruction.getPrototype().getFlowType(instruction.getInstructionContext()) != flowType) {
|
||||
if (flowOverride != FlowOverride.NONE && instruction.getPrototype()
|
||||
.getFlowType(instruction.getInstructionContext()) != flowType) {
|
||||
textBuf.append("\n >>> reflects " + flowOverride + " flow override");
|
||||
}
|
||||
Address fallAddr = instruction.getFallThrough();
|
||||
|
@ -62,20 +62,20 @@ public class InstructionUtils {
|
|||
textBuf.append("\nDelay slot depth : " + instruction.getDelaySlotDepth() +
|
||||
(instruction.isInDelaySlot() ? " in slot" : ""));
|
||||
textBuf.append(
|
||||
"\nHash : " + Integer.toHexString(instruction.getPrototype().hashCode())).append(
|
||||
'\n');
|
||||
"\nHash : " + Integer.toHexString(instruction.getPrototype().hashCode()))
|
||||
.append('\n');
|
||||
|
||||
textBuf.append("\nInput Objects:\n" +
|
||||
getString(getFormatedInstructionObjects(instruction, true), true));
|
||||
textBuf.append("\nResult Objects:\n" +
|
||||
getString(getFormatedInstructionObjects(instruction, false), true));
|
||||
textBuf.append(
|
||||
"\nConstructor Line #'s:\n" + getString(debug.getConstructorLineNumbers(), true)).append(
|
||||
'\n');
|
||||
"\nConstructor Line #'s:\n" + getString(debug.getConstructorLineNumbers(), true))
|
||||
.append('\n');
|
||||
textBuf.append("\nByte Length : " + instruction.getLength());
|
||||
try {
|
||||
textBuf.append("\nInstr Bytes : " +
|
||||
SleighDebugLogger.getFormattedBytes(instruction.getBytes()));
|
||||
textBuf.append(
|
||||
"\nInstr Bytes : " + SleighDebugLogger.getFormattedBytes(instruction.getBytes()));
|
||||
textBuf.append("\nMask : " + debug.getFormattedInstructionMask(-1));
|
||||
textBuf.append("\nMasked Bytes: " + debug.getFormattedMaskedValue(-1)).append('\n');
|
||||
}
|
||||
|
@ -93,10 +93,11 @@ public class InstructionUtils {
|
|||
* @param instr
|
||||
* @return formatted context data
|
||||
*/
|
||||
public static String getFormattedContextRegisterValueBreakout(Instruction instr, String indent) {
|
||||
public static String getFormattedContextRegisterValueBreakout(Instruction instr,
|
||||
String indent) {
|
||||
ProgramContext programContext = instr.getProgram().getProgramContext();
|
||||
Register contextReg = programContext.getBaseContextRegister();
|
||||
if (contextReg == null) {
|
||||
if (contextReg == Register.NO_CONTEXT) {
|
||||
return indent + "[Instruction context not defined]";
|
||||
}
|
||||
return getFormattedRegisterValueBits(instr.getRegisterValue(contextReg), indent);
|
||||
|
|
|
@ -425,9 +425,9 @@ public abstract class LanguageTranslatorAdapter implements LanguageTranslator {
|
|||
return false;
|
||||
}
|
||||
Register newContextReg = getNewLanguage().getContextBaseRegister();
|
||||
if (newContextReg != null) {
|
||||
if (newContextReg != Register.NO_CONTEXT) {
|
||||
Register oldContextReg = getOldLanguage().getContextBaseRegister();
|
||||
if (oldContextReg == null ||
|
||||
if (oldContextReg == Register.NO_CONTEXT ||
|
||||
!isSameRegisterConstruction(oldContextReg, newContextReg)) {
|
||||
Msg.error(this, "Translator can not map context register: " + this);
|
||||
return false;
|
||||
|
|
|
@ -143,8 +143,8 @@ public class OldLanguageFactory {
|
|||
langSvc.getLanguageDescription(oldLang.getLanguageID());
|
||||
if (curDescr.getVersion() <= oldDescr.getVersion()) {
|
||||
// Ignore old versions which are inappropriate
|
||||
log.warn("WARNING! Ignoring old language spec, version still exists: " +
|
||||
oldLang);
|
||||
log.warn(
|
||||
"WARNING! Ignoring old language spec, version still exists: " + oldLang);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -208,8 +208,8 @@ public class OldLanguageFactory {
|
|||
* @throws IOException if file error occurs
|
||||
* @throws LanguageNotFoundException if lang is unknown to DefaultLanguageService
|
||||
*/
|
||||
public static void createOldLanguageFile(Language lang, File file) throws IOException,
|
||||
LanguageNotFoundException {
|
||||
public static void createOldLanguageFile(Language lang, File file)
|
||||
throws IOException, LanguageNotFoundException {
|
||||
|
||||
LanguageService languageService = DefaultLanguageService.getLanguageService();
|
||||
if (lang instanceof OldLanguage) {
|
||||
|
@ -272,7 +272,7 @@ public class OldLanguageFactory {
|
|||
|
||||
Register contextReg = lang.getContextBaseRegister();
|
||||
Element registersElement = new Element("registers");
|
||||
if (contextReg != null) {
|
||||
if (contextReg != Register.NO_CONTEXT) {
|
||||
Element ctxElement = getRegisterElement(contextReg);
|
||||
int contextBitLength = contextReg.getBitLength();
|
||||
for (Register bitReg : contextReg.getChildRegisters()) {
|
||||
|
|
|
@ -160,7 +160,7 @@ class SimpleLanguageTranslator extends LanguageTranslatorAdapter {
|
|||
return super.getNewRegisterValue(oldRegisterValue);
|
||||
}
|
||||
Register newContextReg = getNewLanguage().getContextBaseRegister();
|
||||
if (newContextReg == null || (clearAllContext && contextSettings == null)) {
|
||||
if (newContextReg == Register.NO_CONTEXT || (clearAllContext && contextSettings == null)) {
|
||||
return null;
|
||||
}
|
||||
RegisterValue newValue = null;
|
||||
|
@ -220,8 +220,8 @@ class SimpleLanguageTranslator extends LanguageTranslatorAdapter {
|
|||
LanguagePostUpgradeInstructionHandler.class.getName());
|
||||
}
|
||||
Constructor<?> constructor = handlerClass.getConstructor(new Class<?>[] { Program.class });
|
||||
return (LanguagePostUpgradeInstructionHandler) constructor.newInstance(
|
||||
new Object[] { program });
|
||||
return (LanguagePostUpgradeInstructionHandler) constructor
|
||||
.newInstance(new Object[] { program });
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue
Block a user