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
Modifier and TypeFieldDescriptionprotected DIEAggregate
The 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
dprog, dwarfVersion, endOffset, intSize, startOffset, unitNumber
-
Constructor Summary
ConstructorDescriptionDWARFCompilationUnit
(DWARFProgram dwarfProgram, 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
Modifier and TypeMethodDescriptiongetAbbreviation
(int ac) long
Get the compile directory of the compile unitReturns this comp unit's root DIE as a DIE Aggregate.long
int
Get the source language of the compile unit.getLine()
long
getName()
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.byte
Returns the size of pointers in this compUnit.Get the producer of the compile unitlong
long
boolean
hasDWO()
void
init
(DebugInfoEntry rootDIE) Initializes this compunit with the root DIE (first DIE) of the compunit.static DWARFCompilationUnit
readV4
(DWARFUnitHeader partial, BinaryReader reader, BinaryReader abbrReader, TaskMonitor monitor) Creates a newDWARFCompilationUnit
by reading a compilationUnit's header data from the debug_info section and the debug_abbr section and its compileUnit DIE (ie.static DWARFCompilationUnit
readV5
(DWARFUnitHeader partial, BinaryReader reader, BinaryReader abbrReader, TaskMonitor monitor) Creates a newDWARFCompilationUnit
by reading a compilationUnit's header data from the debug_info section and the debug_abbr section and its compileUnit DIE (ie.toString()
Methods inherited from class ghidra.app.util.bin.format.dwarf.DWARFUnitHeader
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(DWARFProgram dwarfProgram, 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:
dwarfProgram
-DWARFProgram
startOffset
- 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 compunits ordinal in the filefirstDIEOffset
- start of DIEs in the providercodeToAbbreviationMap
- map of abbreviation numbers toDWARFAbbreviation
instances
-
-
Method Details
-
readV4
public static DWARFCompilationUnit readV4(DWARFUnitHeader partial, BinaryReader reader, BinaryReader abbrReader, TaskMonitor monitor) throws DWARFException, IOException, CancelledException Creates a newDWARFCompilationUnit
by reading a compilationUnit's header data from the debug_info section and the debug_abbr section and its compileUnit DIE (ie. the first DIE right after the header).Returns
NULL
if 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 BinaryReaderabbrReader
- .debug_abbr BinaryReadermonitor
- the current task monitor- 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.CancelledException
- if the task has been canceled.
-
readV5
public static DWARFCompilationUnit readV5(DWARFUnitHeader partial, BinaryReader reader, BinaryReader abbrReader, TaskMonitor monitor) throws DWARFException, IOException, CancelledException Creates a newDWARFCompilationUnit
by reading a compilationUnit's header data from the debug_info section and the debug_abbr section and its compileUnit DIE (ie. the first DIE right after the header).Returns
NULL
if 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 BinaryReaderabbrReader
- .debug_abbr BinaryReadermonitor
- the current task monitor- 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.CancelledException
- if the task has been canceled.
-
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
-
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
DWARFSourceLanguage
for 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:
DWARFRange
that this CU covers, never null
-
toString
-