Package ghidra.program.model.pcode
Class LocalSymbolMap
java.lang.Object
ghidra.program.model.pcode.LocalSymbolMap
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
decodeScope
(Decoder decoder) Decode a local symbol scope from the streamvoid
decodeSymbolList
(Decoder decoder) Add mapped symbols to this LocalVariableMap, by decoding the <symbollist> and <mapsym> elementsvoid
encodeLocalDb
(Encoder encoder, Namespace namespace, NameTransformer transformer) Encode all the variables in this local variable map to the streamFind any local variable (including input params) by addressfindLocal
(VariableStorage store, Address pc) Find any local variable (including input params) by addressGet the decompiler's function model owning this containerConstruct and return a map from a HighSymbol's name to the HighSymbol objectint
Get the number of parameter symbols in this scopegetParam
(int i) getParamSymbol
(int i) getSymbol
(long id) Lookup high variable based upon its symbol-idGet 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, String nm, DataType dt, long hash, Address pcaddr) protected HighSymbol
newMappedSymbol
(long id, String nm, DataType dt, VariableStorage store, Address pcaddr, int slot)
-
Constructor Details
-
LocalSymbolMap
- Parameters:
highFunc
- HighFunction the local variables are defined within.spc
- the address space the local variables are defined within.
-
-
Method Details
-
getHighFunction
Get the decompiler's function model owning this container- Returns:
- the owning HighFunction
-
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
-
decodeScope
Decode a local symbol scope from the stream- Parameters:
decoder
- is the stream decoder- Throws:
DecoderException
- for invalid encodings
-
decodeSymbolList
Add mapped symbols to this LocalVariableMap, by decoding the <symbollist> and <mapsym> elements- Parameters:
decoder
- is the stream decoder- Throws:
DecoderException
- for invalid encodings
-
encodeLocalDb
public void encodeLocalDb(Encoder encoder, Namespace namespace, NameTransformer transformer) throws IOException Encode all the variables in this local variable map to the stream- Parameters:
encoder
- is the stream encodernamespace
- if the namespace of the functiontransformer
- is used to compute a simplified version of the namespace name- Throws:
IOException
- for errors in the underlying stream
-
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
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
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
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
- Parameters:
i
- is the desired parameter position- Returns:
- the i-th parameter HighSymbol
-
getParam
- Parameters:
i
- is the desired parameter position- Returns:
- the i-th parameter variable
-
newMappedSymbol
protected HighSymbol newMappedSymbol(long id, String nm, DataType dt, VariableStorage store, Address pcaddr, int slot) -
newDynamicSymbol
-