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
FieldsModifier and TypeFieldDescriptionbooleanbooleanbooleanlong -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRamStorage(long offset) voidaddRegisterStorage(List<Register> registers) voidaddStackStorage(long offset, int length) asParameter(boolean includeStorageDetail) asReturnParameter(boolean includeStorageDetail) voidstatic DWARFVariablefromDataType(DWARFFunction dfunc, DataType dt) Creates an unnamed, storage-lessDWARFVariablefrom a DataType.If this is a static/global variable, stored at a ram address, return it's ram address.longIf this is a stack variable, return its stack offset.intbooleanbooleanbooleanbooleanbooleanbooleanbooleanstatic DWARFVariableReads a static/global variable.static DWARFVariablereadLocalVariable(DIEAggregate diea, DWARFFunction dfunc, long offsetFromFuncStart) Reads a local variable.static DWARFVariablereadParameter(DIEAggregate diea, DWARFFunction dfunc, int paramOrdinal) Reads a parameter.voidsetRamStorage(long offset) Assign storage for this variable in a ram data location.voidsetRegisterStorage(List<Register> registers) Assign storage for this variable via a list of registers.voidsetStackStorage(long offset) Assign storage for this variable at a stack offset.voidsetVarnodes(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-lessDWARFVariablefrom a DataType.- Parameters:
dfunc- containing functiondt-DataTypeof the variable- Returns:
- new
DWARFVariable, never null
-
readParameter
Reads a parameter.- Parameters:
diea-DIEAggregateDW_TAG_formal_parameterdfunc-DWARFFunctionthat 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-DIEAggregateDW_TAG_variabledfunc-DWARFFunctionthat 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-DIEAggregateDW_TAG_variable- Returns:
- new
DWARFVariablethat 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
-