Class DWARFCompilationUnit
DIE records found
in a .debug_info section of an program. The compilation unit block starts with a
header that has a few important values and flags, and is followed by the DIE records.
The first DIE record must be a DW_TAG_compile_unit.
DIE records are identified by their byte offset in the .debug_info section.
-
Field Summary
FieldsChangeModifier and TypeFieldDescriptionprotected DIEAggregateThe contents of the first DIE (that must be a compile unit) in this compUnit.Fields inherited from class ghidra.app.util.bin.format.dwarf.DWARFUnitHeader
dieContainer, dprog, dwarfVersion, endOffset, intSize, startOffset, unitNumber -
Constructor Summary
ConstructorsChangeConstructorDescriptionDWARFCompilationUnit(DIEContainer dieContainer, long startOffset, long endOffset, int intSize, short dwarfVersion, byte pointerSize, int unitNumber, long firstDIEOffset, Map<Integer, DWARFAbbreviation> codeToAbbreviationMap) This ctor is public only for junit tests. -
Method Summary
ChangeModifier and TypeMethodDescriptiongetAbbreviation(int ac) longGet the compile directory of the compile unitReturns this comp unit's root DIE as a DIE Aggregate.longintGet the source language of the compile unit.getLine()longgetName()Get the filename that produced the compile unitReturns the range covered by this CU, as defined by the lo_pc and high_pc attribute values, defaulting to (0,0] if missing.byteReturns the size of pointers in this compUnit.Get the producer of the compile unitlonglongbooleanhasDWO()voidinit(DebugInfoEntry rootDIE) Initializes this compunit with the root DIE (first DIE) of the compunit.NEWstatic DWARFCompilationUnitreadV4(DWARFUnitHeader partial, BinaryReader reader) Creates a newDWARFCompilationUnitby reading a compilationUnit's header data from the debug_info section.NEWstatic DWARFCompilationUnitreadV5(DWARFUnitHeader partial, BinaryReader reader) Creates a newDWARFCompilationUnitby reading a compilationUnit's header data from the debug_info section.toString()REMOVEDDWARFCompilationUnitreadV4(DWARFUnitHeader partial, BinaryReader reader, BinaryReader abbrReader, TaskMonitor monitor) RemovedREMOVEDDWARFCompilationUnitreadV5(DWARFUnitHeader partial, BinaryReader reader, BinaryReader abbrReader, TaskMonitor monitor) RemovedMethods inherited from class ghidra.app.util.bin.format.dwarf.DWARFUnitHeader
getDIEContainer, getDWARFVersion, getEndOffset, getIntSize, getProgram, getStartOffset, getUnitNumber, read
-
Field Details
-
diea
The contents of the first DIE (that must be a compile unit) in this compUnit.
-
-
Constructor Details
-
DWARFCompilationUnit
public DWARFCompilationUnit(DIEContainer dieContainer, long startOffset, long endOffset, int intSize, short dwarfVersion, byte pointerSize, int unitNumber, long firstDIEOffset, Map<Integer, DWARFAbbreviation> codeToAbbreviationMap) This ctor is public only for junit tests. Do not use directly.- Parameters:
dieContainer- holds all DIE records and related serialization infostartOffset- offset in provider where it startsendOffset- offset in provider where it endsintSize- 4 (DWARF_32) or 8 (DWARF_64)dwarfVersion- 2-5pointerSize- default size of pointersunitNumber- this compunit's ordinal in the filefirstDIEOffset- start of DIEs in the providercodeToAbbreviationMap- map of abbreviation numbers toDWARFAbbreviationinstances
-
-
Method Details
-
readV4 NEW
public static DWARFCompilationUnit readV4(DWARFUnitHeader partial, BinaryReader reader) throws DWARFException, IOException Creates a newDWARFCompilationUnitby reading a compilationUnit's header data from the debug_info section.Returns
NULLif there was an ignorable error while reading the compilation unit (and leaves the input stream at the next compilation unit to read), otherwise throws an IOException if there was an unrecoverable error.Also returns
NULL(and leaves the stream at EOF) if the remainder of the stream is filled with null bytes.- Parameters:
partial- already read partial unit headerreader- .debug_info BinaryReader- Returns:
- the read compilation unit, or null if the compilation unit was bad/empty and should be ignored
- Throws:
DWARFException- if an invalid or unsupported DWARF version is read.IOException- if the length of the compilation unit is invalid.
-
readV5 NEW
public static DWARFCompilationUnit readV5(DWARFUnitHeader partial, BinaryReader reader) throws DWARFException, IOException Creates a newDWARFCompilationUnitby reading a compilationUnit's header data from the debug_info section.Returns
NULLif there was an ignorable error while reading the compilation unit (and leaves the input stream at the next compilation unit to read), otherwise throws an IOException if there was an unrecoverable error.Also returns
NULL(and leaves the stream at EOF) if the remainder of the stream is filled with null bytes.- Parameters:
partial- already read partial unit headerreader- .debug_info BinaryReader- Returns:
- the read compilation unit, or null if the compilation unit was bad/empty and should be ignored
- Throws:
DWARFException- if an invalid or unsupported DWARF version is read.IOException- if the length of the compilation unit is invalid.
-
init
Initializes this compunit with the root DIE (first DIE) of the compunit. This comp unit isn't usable until this has happened.- Parameters:
rootDIE-DebugInfoEntry- Throws:
IOException- if error reading data from the DIE
-
getCompUnitDIEA
Returns this comp unit's root DIE as a DIE Aggregate.- Returns:
- the aggregate containing the root element of this comp unit
-
getPointerSize
public byte getPointerSize()Returns the size of pointers in this compUnit.- Returns:
- the size in bytes of pointers
-
getCodeToAbbreviationMap
-
getAbbreviation
-
getFirstDIEOffset
public long getFirstDIEOffset() -
getLine
-
getMacros
-
getName
Get the filename that produced the compile unit- Returns:
- the filename that produced the compile unit
-
getProducer
Get the producer of the compile unit- Returns:
- the producer of the compile unit
-
getCompileDirectory
Get the compile directory of the compile unit- Returns:
- the compile directory of the compile unit
-
getLanguage
public int getLanguage()Get the source language of the compile unit.See
DWARFSourceLanguagefor values.- Returns:
- the source language of the compile unit, or -1 if not set
-
hasDWO
public boolean hasDWO() -
getAddrTableBase
public long getAddrTableBase() -
getRangeListsBase
public long getRangeListsBase() -
getLocListsBase
public long getLocListsBase() -
getStrOffsetsBase
public long getStrOffsetsBase() -
getPCRange
Returns the range covered by this CU, as defined by the lo_pc and high_pc attribute values, defaulting to (0,0] if missing.- Returns:
DWARFRangethat this CU covers, never null
-
toString
-