Class DebugInfoEntry

java.lang.Object
ghidra.app.util.bin.format.dwarf.DebugInfoEntry

public class DebugInfoEntry extends Object
A DWARF Debug Info Entry is a collection of attributes in a hierarchical structure (see getParent(), getChildren()).

This class is a lower-level class and DIEAggregate should be used instead in most cases when examining information from the DWARF system.

  • Constructor Details

    • DebugInfoEntry

      public DebugInfoEntry(DWARFCompilationUnit cu, long offset, int dieIndex, DWARFAbbreviation abbreviation, int[] attrOffsets)
      Creates a DIE.
      Parameters:
      cu - compunit containing the DIE
      offset - offset of the DIE
      dieIndex - index of the DIE
      abbreviation - that defines the schema of this DIE record
      attrOffsets - offset (from the die offset) of each attribute value
  • Method Details

    • read

      public static DebugInfoEntry read(BinaryReader reader, DWARFCompilationUnit cu, int dieIndex) throws IOException
      Read a DIE record.
      Parameters:
      reader - BinaryReader positioned at the start of a DIE record
      cu - the compunit that contains the DIE
      dieIndex - the index of the DIE
      Returns:
      new DIE instance
      Throws:
      IOException - if error reading data, or bad DWARF
    • getIndex

      public int getIndex()
      Returns the index of this DIE in the entire dwarf program.
      Returns:
      index of this DIE
    • getChildren

      public List<DebugInfoEntry> getChildren()
      Return a list of the child DIE's.
      Returns:
      list of child DIE's
    • getChildren

      public List<DebugInfoEntry> getChildren(DWARFTag childTag)
      Return a list of children that are of a specific DWARF type.

      Parameters:
      childTag - DIE tag used to filter the child DIEs
      Returns:
      list of matching child DIE records
    • getParent

      public DebugInfoEntry getParent()
      Get the parent DIE of this DIE.
      Returns:
      the parent DIE, or null if this DIE is the root of the compilation unit
    • getOffset

      public long getOffset()
      Get the offset of this DIE from the beginning of the debug_info section.
      Returns:
      the offset of this DIE from the beginning of the debug_info section
    • getTag

      public DWARFTag getTag()
      Get the DWARFTag value of this DIE.
      Returns:
      the DWARFTag value of this DIE
    • getAttributeCount

      public int getAttributeCount()
      Returns the number of attributes in this DIE.
      Returns:
      number of attribute values in this DIE
    • getAttributeValue

      public DWARFAttributeValue getAttributeValue(int attribIndex) throws IOException
      Returns the indexed attribute value.
      Parameters:
      attribIndex - index (0..count)
      Returns:
      DWARFAttributeValue
      Throws:
      IOException - if error reading the value
    • setAttributeValue

      public void setAttributeValue(int index, DWARFAttributeValue attrVal)
    • findAttribute

      public DWARFAttributeValue findAttribute(DWARFAttribute attributeId)
      Searches the list of attributes for a specific attribute, by id.
      Parameters:
      attributeId - DWARFAttribute
      Returns:
      DWARFAttributeValue, or null if not found
    • getAbbreviation

      public DWARFAbbreviation getAbbreviation()
      Get the abbreviation of this DIE.
      Returns:
      the abbreviation of this DIE
    • isTerminator

      public boolean isTerminator()
      Check to see if the DIE is a terminator.
      Returns:
      true if the DIE is a terminator and false otherwise
    • getPositionInParent

      public int getPositionInParent()
      Returns the ordinal position of this DIE record in its parent's list of children.
      Returns:
      index of ourself in our parent, or -1 if root DIE
    • getCompilationUnit

      public DWARFCompilationUnit getCompilationUnit()
    • getProgram

      public DWARFProgram getProgram()
    • getDepth

      public int getDepth()
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object