Class SleighLanguage
java.lang.Object
ghidra.app.plugin.processors.sleigh.SleighLanguage
- All Implemented Interfaces:
Language
-
Method Summary
Modifier and TypeMethodDescriptionvoidapplyContextSettings(DefaultProgramContext programContext) Apply context settings to the ProgramContext as specified by the configurationvoidencodeTranslator(Encoder encoder, AddressFactory factory, long uniqueOffset) Encode limited information to the stream about the SLEIGH translator for the specified address factory and optional register set.Get the AddressFactory for this language.Returns a list of all compatible compiler spec descriptions.getCompilerSpecByID(CompilerSpecID compilerSpecID) Returns the compiler spec associated with a given CompilerSpecID.Returns processor context base register or null if one has not been defined by the language.Get an unsorted unmodifiable list of processor context registers that this language defines (includes context base register and its context field registers).Returns the default compiler spec for this language, which is used when a loader cannot determine the compiler spec or for upgrades when a program had no compiler spec registered (seriously old program, like Ghidra 4.1 or earlier).Get the preferred data space used by loaders for data sections.Returns the default memory blocks for this language.intDeprecated.Will be removed once we have better way to attach address spaces to pointer data-typesGet the default memory/code space.Returns the default symbols for this language.intGet instruction alignment in terms of bytes.Returns the LanguageDescription of this language, which contains useful information about the characteristics of the language.Returns the LanguageID of this language, which is used as a primary key to find the language when Ghidra loads it.getManualEntry(String instruction) Get the ManualEntry for the given instruction mnemonic.Returns the exception generated trying to load the manual, or null if it succeeded.Returns a read-only set view of the instruction mnemonic keys defined on this language.intReturns the minor version for this language.intGet the total number of user defined pcode names.Returns a parallel instruction helper for this language or null if one has not been defined.Returns the processor name on which this language is based.Get the default program counter register for this language if there is one.getProperty(String key) Gets a property defined for this language, or null if that property isn't defined.getProperty(String key, String defaultString) Gets the value of a property as a String, returning defaultString if undefined.booleangetPropertyAsBoolean(String key, boolean defaultBoolean) Gets the value of a property as a boolean, returning defaultBoolean if undefined.intgetPropertyAsInt(String key, int defaultInt) Gets the value of a property as an int, returning defaultInt if undefined.Returns a read-only set view of the property keys defined on this language.getRegister(Address addr, int size) Get a register given it's underlying address location and size.getRegister(AddressSpace addrspc, long offset, int size) Get a register given the address space it is in, its offset in the space and its size.getRegister(String name) Get a register given the name of the registerReturns address set of all registers.Get an alphabetical sorted unmodifiable list of original register names (including context registers).Get an unsorted unmodifiable list of Register objects that this language defines (including context registers).Register[]getRegisters(Address address) Returns all the registers (each different size is a different register) for an address.Returns the name of the segmented space for this language, or the empty string if the memory model for this language is not segmented.Returns an unmodifiable list of vector registers, sorted first by size and then by name.Returns the source file indexerintlongReturns the unique base offset from which additional temporary variables may be created.getUserDefinedOpName(int index) Get the user define name for a given index.intReturns the major version for this language.Returns an AddressSetView of the volatile addresses for this languagebooleanReturns whether the language has a valid manual defined.booleanhasProperty(String key) Returns whether this lanugage has a property defined.booleanget the Endian type for this language.booleanisVolatile(Address addr) Returns true if the language has defined the specified location as volatile.voidloadIndex(ResourceFile processorFile) intparse(MemBuffer buf, ProcessorContext context, boolean inDelaySlot) Get the InstructionPrototype that matches the bytes presented by the MemBuffer object.voidreloadLanguage(TaskMonitor monitor) Refreshes the definition of this language if possible.booleanReturn true if the instructions in this language support Pcode.toString()
-
Method Details
-
getUniqueBase
public long getUniqueBase()Returns the unique base offset from which additional temporary variables may be created.- Returns:
- unique base offset
-
getUniqueAllocationMask
public int getUniqueAllocationMask() -
numSections
public int numSections()- Returns:
- (maximum) number of named p-code sections
-
toString
-
applyContextSettings
Description copied from interface:LanguageApply context settings to the ProgramContext as specified by the configuration- Specified by:
applyContextSettingsin interfaceLanguage- Parameters:
programContext- is the default program context
-
getAddressFactory
Description copied from interface:LanguageGet the AddressFactory for this language. The returned Address factory will allow addresses associated with physical, constant and unique spaces to be instantiated. NOTE! this factory does not know about compiler or program specified spaces. Spaces such as stack and overlay spaces are not defined by the language - if these are needed, Program.getAddressFactory() should be used instead.- Specified by:
getAddressFactoryin interfaceLanguage- Returns:
- the AddressFactory for this language.
- See Also:
-
getAdditionalInject
-
getContextBaseRegister
Description copied from interface:LanguageReturns processor context base register or null if one has not been defined by the language.- Specified by:
getContextBaseRegisterin interfaceLanguage- Returns:
- base context register or Register.NO_CONTEXT if not defined
-
getContextRegisters
Description copied from interface:LanguageGet an unsorted unmodifiable list of processor context registers that this language defines (includes context base register and its context field registers).- Specified by:
getContextRegistersin interfaceLanguage- Returns:
- unmodifiable list of processor registers.
-
getDefaultMemoryBlocks
Description copied from interface:LanguageReturns the default memory blocks for this language.- Specified by:
getDefaultMemoryBlocksin interfaceLanguage- Returns:
- the default memory blocks for this language
-
getProgramCounter
Description copied from interface:LanguageGet the default program counter register for this language if there is one.- Specified by:
getProgramCounterin interfaceLanguage- Returns:
- default program counter register.
-
getDefaultSymbols
Description copied from interface:LanguageReturns the default symbols for this language. This list does not contain registers.- Specified by:
getDefaultSymbolsin interfaceLanguage- Returns:
- the default symbols for this language
-
getInstructionAlignment
public int getInstructionAlignment()Description copied from interface:LanguageGet instruction alignment in terms of bytes.- Specified by:
getInstructionAlignmentin interfaceLanguage- Returns:
- instruction alignment
-
getMinorVersion
public int getMinorVersion()Description copied from interface:LanguageReturns the minor version for this language. Returning a minor version number different than before could cause the program to try and "update" itself. Those languages which do not support this feature may always return a constant value of 0.- Specified by:
getMinorVersionin interfaceLanguage- Returns:
- the language minor version number
-
getLanguageID
Description copied from interface:LanguageReturns the LanguageID of this language, which is used as a primary key to find the language when Ghidra loads it.- Specified by:
getLanguageIDin interfaceLanguage- Returns:
- the LanguageID of this language
-
getUserDefinedOpName
Description copied from interface:LanguageGet the user define name for a given index. Certain pcode has operations defined only by name that when the pcode returns, only the index is known. Note: only works for Pcode based languages- Specified by:
getUserDefinedOpNamein interfaceLanguage- Parameters:
index- user defined pcodeop index- Returns:
- pcodeop name or null if not defined
-
getNumberOfUserDefinedOpNames
public int getNumberOfUserDefinedOpNames()Description copied from interface:LanguageGet the total number of user defined pcode names. Note: only works for Pcode based languages- Specified by:
getNumberOfUserDefinedOpNamesin interfaceLanguage- Returns:
- number of user defined pcodeops
-
getProcessor
Description copied from interface:LanguageReturns the processor name on which this language is based. For example, 30386, Pentium, 68010, etc.- Specified by:
getProcessorin interfaceLanguage- Returns:
- the processor name
-
getRegister
Description copied from interface:LanguageGet a register given the address space it is in, its offset in the space and its size.- Specified by:
getRegisterin interfaceLanguage- Parameters:
addrspc- address space the register is inoffset- offset of the register in the spacesize- size of the register in bytes- Returns:
- the register
-
getRegister
Description copied from interface:LanguageGet a register given the name of the register- Specified by:
getRegisterin interfaceLanguage- Parameters:
name- Register name- Returns:
- the register
-
getRegister
Description copied from interface:LanguageGet a register given it's underlying address location and size.- Specified by:
getRegisterin interfaceLanguage- Parameters:
addr- location of the register in its address spacesize- the size of the register (in bytes). A value of 0 will return the largest register at the specified addr- Returns:
- the register
-
getRegisters
Description copied from interface:LanguageReturns all the registers (each different size is a different register) for an address.- Specified by:
getRegistersin interfaceLanguage- Parameters:
address- the register address for which to return all registers.- Returns:
- all the registers (each different size is a different register) for an address.
-
getRegisters
Description copied from interface:LanguageGet an unsorted unmodifiable list of Register objects that this language defines (including context registers).- Specified by:
getRegistersin interfaceLanguage- Returns:
- unmodifiable list of processor registers.
-
getRegisterNames
Description copied from interface:LanguageGet an alphabetical sorted unmodifiable list of original register names (including context registers). Names correspond to orignal register name and not aliases which may be defined.- Specified by:
getRegisterNamesin interfaceLanguage- Returns:
- alphabetical sorted unmodifiable list of original register names.
-
getSegmentedSpace
Description copied from interface:LanguageReturns the name of the segmented space for this language, or the empty string if the memory model for this language is not segmented.- Specified by:
getSegmentedSpacein interfaceLanguage- Returns:
- the name of the segmented space or ""
-
getVersion
public int getVersion()Description copied from interface:LanguageReturns the major version for this language. Returning a version number different than before could cause the program to try and "update" itself. Those languages which do not support this feature may always return a constant value of 1.- Specified by:
getVersionin interfaceLanguage- Returns:
- the language version number
-
getVolatileAddresses
Description copied from interface:LanguageReturns an AddressSetView of the volatile addresses for this language- Specified by:
getVolatileAddressesin interfaceLanguage- Returns:
- an AddressSetView of the volatile addresses for this language
-
isBigEndian
public boolean isBigEndian()Description copied from interface:Languageget the Endian type for this language. (If a language supports both, then this returns an initial or default value.)- Specified by:
isBigEndianin interfaceLanguage- Returns:
- true for BigEndian, false for LittleEndian.
-
isVolatile
Description copied from interface:LanguageReturns true if the language has defined the specified location as volatile.- Specified by:
isVolatilein interfaceLanguage- Parameters:
addr- location address- Returns:
- true if specified address is within a volatile range
-
parse
public InstructionPrototype parse(MemBuffer buf, ProcessorContext context, boolean inDelaySlot) throws InsufficientBytesException, UnknownInstructionException Description copied from interface:LanguageGet the InstructionPrototype that matches the bytes presented by the MemBuffer object.- Specified by:
parsein interfaceLanguage- Parameters:
buf- the MemBuffer that presents the bytes in Memory at some address as if they were an array of bytes starting at index 0.context- the processor context at the address to be disassembledinDelaySlot- true if this instruction should be parsed as if it were in a delay slot- Returns:
- the InstructionPrototype that matches the bytes in buf.
- Throws:
InsufficientBytesException- thrown if there are not enough bytes in memory to satisfy a legal instruction.UnknownInstructionException- thrown if the byte pattern does not match any legal instruction.
-
getRootDecisionNode
-
getSymbolTable
-
getSourceFileIndexer
Returns the source file indexer- Returns:
- indexer
-
reloadLanguage
Description copied from interface:LanguageRefreshes the definition of this language if possible. Use of this method is intended for development purpose only since stale references to prior language resources (e.g., registers) may persist.- Specified by:
reloadLanguagein interfaceLanguage- Parameters:
monitor- monitor for progress back to the user- Throws:
IOException- if error occurs while reloading language spec file(s)
-
supportsPcode
public boolean supportsPcode()Description copied from interface:LanguageReturn true if the instructions in this language support Pcode.- Specified by:
supportsPcodein interfaceLanguage- Returns:
- true if language supports the use of pcode
-
getDefaultSpace
Description copied from interface:LanguageGet the default memory/code space.- Specified by:
getDefaultSpacein interfaceLanguage- Returns:
- default address space
-
getDefaultDataSpace
Description copied from interface:LanguageGet the preferred data space used by loaders for data sections.- Specified by:
getDefaultDataSpacein interfaceLanguage- Returns:
- default data address space
-
getDefaultPointerWordSize
Deprecated.Will be removed once we have better way to attach address spaces to pointer data-types- Returns:
- the default wordsize to use when analyzing pointer offsets
-
getCompatibleCompilerSpecDescriptions
Description copied from interface:LanguageReturns a list of all compatible compiler spec descriptions. The first item in the list is the default.- Specified by:
getCompatibleCompilerSpecDescriptionsin interfaceLanguage- Returns:
- list of all compatible compiler specifications descriptions
-
getCompilerSpecByID
public CompilerSpec getCompilerSpecByID(CompilerSpecID compilerSpecID) throws CompilerSpecNotFoundException Description copied from interface:LanguageReturns the compiler spec associated with a given CompilerSpecID.- Specified by:
getCompilerSpecByIDin interfaceLanguage- Parameters:
compilerSpecID- the compiler spec id- Returns:
- the compiler spec associated with the given id
- Throws:
CompilerSpecNotFoundException- if no such compiler spec exists
-
getLanguageDescription
Description copied from interface:LanguageReturns the LanguageDescription of this language, which contains useful information about the characteristics of the language.- Specified by:
getLanguageDescriptionin interfaceLanguage- Returns:
- the LanguageDescription of this language
-
getDefaultCompilerSpec
Description copied from interface:LanguageReturns the default compiler spec for this language, which is used when a loader cannot determine the compiler spec or for upgrades when a program had no compiler spec registered (seriously old program, like Ghidra 4.1 or earlier). NOTE: this has NOTHING to do with the compiler spec registered for a program. Use Program.getCompilerSpec() for that!- Specified by:
getDefaultCompilerSpecin interfaceLanguage- Returns:
- the default compiler spec for this language
-
getProperty
Description copied from interface:LanguageGets a property defined for this language, or null if that property isn't defined.- Specified by:
getPropertyin interfaceLanguage- Parameters:
key- the property key- Returns:
- the property value, or null if not defined
-
getPropertyKeys
Description copied from interface:LanguageReturns a read-only set view of the property keys defined on this language.- Specified by:
getPropertyKeysin interfaceLanguage- Returns:
- read-only set of property keys
-
getProperty
Description copied from interface:LanguageGets the value of a property as a String, returning defaultString if undefined.- Specified by:
getPropertyin interfaceLanguage- Parameters:
key- the property keydefaultString- the default value to return if property is undefined- Returns:
- the property value as a String, or the default value if undefined
-
getPropertyAsBoolean
Description copied from interface:LanguageGets the value of a property as a boolean, returning defaultBoolean if undefined.- Specified by:
getPropertyAsBooleanin interfaceLanguage- Parameters:
key- the property keydefaultBoolean- the default value to return if property is undefined- Returns:
- the property value as a boolean, or the default value if undefined
-
getPropertyAsInt
Description copied from interface:LanguageGets the value of a property as an int, returning defaultInt if undefined.- Specified by:
getPropertyAsIntin interfaceLanguage- Parameters:
key- the property keydefaultInt- the default value to return if property is undefined- Returns:
- the property value as an int, or the default value if undefined
-
hasProperty
Description copied from interface:LanguageReturns whether this lanugage has a property defined.- Specified by:
hasPropertyin interfaceLanguage- Parameters:
key- the property key- Returns:
- if the property is defined
-
getManualEntry
Description copied from interface:LanguageGet the ManualEntry for the given instruction mnemonic.- Specified by:
getManualEntryin interfaceLanguage- Parameters:
instruction- the instruction mnemonic- Returns:
- the ManualEntry or null. A default manual entry will be returned if an instruction can not be found within the index and a manual exists.
-
getManualInstructionMnemonicKeys
Description copied from interface:LanguageReturns a read-only set view of the instruction mnemonic keys defined on this language.- Specified by:
getManualInstructionMnemonicKeysin interfaceLanguage- Returns:
- read-only set of instruction mnemonic keys
-
loadIndex
- Throws:
IOException
-
getManualException
Description copied from interface:LanguageReturns the exception generated trying to load the manual, or null if it succeeded.- Specified by:
getManualExceptionin interfaceLanguage- Returns:
- the exception generated trying to load the manual, or null if it succeeded
-
hasManual
public boolean hasManual()Description copied from interface:LanguageReturns whether the language has a valid manual defined. -
encodeTranslator
public void encodeTranslator(Encoder encoder, AddressFactory factory, long uniqueOffset) throws IOException Encode limited information to the stream about the SLEIGH translator for the specified address factory and optional register set.- Parameters:
encoder- is the stream encoderfactory- is the specified address factoryuniqueOffset- the initial offset within the unique address space to start assigning temporary registers- Throws:
IOException- for errors writing to the underlying stream
-
getParallelInstructionHelper
Description copied from interface:LanguageReturns a parallel instruction helper for this language or null if one has not been defined.- Specified by:
getParallelInstructionHelperin interfaceLanguage- Returns:
- parallel instruction helper or null if not applicable
-
getSortedVectorRegisters
Description copied from interface:LanguageReturns an unmodifiable list of vector registers, sorted first by size and then by name.- Specified by:
getSortedVectorRegistersin interfaceLanguage- Returns:
- unmodifiable list of vector registers.
-
getRegisterAddresses
Description copied from interface:LanguageReturns address set of all registers.- Specified by:
getRegisterAddressesin interfaceLanguage- Returns:
- the address set.
-