Package ghidra.app.util.bin.format.dwarf
Class DIEContainer
java.lang.Object
ghidra.app.util.bin.format.dwarf.DIEContainer
- All Implemented Interfaces:
Iterable<DebugInfoEntry>
Provides access to a set of DIE records (and associated bits and bobs)
-
Field Summary
FieldsChangeModifier and TypeFieldDescriptionprotected Map<Long, Map<Integer, DWARFAbbreviation>> protected DWARFIndirectTableprotected WeakValueHashMap<Long, DIEAggregate> protected TreeMap<Integer, DWARFCompilationUnit> protected List<DWARFCompilationUnit> protected BinaryReaderprotected BinaryReaderprotected BinaryReaderprotected BinaryReaderprotected BinaryReaderprotected BinaryReaderprotected BinaryReaderprotected BinaryReaderprotected BinaryReaderprotected StringTableprotected BinaryReaderprotected long[]protected WeakValueHashMap<Long, DebugInfoEntry> protected DWARFProgramprotected DWARFImportSummaryprotected BitSetprotected StringTableprotected DWARFIndirectTableprotected int[]protected DWARFIndirectTableprotected static final EnumSet<DWARFAttributeId> protected DWARFSectionProviderprotected int[]protected DWARFIndirectTableprotected int -
Constructor Summary
Constructors -
Method Summary
ChangeModifier and TypeMethodDescriptionReturns iterable that traverses allDIEAggregates in the program.voidclose()voiddumpDIEs(PrintStream ps) getAbbrevs(long abbrevOffset) longgetAddress(DWARFForm form, long value, DWARFCompilationUnit cu) Returns an address value.getAggregate(long dieOffset) Returns theDIEAggregatethat contains theDebugInfoEntryspecified by the offset.Returns theDIEAggregatethat contains the specifiedDebugInfoEntry.intgetChildCount(int dieIndex) getChildrenOf(int dieIndex) Returns the children of the specified DIEgetDIE(DWARFForm form, long rawOffset, DWARFCompilationUnit cu) Return the DIE referenced by an attribute value (a DW_FORM and offset)getDIEByOffset(long dieOffset) Returns the specified DIE record.getLine(long offset, DWARFCompilationUnit cu, boolean readIfMissing) getLine(DIEAggregate diea, DWARFAttributeId attribute) Returns the DWARFLine info pointed to by the specified attribute.longgetLocationList(DIEAggregate diea, DWARFAttributeId attrId) Returns theDWARFLocationListpointed to by the specified attribute value.getMacroEntries(DWARFMacroHeader macroHeader) getMacroHeader(long offset, DWARFCompilationUnit cu) longgetOffsetOfIndexedElement(DWARFForm form, int index, DWARFCompilationUnit cu) Returns the raw offset of an indexed item.intgetParentDepth(int dieIndex) Returns the depth of the specified DIE.getParentOf(int dieIndex) Returns the parent DIE of the specified (by index) DIEintgetPositionInParent(DebugInfoEntry die, Predicate<DWARFTag> dwTagFilter) getRangeList(DIEAggregate diea, DWARFAttributeId attribute) Returns theDWARFRangeListpointed at by the specified attribute.getString(DWARFForm form, long offset, DWARFCompilationUnit cu) Returns a DWARF attribute string value, as specified by a form, offset/index, and the cu.intReturns the total number ofDIEAggregateobjects in the entire program.getTypeReferers(DIEAggregate targetDIEA, DWARFTag tag) Returns a list ofDIEAggregates that refer to the targetDIEA via an attribute of the specified tag type.booleanvoidindexData(TaskMonitor monitor) Reads and indexes the DIE records found in the section.protected voidindexDIEAggregates(LongArrayList aggrTargets, TaskMonitor monitor) protected voidindexDIEATypeRefs(TaskMonitor monitor) voidinit(TaskMonitor monitor) Fetches required sections and sets up variables.ghidra.app.util.bin.format.dwarf.DIEContainer.DIEIteratoriterator()ghidra.app.util.bin.format.dwarf.DIEContainer.DIEIteratorprotected voidupdateSiblingIndexes(IntArrayList siblingIndexList, IntArrayList parentIndexList, int index) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
REF_ATTRS
-
dprog
-
sectionProvider
-
abbrCache
-
dieOffsets
protected long[] dieOffsets -
siblingIndexes
protected int[] siblingIndexes -
parentIndexes
protected int[] parentIndexes -
compUnitDieIndex
-
compUnits
-
addressListTable
-
locationListTable
-
rangeListTable
-
stringsOffsetTable
-
indexHasRef
-
diesByOffset
-
aggsByOffset
-
typeReferers
-
totalAggregateCount
protected int totalAggregateCount -
debugStrings
-
lineStrings
-
cachedDWARFLines
-
debugLocation
-
debugLocLists
-
debugRanges
-
debugRngLists
-
debugInfoBR
-
debugLineBR
-
debugAbbrBR
-
debugAddr
-
debugStrOffsets
-
debugMacros
-
importSummary
-
-
Constructor Details
-
DIEContainer
-
-
Method Details
-
init
Fetches required sections and sets up variables.- Parameters:
monitor-TaskMonitor- Throws:
IOException- if error
-
indexData
Reads and indexes the DIE records found in the section.- Parameters:
monitor-TaskMonitor- Throws:
CancelledException- if cancelledDWARFException- if errorIOException- if error
-
close
public void close() -
indexDIEATypeRefs
- Throws:
CancelledException
-
indexDIEAggregates
protected void indexDIEAggregates(LongArrayList aggrTargets, TaskMonitor monitor) throws CancelledException, DWARFException - Throws:
CancelledExceptionDWARFException
-
updateSiblingIndexes
protected void updateSiblingIndexes(IntArrayList siblingIndexList, IntArrayList parentIndexList, int index) -
getDIE
public DebugInfoEntry getDIE(DWARFForm form, long rawOffset, DWARFCompilationUnit cu) throws IOException Return the DIE referenced by an attribute value (a DW_FORM and offset)- Parameters:
form-DWARFFormrawOffset- index / offset from the numeric attributecu- compilation unit containing the value- Returns:
DebugInfoEntry, or null if doesn't exist- Throws:
IOException- if unsupported format for reference
-
getDIEByOffset
Returns the specified DIE record.- Parameters:
dieOffset- offset of a DIE record- Returns:
DebugInfoEntryinstance, or null if invalid offset
-
dumpDIEs
-
getAggregate
Returns theDIEAggregatethat contains the specifiedDebugInfoEntry.- Parameters:
die-DebugInfoEntryor null- Returns:
DIEAggregatethat contains the specified DIE, or null if DIE null or the aggregate was not found.
-
getAggregate
Returns theDIEAggregatethat contains theDebugInfoEntryspecified by the offset.- Parameters:
dieOffset- offset of a DIE record- Returns:
DIEAggregatethat contains the DIE record specified, or null if bad offset.
-
allAggregates
Returns iterable that traverses allDIEAggregates in the program.- Returns:
- sequence of
DIEAggregatees
-
getTotalAggregateCount
public int getTotalAggregateCount()Returns the total number ofDIEAggregateobjects in the entire program.- Returns:
- the total number of
DIEAggregateobjects in the entire program.
-
getReaderForCompUnit
-
getAbbrevs
- Throws:
IOException
-
getProgram
-
getCompilationUnits
-
getParentOf
Returns the parent DIE of the specified (by index) DIE- Parameters:
dieIndex- index of a DIE record- Returns:
- parent DIE, or null if no parent (eg. root DIE)
-
getParentDepth
public int getParentDepth(int dieIndex) Returns the depth of the specified DIE.- Parameters:
dieIndex- index of a DIE record- Returns:
- parent/child depth of specified record, where 0 is the root DIE
-
getChildrenOf
Returns the children of the specified DIE- Parameters:
dieIndex- index of a DIE record- Returns:
- list of DIE instances that are children of the specified DIE
-
getChildCount
public int getChildCount(int dieIndex) -
getOffsetOfIndexedElement
public long getOffsetOfIndexedElement(DWARFForm form, int index, DWARFCompilationUnit cu) throws IOException Returns the raw offset of an indexed item. For DW_FORM_addrx values, the returned value is not fixed up with Ghidra load offset.- Parameters:
form-DWARFFormof the indexindex- int index into a lookup table (seeaddressListTable,locationListTable,rangeListTable,stringsOffsetTable)cu-DWARFCompilationUnit- Returns:
- raw offset of indexed item
- Throws:
IOException- if error reading index table
-
getAddress
Returns an address value.- Parameters:
form- the format of the numeric valuevalue- raw offset or indirect address index (depending on the DWARFForm)cu-DWARFCompilationUnit- Returns:
- address
- Throws:
IOException- if error reading indirect lookup tables
-
getLocationList
public DWARFLocationList getLocationList(DIEAggregate diea, DWARFAttributeId attrId) throws IOException Returns theDWARFLocationListpointed to by the specified attribute value.- Parameters:
diea-DIEAggregateattrId- attribute id that points to the location list- Returns:
DWARFLocationList, never null- Throws:
IOException- if specified attribute is not the correct type, or if other error reading data
-
getString
Returns a DWARF attribute string value, as specified by a form, offset/index, and the cu.- Parameters:
form-DWARFFormoffset- offset or index of the valuecu-DWARFCompilationUnit- Returns:
- String value, never null
- Throws:
IOException- if invalid form or bad offset/index
-
getStringTable
-
getRangeList
public DWARFRangeList getRangeList(DIEAggregate diea, DWARFAttributeId attribute) throws IOException Returns theDWARFRangeListpointed at by the specified attribute.- Parameters:
diea-DIEAggregateattribute- attribute id to find in the DIEA- Returns:
DWARFRangeList, or null if attribute is not present- Throws:
IOException- if error reading range list
-
getLine
Returns the DWARFLine info pointed to by the specified attribute.- Parameters:
diea-DIEAggregateattribute- attribute id that points to the line info- Returns:
DWARFLine, never null, seeDWARFLine.empty()- Throws:
IOException- if error reading line data
-
getLine
public DWARFLine getLine(long offset, DWARFCompilationUnit cu, boolean readIfMissing) throws IOException - Throws:
IOException
-
getLineDataSize
public long getLineDataSize() -
getDebugLineReader
-
hasLineInfo
public boolean hasLineInfo() -
getMacroHeader
-
getMacroEntries
- Throws:
IOException
-
getPositionInParent
-
iterator
public ghidra.app.util.bin.format.dwarf.DIEContainer.DIEIterator iterator()- Specified by:
iteratorin interfaceIterable<DebugInfoEntry>
-
unreferencedDIEs
public ghidra.app.util.bin.format.dwarf.DIEContainer.DIEIterator unreferencedDIEs() -
getTypeReferers
Returns a list ofDIEAggregates that refer to the targetDIEA via an attribute of the specified tag type.- Parameters:
targetDIEA-DIEAggregatethat might be pointed to by other DIEAs.tag- theDWARFTagattribute type that is pointing DIEAs are using to refer to the target DIEA.- Returns:
- list of DIEAs that point to the target, empty list if nothing found.
-