Package ghidra.program.model.pcode
Class LocalSymbolMap
- java.lang.Object
-
- ghidra.program.model.pcode.LocalSymbolMap
-
public class LocalSymbolMap extends java.lang.Object
A container for local symbols within the decompiler's model of a function. It contains HighSymbol objects for any symbol within the scope of the function, including parameters. The container is populated either from the underlying Function object (when sending information to the decompiler) or read in from an XML description (when receiving a function model from the decompiler). HighSymbols can be obtained via Address using findLocal() or by id using getSymbol(). Parameters can be accessed specifically using getParamSymbol().
-
-
Constructor Summary
Constructors Constructor Description LocalSymbolMap(HighFunction highFunc, java.lang.String spcname)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
buildLocalDbXML(java.lang.StringBuilder resBuf, Namespace namespace)
Output an XML document representing this local variable map.boolean
containsVariableWithName(java.lang.String name)
HighSymbol
findLocal(Address addr, Address pc)
Find any local variable (including input params) by addressHighSymbol
findLocal(VariableStorage store, Address pc)
Find any local variable (including input params) by addressHighFunction
getHighFunction()
Get the decompiler's function model owning this containerjava.util.Map<java.lang.String,HighSymbol>
getNameToSymbolMap()
Construct and return a map from a HighSymbol's name to the HighSymbol objectint
getNumParams()
Get the number of parameter symbols in this scopeHighParam
getParam(int i)
HighSymbol
getParamSymbol(int i)
HighSymbol
getSymbol(long id)
Lookup high variable based upon its symbol-idjava.util.Iterator<HighSymbol>
getSymbols()
Get all the symbols mapped for this program, Param, Locals.void
grabFromFunction(boolean includeDefaultNames)
Populate the local variable map from information attached to the Program DB's function.protected HighSymbol
newDynamicSymbol(long id, java.lang.String nm, DataType dt, long hash, Address pcaddr)
protected HighSymbol
newMappedSymbol(long id, java.lang.String nm, DataType dt, VariableStorage store, Address pcaddr, int slot)
void
parseScopeXML(XmlPullParser parser)
Parse a local symbol scope in XML from the <localdb> tag.void
parseSymbolList(XmlPullParser parser)
Add mapped symbols to this LocalVariableMap, by parsing the <symbollist> and <mapsym> tags.
-
-
-
Constructor Detail
-
LocalSymbolMap
public LocalSymbolMap(HighFunction highFunc, java.lang.String spcname)
- Parameters:
highFunc
- HighFunction the local variables are defined within.spcname
- space name the local variables are defined within.
-
-
Method Detail
-
getHighFunction
public HighFunction getHighFunction()
Get the decompiler's function model owning this container- Returns:
- the owning HighFunction
-
getNameToSymbolMap
public java.util.Map<java.lang.String,HighSymbol> getNameToSymbolMap()
Construct and return a map from a HighSymbol's name to the HighSymbol object- Returns:
- the new name to symbol map
-
grabFromFunction
public void grabFromFunction(boolean includeDefaultNames)
Populate the local variable map from information attached to the Program DB's function.- Parameters:
includeDefaultNames
- is true if default symbol names should be considered locked
-
parseScopeXML
public void parseScopeXML(XmlPullParser parser) throws PcodeXMLException
Parse a local symbol scope in XML from the <localdb> tag.- Parameters:
parser
- is the XML parser- Throws:
PcodeXMLException
- for problems parsing individual tags
-
parseSymbolList
public void parseSymbolList(XmlPullParser parser) throws PcodeXMLException
Add mapped symbols to this LocalVariableMap, by parsing the <symbollist> and <mapsym> tags.- Parameters:
parser
- is the XML parser- Throws:
PcodeXMLException
- for problems parsing a tag
-
buildLocalDbXML
public void buildLocalDbXML(java.lang.StringBuilder resBuf, Namespace namespace)
Output an XML document representing this local variable map.- Parameters:
resBuf
- is the buffer to write tonamespace
- if the namespace of the function
-
getSymbols
public java.util.Iterator<HighSymbol> getSymbols()
Get all the symbols mapped for this program, Param, Locals. The HighSymbol can either be a HighParam, or HighLocal- Returns:
- an iterator over all mapped symbols.
-
findLocal
public HighSymbol findLocal(VariableStorage store, Address pc)
Find any local variable (including input params) by address- Parameters:
store
- - variable storagepc
- = Address of first use, or null if address is valid throughout the entire scope- Returns:
- HighLocal or null
-
findLocal
public HighSymbol findLocal(Address addr, Address pc)
Find any local variable (including input params) by address- Parameters:
addr
- - variable storage addresspc
- = Address of first use, or null if address is valid throughout the entire scope- Returns:
- HighLocal or null
-
getSymbol
public HighSymbol getSymbol(long id)
Lookup high variable based upon its symbol-id- Parameters:
id
- symbol-id- Returns:
- variable or null if not found
-
getNumParams
public int getNumParams()
Get the number of parameter symbols in this scope- Returns:
- the number of parameters
-
getParamSymbol
public HighSymbol getParamSymbol(int i)
- Parameters:
i
- is the desired parameter position- Returns:
- the i-th parameter HighSymbol
-
getParam
public HighParam getParam(int i)
- Parameters:
i
- is the desired parameter position- Returns:
- the i-th parameter variable
-
containsVariableWithName
public boolean containsVariableWithName(java.lang.String name)
-
newMappedSymbol
protected HighSymbol newMappedSymbol(long id, java.lang.String nm, DataType dt, VariableStorage store, Address pcaddr, int slot)
-
newDynamicSymbol
protected HighSymbol newDynamicSymbol(long id, java.lang.String nm, DataType dt, long hash, Address pcaddr)
-
-