Class AssemblyDefaultContext
java.lang.Object
ghidra.app.plugin.assembler.sleigh.sem.AssemblyDefaultContext
- All Implemented Interfaces:
DisassemblerContext,ProcessorContext,ProcessorContextView,DefaultProgramContext
public class AssemblyDefaultContext
extends Object
implements DisassemblerContext, DefaultProgramContext
A class that computes the default context for a language, and acts as a pseudo context
This class helps maintain context consistency when performing both assembly and disassembly.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Addressprotected AssemblyPatternBlockprotected static final DbgTimerprotected AssemblyPatternBlockprotected final SleighLanguage -
Constructor Summary
ConstructorsModifierConstructorDescriptionCompute the default context at most addresses for the given languageprotectedAssemblyDefaultContext(SleighLanguage lang, Address at) Compute the default context at the given address for the given language -
Method Summary
Modifier and TypeMethodDescriptionvoidclearRegister(Register register) Clears the register within this context.Get the default value of the context registergetDefaultAt(Address addr) Compute the default value of the context register at the given addressgetDefaultValue(Register register, Address address) Returns the default value of a register at a given address.getRegister(String name) Get a Register given the name of a registerReturns all the Registers for the processor as an unmodifiable listgetRegisterValue(Register register) Get the RegisterValue for the given register.Get the contents of a processor register as a BigInteger objectbooleanReturns true if a value is defined for the given register.voidsetContextRegister(byte[] val) Set the value of the pseudo context registervoidvoidsetDefaultValue(RegisterValue registerValue, Address start, Address end) Associates a default value with the given register over the given range.voidsetFutureRegisterValue(Address fromAddr, Address toAddr, RegisterValue value) Combinesvaluewith any previously saved future register value atfromAddr/toAddror any value stored in the program if there is no previously saved future value.voidsetFutureRegisterValue(Address address, RegisterValue value) Combinesvaluewith any previously saved future register value ataddressor any value stored in the program if there is no previously saved future value.voidsetRegisterValue(RegisterValue value) Sets the specified register value within this context.voidsetValue(Register register, BigInteger value) Sets the value for a Register.
-
Field Details
-
lang
-
at
-
curctx
-
defctx
-
dbg
-
-
Constructor Details
-
AssemblyDefaultContext
Compute the default context at most addresses for the given language- Parameters:
lang- the language
-
AssemblyDefaultContext
Compute the default context at the given address for the given language- Parameters:
lang- the languageat- the address
-
-
Method Details
-
setContextRegister
public void setContextRegister(byte[] val) Set the value of the pseudo context registerIf the provided value has length less than the register, it will be left aligned, and the remaining bytes will be set to unknown (masked out).
- Parameters:
val- the value of the register
-
setContextRegister
-
getDefault
Get the default value of the context register- Returns:
- the value as a pattern block for assembly
-
getDefaultAt
Compute the default value of the context register at the given address- Parameters:
addr- the addres- Returns:
- the value as a pattern block for assembly
-
setValue
Description copied from interface:ProcessorContextSets the value for a Register.- Specified by:
setValuein interfaceProcessorContext- Parameters:
register- the register to have its value setvalue- the value for the register (null is not permitted).- Throws:
ContextChangeException- an illegal attempt to change context was made
-
setRegisterValue
Description copied from interface:ProcessorContextSets the specified register value within this context.- Specified by:
setRegisterValuein interfaceProcessorContext- Parameters:
value- register value- Throws:
ContextChangeException- an illegal attempt to change context was made
-
clearRegister
Description copied from interface:ProcessorContextClears the register within this context.- Specified by:
clearRegisterin interfaceProcessorContext- Parameters:
register- register to be cleared.- Throws:
ContextChangeException- an illegal attempt to change context was made
-
getBaseContextRegister
- Specified by:
getBaseContextRegisterin interfaceProcessorContextView- Returns:
- the base processor context register or null if one has not been defined
-
getRegisters
Description copied from interface:ProcessorContextViewReturns all the Registers for the processor as an unmodifiable list- Specified by:
getRegistersin interfaceProcessorContextView- Returns:
- all the Registers for the processor
-
getRegister
Description copied from interface:ProcessorContextViewGet a Register given the name of a register- Specified by:
getRegisterin interfaceProcessorContextView- Parameters:
name- the name of the register.- Returns:
- The register with the given name.
-
getValue
Description copied from interface:ProcessorContextViewGet the contents of a processor register as a BigInteger object- Specified by:
getValuein interfaceProcessorContextView- Parameters:
register- register to get the value for- Returns:
- a BigInteger object containing the value of the register if a value exists, otherwise null.
-
getRegisterValue
Description copied from interface:ProcessorContextViewGet the RegisterValue for the given register.- Specified by:
getRegisterValuein interfaceProcessorContextView- Parameters:
register- register to get the value for- Returns:
- RegisterValue object containing the value of the register if a value exists, otherwise null.
-
hasValue
Description copied from interface:ProcessorContextViewReturns true if a value is defined for the given register.- Specified by:
hasValuein interfaceProcessorContextView- Parameters:
register- the register to check for a value.- Returns:
- true if the given register has a value.
-
setFutureRegisterValue
Description copied from interface:DisassemblerContextCombinesvaluewith any previously saved future register value ataddressor any value stored in the program if there is no previously saved future value. Use this method when multiple flows to the same address don't matter or the flowing from address is unknown.
Whenvaluehas conflicting bits with the previously saved value,valuewill take precedence.
If the register value is the value for the processor context register and a previously saved value does not exist, the user saved values in the stored context of the program will be used as existing value.- Specified by:
setFutureRegisterValuein interfaceDisassemblerContext- Parameters:
address- the address to store the register valuevalue- the register value to store at the address
-
setFutureRegisterValue
Description copied from interface:DisassemblerContextCombinesvaluewith any previously saved future register value atfromAddr/toAddror any value stored in the program if there is no previously saved future value.
Whenvaluehas conflicting bits with the previously saved value,valuewill take precedence.
If the register value is the value for the processor context register and a previously saved value does not exist, the user saved values in the stored context of the program will be used as existing value.- Specified by:
setFutureRegisterValuein interfaceDisassemblerContext- Parameters:
fromAddr- the address this value if flowing fromtoAddr- the address to store the register valuevalue- the register value to store at the address
-
setDefaultValue
Description copied from interface:DefaultProgramContextAssociates a default value with the given register over the given range.- Specified by:
setDefaultValuein interfaceDefaultProgramContext- Parameters:
registerValue- the register for which to associate a default value.start- the start address.end- the end address (inclusive)
-
getDefaultValue
Description copied from interface:DefaultProgramContextReturns the default value of a register at a given address.- Specified by:
getDefaultValuein interfaceDefaultProgramContext- Parameters:
register- the register for which to get a default value.address- the address at which to get a default value.- Returns:
- the default value of the register at the given address or null if no default value has been assigned.
-