Package ghidra.app.util.bin.format.dwarf4.next

# Class DWARFVariable

java.lang.Object
ghidra.app.util.bin.format.dwarf4.next.DWARFVariable

public class DWARFVariable extends Object
Represents a function parameter, local variable, or global variable.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `boolean`
  `isExternal`
  `boolean`
  `isOutputParameter`
  `boolean`
  `isThis`
  `long`
  `lexicalOffset`
  `DWARFNameInfo`
  `name`
  `DWARFSourceInfo`
  `sourceInfo`
  `DataType`
  `type`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addRamStorage(long offset)`
  `void`
  `addRegisterStorage(List<Register> registers)`
  `void`
  `addStackStorage(long offset, int length)`
  `Variable`
  `asLocalVariable()`
  `Parameter`
  `asParameter(boolean includeStorageDetail)`
  `ParameterDefinition`
  `asParameterDef()`
  `Parameter`
  `asReturnParameter(boolean includeStorageDetail)`
  `void`
  `clearStorage()`
  `static DWARFVariable`
  `fromDataType(DWARFFunction dfunc, DataType dt)`
  Creates an unnamed, storage-less `DWARFVariable` from a DataType.
  `String`
  `getDeclInfoString()`
  `Address`
  `getRamAddress()`
  If this is a static/global variable, stored at a ram address, return it's ram address.
  `long`
  `getStackOffset()`
  If this is a stack variable, return its stack offset.
  `int`
  `getStorageSize()`
  `VariableStorage`
  `getVariableStorage()`
  `List<Varnode>`
  `getVarnodes()`
  `boolean`
  `isEmptyArray()`
  `boolean`
  `isLocationValidOnEntry()`
  `boolean`
  `isMissingStorage()`
  `boolean`
  `isRamStorage()`
  `boolean`
  `isStackStorage()`
  `boolean`
  `isVoidType()`
  `boolean`
  `isZeroByte()`
  `static DWARFVariable`
  `readGlobalVariable(DIEAggregate diea)`
  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)`
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### name

    public DWARFNameInfo name

  - ### type

    public DataType type

  - ### lexicalOffset

    public long lexicalOffset

  - ### isOutputParameter

    public boolean isOutputParameter

  - ### isExternal

    public boolean isExternal

  - ### isThis

    public boolean isThis

  - ### sourceInfo

    public DWARFSourceInfo sourceInfo

- ## Method Details

  - ### fromDataType

    public static DWARFVariable fromDataType(DWARFFunction dfunc, DataType dt)
    Creates an unnamed, storage-less `DWARFVariable` from a DataType.
    Parameters:
      `dfunc` - containing function
      `dt` - `DataType` of the variable
    Returns:
      new `DWARFVariable`, never null

  - ### readParameter

    public static DWARFVariable readParameter(DIEAggregate diea, DWARFFunction dfunc, int paramOrdinal)
    Reads a parameter.
    Parameters:
      `diea` - `DIEAggregate` DW_TAG_formal_parameter
      `dfunc` - `DWARFFunction` that this parameter is attached to
      `paramOrdinal` - 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_variable
      `dfunc` - `DWARFFunction` that this local var belongs to
      `offsetFromFuncStart` - offset from start of containing function
    Returns:
      new DWARFVariable that represents a local var, or null if error reading storage info

  - ### readGlobalVariable

    public static DWARFVariable readGlobalVariable(DIEAggregate diea)
    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

    public void setRegisterStorage(List<Register> registers)
    Assign storage for this variable via a list of registers.
    Parameters:
      `registers` - registers that contain the data

  - ### addRegisterStorage

    public void addRegisterStorage(List<Register> registers)

  - ### 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

    public Address 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

    public List<Varnode> getVarnodes()

  - ### setVarnodes

    public void setVarnodes(List<Varnode> newStorage)

  - ### getVariableStorage

    public VariableStorage getVariableStorage() throws InvalidInputException
    Throws:
      `InvalidInputException`

  - ### asLocalVariable

    public Variable asLocalVariable() throws InvalidInputException
    Throws:
      `InvalidInputException`

  - ### asParameter

    public Parameter asParameter(boolean includeStorageDetail) throws InvalidInputException
    Throws:
      `InvalidInputException`

  - ### asParameterDef

    public ParameterDefinition asParameterDef()

  - ### asReturnParameter

    public Parameter asReturnParameter(boolean includeStorageDetail) throws InvalidInputException
    Throws:
      `InvalidInputException`

  - ### getDeclInfoString

    public String getDeclInfoString()

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`