Module gimli::write [−][src]
Write DWARF debugging information.
API Structure
This module works by building up a representation of the debugging information in memory, and then writing it all at once. It supports two major use cases:
-
Use the
DwarfUnit
type when writing DWARF for a single compilation unit. -
Use the
Dwarf
type when writing DWARF for multiple compilation units.
The module also supports reading in DWARF debugging information and writing it out
again, possibly after modifying it. Create a read::Dwarf
instance, and then use Dwarf::from
to convert
it to a writable instance.
Example Usage
Write a compilation unit containing only the top level DIE.
use gimli::write::{ Address, AttributeValue, DwarfUnit, EndianVec, Error, Range, RangeList, Sections, }; fn example() -> Result<(), Error> { // Choose the encoding parameters. let encoding = gimli::Encoding { format: gimli::Format::Dwarf32, version: 5, address_size: 8, }; // Create a container for a single compilation unit. let mut dwarf = DwarfUnit::new(encoding); // Set a range attribute on the root DIE. let range_list = RangeList(vec![Range::StartLength { begin: Address::Constant(0x100), length: 42, }]); let range_list_id = dwarf.unit.ranges.add(range_list); let root = dwarf.unit.root(); dwarf.unit.get_mut(root).set( gimli::DW_AT_ranges, AttributeValue::RangeListRef(range_list_id), ); // Create a `Vec` for each DWARF section. let mut sections = Sections::new(EndianVec::new(gimli::LittleEndian)); // Finally, write the DWARF data to the sections. dwarf.write(&mut sections)?; sections.for_each(|id, data| { // Here you can add the data to the output object file. Ok(()) }) }
Structs
Attribute | An attribute in a |
CieId | An identifier for a CIE in a |
CommonInformationEntry | A common information entry. This contains information that is shared between FDEs. |
DebugAbbrev | A writable |
DebugFrame | A writable |
DebugInfo | A writable |
DebugInfoOffsets | The section offsets of all elements within a |
DebugLine | A writable |
DebugLineStr | A writable |
DebugLineStrOffsets | The section offsets of all strings within a |
DebugLoc | A writable |
DebugLocLists | A writable |
DebugRanges | A writable |
DebugRngLists | A writable |
DebugStr | A writable |
DebugStrOffsets | The section offsets of all strings within a |
DebuggingInformationEntry | A Debugging Information Entry (DIE). |
DirectoryId | An identifier for a directory in a |
Dwarf | Writable DWARF information for more than one unit. |
DwarfUnit | Writable DWARF information for a single unit. |
EhFrame | A writable |
EndianVec | A |
Expression | The bytecode for a DWARF expression or location description. |
FileId | An identifier for a file in a |
FileInfo | Extra information for file in a |
FrameDescriptionEntry | A frame description entry. There should be one FDE per function. |
FrameTable | A table of frame description entries. |
InitialLengthOffset | The offset at which an initial length should be written. |
LineProgram | A line number program. |
LineRow | A row in the line number table that corresponds to a machine instruction. |
LineStringId | An identifier for a string in a |
LineStringTable | A table of strings that will be stored in a |
LocationList | A locations list that will be stored in a |
LocationListId | An identifier for a location list in a |
LocationListOffsets | The section offsets of a series of location lists within the |
LocationListTable | A table of location lists that will be stored in a |
RangeList | A range list that will be stored in a |
RangeListId | An identifier for a range list in a |
RangeListOffsets | The section offsets of a series of range lists within the |
RangeListTable | A table of range lists that will be stored in a |
Sections | All of the writable DWARF sections. |
StringId | An identifier for a string in a |
StringTable | A table of strings that will be stored in a |
Unit | A unit’s debugging information. |
UnitEntryId | An identifier for an entry in a |
UnitId | An identifier for a unit in a |
UnitTable | A table of units that will be stored in the |
Enums
Address | An address. |
AttributeValue | The value of an attribute in a |
CallFrameInstruction | An instruction in a frame description entry. |
ConvertError | An error that occurred when converting a read value into a write value. |
Error | An error that occurred when writing. |
LineString | A string value for use in defining paths in line number programs. |
Location | A single location. |
Range | A single range. |
Reference | A reference to a |
Traits
Section | Functionality common to all writable DWARF sections. |
Writer | A trait for writing the data to a DWARF section. |
Type Definitions
ConvertResult | The result of a conversion. |
Result | The result of a write. |