Package ghidra.program.model.lang
Interface Language
- All Known Implementing Classes:
SleighLanguage
public interface Language
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Apply context settings to the ProgramContext as specified by the configurationGet 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.Get the default memory/code space.Returns the default symbols for this language.int
Get 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 instructionMnemonic) 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.int
Returns the minor version for this language.int
Get 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.boolean
getPropertyAsBoolean
(String key, boolean defaultBoolean) Gets the value of a property as a boolean, returning defaultBoolean if undefined.int
getPropertyAsInt
(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.getUserDefinedOpName
(int index) Get the user define name for a given index.int
Returns the major version for this language.Returns an AddressSetView of the volatile addresses for this languageboolean
Returns whether the language has a valid manual defined.boolean
hasProperty
(String key) Returns whether this lanugage has a property defined.boolean
get the Endian type for this language.boolean
isVolatile
(Address addr) Returns true if the language has defined the specified location as volatile.parse
(MemBuffer buf, ProcessorContext context, boolean inDelaySlot) Get the InstructionPrototype that matches the bytes presented by the MemBuffer object.void
reloadLanguage
(TaskMonitor taskMonitor) Refreshes the definition of this language if possible.boolean
Return true if the instructions in this language support Pcode.
-
Method Details
-
getLanguageID
LanguageID getLanguageID()Returns the LanguageID of this language, which is used as a primary key to find the language when Ghidra loads it.- Returns:
- the LanguageID of this language
-
getLanguageDescription
LanguageDescription getLanguageDescription()Returns the LanguageDescription of this language, which contains useful information about the characteristics of the language.- Returns:
- the LanguageDescription of this language
-
getParallelInstructionHelper
ParallelInstructionLanguageHelper getParallelInstructionHelper()Returns a parallel instruction helper for this language or null if one has not been defined.- Returns:
- parallel instruction helper or null if not applicable
-
getProcessor
Processor getProcessor()Returns the processor name on which this language is based. For example, 30386, Pentium, 68010, etc.- Returns:
- the processor name
-
getVersion
int getVersion()Returns 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.- Returns:
- the language version number
-
getMinorVersion
int getMinorVersion()Returns 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.- Returns:
- the language minor version number
-
getAddressFactory
AddressFactory getAddressFactory()Get 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.- Returns:
- the AddressFactory for this language.
- See Also:
-
getDefaultSpace
AddressSpace getDefaultSpace()Get the default memory/code space.- Returns:
- default address space
-
getDefaultDataSpace
AddressSpace getDefaultDataSpace()Get the preferred data space used by loaders for data sections.- Returns:
- default data address space
-
isBigEndian
boolean isBigEndian()get the Endian type for this language. (If a language supports both, then this returns an initial or default value.)- Returns:
- true for BigEndian, false for LittleEndian.
-
getInstructionAlignment
int getInstructionAlignment()Get instruction alignment in terms of bytes.- Returns:
- instruction alignment
-
supportsPcode
boolean supportsPcode()Return true if the instructions in this language support Pcode.- Returns:
- true if language supports the use of pcode
-
isVolatile
Returns true if the language has defined the specified location as volatile.- Parameters:
addr
- location address- Returns:
- true if specified address is within a volatile range
-
parse
InstructionPrototype parse(MemBuffer buf, ProcessorContext context, boolean inDelaySlot) throws InsufficientBytesException, UnknownInstructionException Get the InstructionPrototype that matches the bytes presented by the MemBuffer object.- 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.
-
getNumberOfUserDefinedOpNames
int getNumberOfUserDefinedOpNames()Get the total number of user defined pcode names. Note: only works for Pcode based languages- Returns:
- number of user defined pcodeops
-
getUserDefinedOpName
Get 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- Parameters:
index
- user defined pcodeop index- Returns:
- pcodeop name or null if not defined
-
getRegisters
Returns all the registers (each different size is a different register) for an address.- 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.
-
getRegister
Get a register given the address space it is in, its offset in the space and its size.- Parameters:
addrspc
- address space the register is inoffset
- offset of the register in the spacesize
- size of the register in bytes- Returns:
- the register
-
getRegisters
Get an unsorted unmodifiable list of Register objects that this language defines (including context registers).- Returns:
- unmodifiable list of processor registers.
-
getRegisterNames
Get 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.- Returns:
- alphabetical sorted unmodifiable list of original register names.
-
getRegister
Get a register given the name of the register- Parameters:
name
- Register name- Returns:
- the register
-
getRegister
Get a register given it's underlying address location and size.- 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
-
getProgramCounter
Register getProgramCounter()Get the default program counter register for this language if there is one.- Returns:
- default program counter register.
-
getContextBaseRegister
Register getContextBaseRegister()Returns processor context base register or null if one has not been defined by the language.- Returns:
- base context register or Register.NO_CONTEXT if not defined
-
getContextRegisters
Get an unsorted unmodifiable list of processor context registers that this language defines (includes context base register and its context field registers).- Returns:
- unmodifiable list of processor registers.
-
getDefaultMemoryBlocks
MemoryBlockDefinition[] getDefaultMemoryBlocks()Returns the default memory blocks for this language.- Returns:
- the default memory blocks for this language
-
getDefaultSymbols
List<AddressLabelInfo> getDefaultSymbols()Returns the default symbols for this language. This list does not contain registers.- Returns:
- the default symbols for this language
-
getSegmentedSpace
String getSegmentedSpace()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:
- the name of the segmented space or ""
-
getVolatileAddresses
AddressSetView getVolatileAddresses()Returns an AddressSetView of the volatile addresses for this language- Returns:
- an AddressSetView of the volatile addresses for this language
-
applyContextSettings
Apply context settings to the ProgramContext as specified by the configuration- Parameters:
ctx
- is the default program context
-
reloadLanguage
Refreshes 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.- Parameters:
taskMonitor
- monitor for progress back to the user- Throws:
IOException
- if error occurs while reloading language spec file(s)
-
getCompatibleCompilerSpecDescriptions
List<CompilerSpecDescription> getCompatibleCompilerSpecDescriptions()Returns a list of all compatible compiler spec descriptions. The first item in the list is the default.- Returns:
- list of all compatible compiler specifications descriptions
-
getCompilerSpecByID
CompilerSpec getCompilerSpecByID(CompilerSpecID compilerSpecID) throws CompilerSpecNotFoundException Returns the compiler spec associated with a given CompilerSpecID.- Parameters:
compilerSpecID
- the compiler spec id- Returns:
- the compiler spec associated with the given id
- Throws:
CompilerSpecNotFoundException
- if no such compiler spec exists
-
getDefaultCompilerSpec
CompilerSpec getDefaultCompilerSpec()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). NOTE: this has NOTHING to do with the compiler spec registered for a program. Use Program.getCompilerSpec() for that!- Returns:
- the default compiler spec for this language
-
hasProperty
Returns whether this lanugage has a property defined.- Parameters:
key
- the property key- Returns:
- if the property is defined
-
getPropertyAsInt
Gets the value of a property as an int, returning defaultInt if undefined.- 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
-
getPropertyAsBoolean
Gets the value of a property as a boolean, returning defaultBoolean if undefined.- 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
-
getProperty
Gets the value of a property as a String, returning defaultString if undefined.- 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
-
getProperty
Gets a property defined for this language, or null if that property isn't defined.- Parameters:
key
- the property key- Returns:
- the property value, or null if not defined
-
getPropertyKeys
Returns a read-only set view of the property keys defined on this language.- Returns:
- read-only set of property keys
-
hasManual
boolean hasManual()Returns whether the language has a valid manual defined.- Returns:
- if the language has a manual
-
getManualEntry
Get the ManualEntry for the given instruction mnemonic.- Parameters:
instructionMnemonic
- 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
Returns a read-only set view of the instruction mnemonic keys defined on this language.- Returns:
- read-only set of instruction mnemonic keys
-
getManualException
Exception getManualException()Returns the exception generated trying to load the manual, or null if it succeeded.- Returns:
- the exception generated trying to load the manual, or null if it succeeded
-
getSortedVectorRegisters
Returns an unmodifiable list of vector registers, sorted first by size and then by name.- Returns:
- unmodifiable list of vector registers.
-
getRegisterAddresses
AddressSetView getRegisterAddresses()Returns address set of all registers.- Returns:
- the address set.
-