Package ghidra.app.util.bin.format.dwarf
Class DWARFProgram
java.lang.Object
ghidra.app.util.bin.format.dwarf.DWARFProgram
- All Implemented Interfaces:
Closeable,AutoCloseable
DWARFProgram encapsulates a
Ghidra program with DWARF specific reference data
used by DWARFDataTypeImporter and DWARFFunctionImporter, along with some
helper functions.-
Field Summary
FieldsChangeModifier and TypeFieldDescriptionNEWprotected DIEContainerstatic final Stringstatic final CategoryPathstatic final Stringprotected longMODIFIEDprotected static final EnumSet<DWARFAttributeId> static final CategoryPathREMOVEDRemovedREMOVEDRemovedREMOVEDRemovedREMOVEDRemovedREMOVEDRemovedREMOVEDRemovedREMOVEDRemoved -
Constructor Summary
ConstructorsChangeConstructorDescriptionDWARFProgram(Program program, DWARFImportOptions importOptions, DWARFSectionProvider sectionProvider) Constructor for DWARFProgram.DWARFProgram(Program program, DWARFImportOptions importOptions, TaskMonitor monitor) Main constructor for DWARFProgram. -
Method Summary
ChangeModifier and TypeMethodDescriptionReturns iterable that traverses allDIEAggregates in the program.voidclose()getAddressRange(DWARFRange range, boolean isCode) Returns charset to use when decoding debug strings.getCodeAddress(long offset) getDataAddress(long offset) intNEWgetEntryName(DIEAggregate diea) getName(DIEAggregate diea) Returns aDWARFNamefor aDIEAggregate.longA fixup value that needs to be applied to static addresses of the program.NEWintReturns the total number ofDIEAggregateobjects in the entire program.static booleanhasDWARFData(Program program, TaskMonitor monitor) Returns true if the specifiedprogramhas DWARF information.voidinit(TaskMonitor monitor) Reads and indexes available DWARF information.booleanstatic booleanReturns true if theprogramprobably has DWARF information, without doing all the work that querying all registered DWARFSectionProviders would take.booleanNEWbooleanisZeroDataAddress(Address addr) voidlogWarningAt(Address addr, String addrName, String msg) NEWvoidsetProgramBaseAddressFixup(long programBaseAddressFixup) booleanREMOVEDvoidindexDIEATypeRefs(TaskMonitor monitor) RemovedREMOVEDvoidindexDIEAggregates(LongArrayList aggrTargets, TaskMonitor monitor) RemovedREMOVEDvoidupdateSiblingIndexes(IntArrayList siblingIndexList, IntArrayList parentIndexList, int index) RemovedREMOVEDBinaryReaderRemovedREMOVEDDIEAggregategetReferringTypedef(DIEAggregate diea) RemovedREMOVEDDebugInfoEntrygetParentOf(int dieIndex) RemovedREMOVEDintgetParentDepth(int dieIndex) RemovedREMOVEDList<DebugInfoEntry>getChildrenOf(int dieIndex) RemovedREMOVEDintgetChildCount(int dieIndex) RemovedREMOVEDDebugInfoEntrygetDIEByOffset(long dieOffset) RemovedREMOVEDvoiddumpDIEs(PrintStream ps) RemovedREMOVEDDIEAggregategetAggregate(DebugInfoEntry die) RemovedREMOVEDDIEAggregategetAggregate(long dieOffset) RemovedREMOVEDStringgetString(DWARFForm form, long offset, DWARFCompilationUnit cu) RemovedREMOVEDDWARFRangeListgetRangeList(DIEAggregate diea, DWARFAttribute attribute) RemovedREMOVEDlonggetOffsetOfIndexedElement(DWARFForm form, int index, DWARFCompilationUnit cu) RemovedREMOVEDlonggetAddress(DWARFForm form, long value, DWARFCompilationUnit cu) RemovedREMOVEDDWARFLocationListgetLocationList(DIEAggregate diea, DWARFAttribute attribute) RemovedREMOVEDDWARFLinegetLine(DIEAggregate diea, DWARFAttribute attribute) RemovedREMOVEDDWARFLinegetLine(long offset, DWARFCompilationUnit cu, boolean readIfMissing) RemovedREMOVEDDWARFMacroHeadergetMacroHeader(long offset, DWARFCompilationUnit cu) RemovedREMOVEDList<DWARFMacroInfoEntry>getMacroEntries(DWARFMacroHeader macroHeader) RemovedREMOVEDBinaryReadergetReaderForCompUnit(DWARFCompilationUnit cu) RemovedREMOVEDAttrDefinternAttributeSpec(AttrDef das) RemovedREMOVEDList<DIEAggregate>getTypeReferers(DIEAggregate targetDIEA, DWARFTag tag) RemovedREMOVEDvoidsetStringTable(StringTable st) Removed
-
Field Details
-
DWARF_ROOT_NAME
- See Also:
-
DWARF_ROOT_CATPATH
-
UNCAT_CATPATH
-
DWARF_BOOKMARK_CAT
- See Also:
-
REF_ATTRS MODIFIED
type: EnumSet → EnumSet-static java.util.EnumSet<ghidra.app.util.bin.format.dwarf.attribs.DWARFAttribute> REF_ATTRS+static java.util.EnumSet<ghidra.app.util.bin.format.dwarf.attribs.DWARFAttributeId> REF_ATTRS -
programBaseAddressFixup
protected long programBaseAddressFixup -
dieContainer NEW
-
-
Constructor Details
-
DWARFProgram
public DWARFProgram(Program program, DWARFImportOptions importOptions, TaskMonitor monitor) throws CancelledException, IOException, DWARFException Main constructor for DWARFProgram.Auto-detects the DWARFSectionProvider and chains to the next constructor.
- Parameters:
program- GhidraProgram.importOptions-DWARFImportOptionsto controls options during reading / parsing /importing.monitor-TaskMonitorto control canceling and progress.- Throws:
CancelledException- if user cancelsIOException- if error reading dataDWARFException- if bad stuff happens.
-
DWARFProgram
public DWARFProgram(Program program, DWARFImportOptions importOptions, DWARFSectionProvider sectionProvider) throws IOException Constructor for DWARFProgram.- Parameters:
program- GhidraProgram.importOptions-DWARFImportOptionsto controls options during reading / parsing /importing.sectionProvider-DWARFSectionProviderfactory that finds DWARF .debug_* sections wherever they live.- Throws:
IOException- if error reading data
-
-
Method Details
-
isDWARF
Returns true if theprogramprobably has DWARF information, without doing all the work that querying all registered DWARFSectionProviders would take.If the program is an Elf binary, it must have (at least) ".debug_info" and ".debug_abbr", program sections, or their compressed "z" versions, or ExternalDebugInfo that would point to an external DWARF file.
If the program is a MachO binary (Mac), it must have a ".dSYM" directory co-located next to the original binary file on the native filesystem (outside of Ghidra). See the DSymSectionProvider for more info.
- Parameters:
program-Programto test- Returns:
- boolean true if program probably has DWARF info, false if not
-
hasDWARFData
Returns true if the specifiedprogramhas DWARF information.This is similar to
isDWARF(Program), but is a stronger check that is more expensive as it could involve searching for external files.- Parameters:
program-Programto testmonitor-TaskMonitorthat can be used to cancel- Returns:
- boolean true if the program has DWARF info, false if not
-
getDIEContainer NEW
-
init
Reads and indexes available DWARF information.- Parameters:
monitor-TaskMonitor- Throws:
IOException- if error reading dataDWARFException- if bad or invalid DWARF informationCancelledException- if cancelled
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getImportOptions
-
getImportSummary
-
getGhidraProgram
-
getDwarfDTM
-
getCompilationUnits
-
isBigEndian
public boolean isBigEndian() -
isLittleEndian
public boolean isLittleEndian() -
getSectionProvider NEW
-
getEntryName
-
getName
Returns aDWARFNamefor aDIEAggregate.- Parameters:
diea-DIEAggregate- Returns:
DWARFName, never null
-
getCharset
Returns charset to use when decoding debug strings.- Returns:
- charset to use when decoding debug strings
-
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.
-
getRegisterMappings
-
getRootDNI
-
getUncategorizedRootDNI
-
getStackSpace
-
getProgramBaseAddressFixup
public long getProgramBaseAddressFixup()A fixup value that needs to be applied to static addresses of the program.This value is necessary if the program's built-in base address is overridden at import time.
- Returns:
- long value to add to static addresses discovered in DWARF to make it agree with Ghidra's imported program.
-
setProgramBaseAddressFixup NEW
public void setProgramBaseAddressFixup(long programBaseAddressFixup) -
getAddressRange
-
getCodeAddress
-
getDataAddress
-
isZeroDataAddress NEW
-
stackGrowsNegative
public boolean stackGrowsNegative() -
getFunctionFixups
-
getDefaultIntSize
public int getDefaultIntSize() -
logWarningAt
-