Package ghidra.app.util.bin.format.dwarf
Class DWARFVariable
java.lang.Object
ghidra.app.util.bin.format.dwarf.DWARFVariable
Represents a function's parameter or local variable; or a global variable.
-
Field Summary
Modifier and TypeFieldDescriptionboolean
boolean
boolean
long
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addRamStorage
(long offset) void
addRegisterStorage
(List<Register> registers) void
addStackStorage
(long offset, int length) asParameter
(boolean includeStorageDetail) asReturnParameter
(boolean includeStorageDetail) void
static DWARFVariable
fromDataType
(DWARFFunction dfunc, DataType dt) Creates an unnamed, storage-lessDWARFVariable
from a DataType.If this is a static/global variable, stored at a ram address, return it's ram address.long
If this is a stack variable, return its stack offset.int
boolean
boolean
boolean
boolean
boolean
boolean
boolean
static DWARFVariable
Reads a static/global variable.static DWARFVariable
readLocalVariable
(DIEAggregate diea, DWARFFunction dfunc, long offsetFromFuncStart) Reads a local variable.static DWARFVariable
readParameter
(DIEAggregate diea, DWARFFunction dfunc, int paramOrdinal) Reads a parameter.void
setRamStorage
(long offset) Assign storage for this variable in a ram data location.void
setRegisterStorage
(List<Register> registers) Assign storage for this variable via a list of registers.void
setStackStorage
(long offset) Assign storage for this variable at a stack offset.void
setVarnodes
(List<Varnode> newStorage) toString()
-
Field Details
-
name
-
type
-
lexicalOffset
public long lexicalOffset -
isOutputParameter
public boolean isOutputParameter -
isExternal
public boolean isExternal -
isThis
public boolean isThis -
sourceInfo
-
-
Method Details
-
fromDataType
Creates an unnamed, storage-lessDWARFVariable
from a DataType.- Parameters:
dfunc
- containing functiondt
-DataType
of the variable- Returns:
- new
DWARFVariable
, never null
-
readParameter
Reads a parameter.- Parameters:
diea
-DIEAggregate
DW_TAG_formal_parameterdfunc
-DWARFFunction
that this parameter is attached toparamOrdinal
- ordinal in containing list- Returns:
- new parameter, never null, possibly without storage info
-
readLocalVariable
public static DWARFVariable readLocalVariable(DIEAggregate diea, DWARFFunction dfunc, long offsetFromFuncStart) Reads a local variable.- Parameters:
diea
-DIEAggregate
DW_TAG_variabledfunc
-DWARFFunction
that this local var belongs tooffsetFromFuncStart
- offset from start of containing function- Returns:
- new DWARFVariable that represents a local var, or null if error reading storage info
-
readGlobalVariable
Reads a static/global variable.- Parameters:
diea
-DIEAggregate
DW_TAG_variable- Returns:
- new
DWARFVariable
that represents the global variable, or null if error reading storage info
-
setRamStorage
public void setRamStorage(long offset) Assign storage for this variable in a ram data location.- Parameters:
offset
- address offset
-
addRamStorage
public void addRamStorage(long offset) -
setStackStorage
public void setStackStorage(long offset) Assign storage for this variable at a stack offset.- Parameters:
offset
- stack offset
-
addStackStorage
public void addStackStorage(long offset, int length) -
setRegisterStorage
Assign storage for this variable via a list of registers.- Parameters:
registers
- registers that contain the data
-
addRegisterStorage
-
isStackStorage
public boolean isStackStorage()- Returns:
- true if this variable is stored on the stack
-
getStackOffset
public long getStackOffset()If this is a stack variable, return its stack offset.- Returns:
- its stack offset
-
isRamStorage
public boolean isRamStorage()- Returns:
- true if this variable's storage is in ram
-
getRamAddress
If this is a static/global variable, stored at a ram address, return it's ram address.- Returns:
- address of where this variable is stored, null if not ram address
-
isMissingStorage
public boolean isMissingStorage() -
isZeroByte
public boolean isZeroByte() -
isVoidType
public boolean isVoidType() -
isEmptyArray
public boolean isEmptyArray() -
isLocationValidOnEntry
public boolean isLocationValidOnEntry() -
clearStorage
public void clearStorage() -
getStorageSize
public int getStorageSize() -
getVarnodes
-
setVarnodes
-
getVariableStorage
- Throws:
InvalidInputException
-
asLocalVariable
- Throws:
InvalidInputException
-
asParameter
- Throws:
InvalidInputException
-
asParameterDef
-
asReturnParameter
- Throws:
InvalidInputException
-
getDeclInfoString
-
toString
-