Package ghidra.program.model.pcode
Class HighSymbol
- java.lang.Object
- 
- ghidra.program.model.pcode.HighSymbol
 
- 
- Direct Known Subclasses:
- EquateSymbol,- HighCodeSymbol,- HighExternalSymbol,- HighFunctionShellSymbol,- HighFunctionSymbol,- HighLabelSymbol
 
 public class HighSymbol extends java.lang.ObjectA symbol within the decompiler's model of a particular function. The symbol has a name and a data-type along with other properties. The symbol is mapped to one or more storage locations by attaching a SymbolEntry for each mapping.
- 
- 
Field SummaryFields Modifier and Type Field Description protected intcategoryprotected intcategoryIndexprotected SymbolEntry[]entryListprotected HighFunctionfunctionstatic longID_BASEprotected java.lang.Stringnameprotected DataTypetype
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedHighSymbol(long uniqueId, java.lang.String nm, DataType tp, boolean tlock, boolean nlock, PcodeDataTypeManager manage)Construct a symbol that is not attached to a function model.protectedHighSymbol(long uniqueId, java.lang.String nm, DataType tp, HighFunction func)Construct a base symbol, given a name and data-type.protectedHighSymbol(HighFunction func)Constructor for use with restoreXML
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddMapEntry(SymbolEntry entry)static voidbuildMapSymXML(java.lang.StringBuilder res, HighSymbol sym)Write out the given symbol with all its mapping as a <mapsym> tag to the given XML stream.intgetCategoryIndex()For parameters (category=0), this method returns the position of the parameter within the function prototype.DataTypegetDataType()protected intgetFirstUseOffset()Get the first code Address (expressed as a different in bytes from the starting address of the function) where this symbol's storage actually holds the value of the symbol.SymbolEntrygetFirstWholeMap()HighFunctiongetHighFunction()Get the function model of which this symbol is a part.HighVariablegetHighVariable()Get the HighVariable associate with this symbol if any.longgetId()Get id associated with this symbol.java.lang.StringgetName()Get the base name of this symbolNamespacegetNamespace()Fetch the namespace owning this symbol, if it exists.AddressgetPCAddress()Get the first code Address, within the function, where this symbol's storage actually holds the value of the symbol.ProgramgetProgram()Get the Program object containing the function being modeled.intgetSize()VariableStoragegetStorage()SymbolgetSymbol()Fetch the corresponding database Symbol if it exists.booleanisGlobal()Is this symbol in the global scope or some other global namespacebooleanisHiddenReturn()booleanisIsolated()If this returns true, the decompiler will not speculatively merge this with other variables.booleanisNameLocked()If this returns true, this symbol's name is "locked".booleanisParameter()Is this symbol a parameter for a functionbooleanisReadOnly()booleanisThisPointer()booleanisTypeLocked()If this returns true, this symbol's data-type is "locked", meaning it is considered unchangeable during decompilation.static HighSymbolrestoreMapSymXML(XmlPullParser parser, boolean isGlobal, HighFunction high)Restore a full HighSymbol from the next <mapsym> tag in the given XML stream.voidrestoreXML(XmlPullParser parser)Restore this symbol object and its associated mappings from an XML description in the given stream.protected voidrestoreXMLHeader(XmlElement symel)voidsaveXML(java.lang.StringBuilder buf)Save the symbol description as a tag to the XML stream.protected voidsaveXMLHeader(java.lang.StringBuilder buf)Write out attributes for the base XML tagprotected voidsetCategory(int cat, int index)Set the category and associated index for this symbol.voidsetHighVariable(HighVariable high)Associate a particular HighVariable with this symbol.voidsetNameLock(boolean namelock)Set whether this symbol's name is considered "locked".voidsetTypeLock(boolean typelock)Set whether this symbol's data-type is considered "locked".
 
- 
- 
- 
Field Detail- 
ID_BASEpublic static final long ID_BASE - See Also:
- Constant Field Values
 
 - 
nameprotected java.lang.String name 
 - 
typeprotected DataType type 
 - 
functionprotected HighFunction function 
 - 
categoryprotected int category 
 - 
categoryIndexprotected int categoryIndex 
 - 
entryListprotected SymbolEntry[] entryList 
 
- 
 - 
Constructor Detail- 
HighSymbolprotected HighSymbol(HighFunction func) Constructor for use with restoreXML- Parameters:
- func- is the HighFunction using the symbol
 
 - 
HighSymbolprotected HighSymbol(long uniqueId, java.lang.String nm, DataType tp, HighFunction func)Construct a base symbol, given a name and data-type. Mappings must be attached separately.- Parameters:
- uniqueId- is the id to associate with the new symbol
- nm- is the given name
- tp- is the given data-type
- func- is the function model owning the new symbol
 
 - 
HighSymbolprotected HighSymbol(long uniqueId, java.lang.String nm, DataType tp, boolean tlock, boolean nlock, PcodeDataTypeManager manage)Construct a symbol that is not attached to a function model. The symbol is given a name, data-type, and other basic attributes. Mappings must be attached separately.- Parameters:
- uniqueId- is the id to associate with the new symbol
- nm- is the given name
- tp- is the given data-type
- tlock- is true if the symbol is type locked
- nlock- is true if the symbol is name locked
- manage- is a PcodeDataTypeManager to facilitate XML marshaling
 
 
- 
 - 
Method Detail- 
addMapEntryprotected void addMapEntry(SymbolEntry entry) 
 - 
getIdpublic long getId() Get id associated with this symbol.- Returns:
- the id
 
 - 
getSymbolpublic Symbol getSymbol() Fetch the corresponding database Symbol if it exists.- Returns:
- the matching Symbol object or null
 
 - 
getNamespacepublic Namespace getNamespace() Fetch the namespace owning this symbol, if it exists.- Returns:
- the Namespace object or null
 
 - 
setHighVariablepublic void setHighVariable(HighVariable high) Associate a particular HighVariable with this symbol. This is used to link the symbol into the decompiler's description of how a function manipulates a particular symbol.- Parameters:
- high- is the associated HighVariable
 
 - 
getHighVariablepublic HighVariable getHighVariable() Get the HighVariable associate with this symbol if any. This allows the user to go straight into the decompiler's function to see how the symbol gets manipulated.- Returns:
- the associated HighVariable or null
 
 - 
getNamepublic java.lang.String getName() Get the base name of this symbol- Returns:
- the name
 
 - 
getProgrampublic Program getProgram() Get the Program object containing the function being modeled.- Returns:
- the Program
 
 - 
getDataTypepublic DataType getDataType() - Returns:
- the data-type associate with this symbol
 
 - 
getSizepublic int getSize() - Returns:
- the number of bytes consumed by the storage for this symbol
 
 - 
getPCAddresspublic Address getPCAddress() Get the first code Address, within the function, where this symbol's storage actually holds the value of the symbol. If there is more than one mapping for the symbol, this returns the code Address for the first mapping. A null value indicates that the storage is valid over the whole function (at least). If the value is non-null, the symbol storage may be used for other purposes at prior locations.- Returns:
- the first use code Address or null
 
 - 
getFirstUseOffsetprotected int getFirstUseOffset() Get the first code Address (expressed as a different in bytes from the starting address of the function) where this symbol's storage actually holds the value of the symbol. A value of 0 indicates that the storage is valid across the entire function. A negative value indicates the storage is an input to the function.- Returns:
- the first-use offset of this symbol's storage
 
 - 
getHighFunctionpublic HighFunction getHighFunction() Get the function model of which this symbol is a part.- Returns:
- the HighFunction owning this symbol
 
 - 
setCategoryprotected void setCategory(int cat, int index)Set the category and associated index for this symbol. The category indicates a specific sub-class of symbols. Currently -1=none, 0=parameter, 1=equate- Parameters:
- cat- is the category
- index- is the category index ("slot" for parameters)
 
 - 
setTypeLockpublic void setTypeLock(boolean typelock) Set whether this symbol's data-type is considered "locked". If it is "locked", this symbol's data-type is considered unchangeable during decompilation. The data-type will be forced into the decompiler's model of the function to the extent possible.- Parameters:
- typelock- is true if the data-type should be considered "locked".
 
 - 
setNameLockpublic void setNameLock(boolean namelock) Set whether this symbol's name is considered "locked". If it is "locked", the decompiler will use the name when labeling the storage described by this symbol.- Parameters:
- namelock- is true if the name should be considered "locked".
 
 - 
isTypeLockedpublic boolean isTypeLocked() If this returns true, this symbol's data-type is "locked", meaning it is considered unchangeable during decompilation. The data-type will be forced into the decompiler's model of the function to the extent possible.- Returns:
- true if the data-type is considered "locked".
 
 - 
isNameLockedpublic boolean isNameLocked() If this returns true, this symbol's name is "locked". meaning the decompiler is forced to use the name when labeling the storage described by this symbol.- Returns:
- true if the name is considered "locked".
 
 - 
isIsolatedpublic boolean isIsolated() If this returns true, the decompiler will not speculatively merge this with other variables. Currently, being isolated is equivalent to being typelocked.- Returns:
- true if this will not be merged with other variables
 
 - 
isReadOnlypublic boolean isReadOnly() - Returns:
- true if the symbol's value is considered read-only (by the decompiler)
 
 - 
isParameterpublic boolean isParameter() Is this symbol a parameter for a function- Returns:
- true if this is a parameter
 
 - 
getCategoryIndexpublic int getCategoryIndex() For parameters (category=0), this method returns the position of the parameter within the function prototype.- Returns:
- the category index for this symbol
 
 - 
isGlobalpublic boolean isGlobal() Is this symbol in the global scope or some other global namespace- Returns:
- true if this is global
 
 - 
isThisPointerpublic boolean isThisPointer() - Returns:
- true if symbol is a "this" pointer for a class method
 
 - 
isHiddenReturnpublic boolean isHiddenReturn() - Returns:
- true is symbol holds a pointer to where a function's return value should be stored
 
 - 
getFirstWholeMappublic SymbolEntry getFirstWholeMap() - Returns:
- the first mapping object attached to this symbol
 
 - 
getStoragepublic VariableStorage getStorage() - Returns:
- the storage associated with this symbol (associated with the first mapping)
 
 - 
saveXMLHeaderprotected void saveXMLHeader(java.lang.StringBuilder buf) Write out attributes for the base XML tag- Parameters:
- buf- is the XML output stream
 
 - 
saveXMLpublic void saveXML(java.lang.StringBuilder buf) Save the symbol description as a tag to the XML stream. This does NOT save the mappings.- Parameters:
- buf- is the XML stream
 
 - 
restoreXMLHeaderprotected void restoreXMLHeader(XmlElement symel) throws PcodeXMLException - Throws:
- PcodeXMLException
 
 - 
restoreXMLpublic void restoreXML(XmlPullParser parser) throws PcodeXMLException Restore this symbol object and its associated mappings from an XML description in the given stream.- Parameters:
- parser- is the given XML stream
- Throws:
- PcodeXMLException- if the XML description is invalid
 
 - 
restoreMapSymXMLpublic static HighSymbol restoreMapSymXML(XmlPullParser parser, boolean isGlobal, HighFunction high) throws PcodeXMLException Restore a full HighSymbol from the next <mapsym> tag in the given XML stream. This method acts as an XML based HighSymbol factory, instantiating the correct class based on the particular tags.- Parameters:
- parser- is the given XML stream
- isGlobal- is true if this symbol is being read into a global scope
- high- is the function model that will own the new symbol
- Returns:
- the new symbol
- Throws:
- PcodeXMLException- if the XML description is invalid
 
 - 
buildMapSymXMLpublic static void buildMapSymXML(java.lang.StringBuilder res, HighSymbol sym)Write out the given symbol with all its mapping as a <mapsym> tag to the given XML stream.- Parameters:
- res- is the given XML stream
- sym- is the given symbol
 
 
- 
 
-