#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Format {
Dwarf64 = 8,
Dwarf32 = 4,
}
impl Format {
#[inline]
pub fn initial_length_size(self) -> u8 {
match self {
Format::Dwarf32 => 4,
Format::Dwarf64 => 12,
}
}
#[inline]
pub fn word_size(self) -> u8 {
match self {
Format::Dwarf32 => 4,
Format::Dwarf64 => 8,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[repr(C)]
pub struct Encoding {
pub address_size: u8,
pub format: Format,
pub version: u16,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct LineEncoding {
pub minimum_instruction_length: u8,
pub maximum_operations_per_instruction: u8,
pub default_is_stmt: bool,
pub line_base: i8,
pub line_range: u8,
}
impl Default for LineEncoding {
fn default() -> Self {
LineEncoding {
minimum_instruction_length: 1,
maximum_operations_per_instruction: 1,
default_is_stmt: true,
line_base: -5,
line_range: 14,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct Register(pub u16);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct DebugAbbrevOffset<T = usize>(pub T);
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct DebugAddrBase<T = usize>(pub T);
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct DebugAddrIndex<T = usize>(pub T);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Hash)]
pub struct DebugInfoOffset<T = usize>(pub T);
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct DebugLineOffset<T = usize>(pub T);
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct DebugLineStrOffset<T = usize>(pub T);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct LocationListsOffset<T = usize>(pub T);
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct DebugLocListsBase<T = usize>(pub T);
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct DebugLocListsIndex<T = usize>(pub T);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct DebugMacinfoOffset<T = usize>(pub T);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct DebugMacroOffset<T = usize>(pub T);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct RangeListsOffset<T = usize>(pub T);
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct DebugRngListsBase<T = usize>(pub T);
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct DebugRngListsIndex<T = usize>(pub T);
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct DebugStrOffset<T = usize>(pub T);
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct DebugStrOffsetsBase<T = usize>(pub T);
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct DebugStrOffsetsIndex<T = usize>(pub T);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Hash)]
pub struct DebugTypesOffset<T = usize>(pub T);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct DebugTypeSignature(pub u64);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct DebugFrameOffset<T = usize>(pub T);
impl<T> From<T> for DebugFrameOffset<T> {
#[inline]
fn from(o: T) -> Self {
DebugFrameOffset(o)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct EhFrameOffset<T = usize>(pub T);
impl<T> From<T> for EhFrameOffset<T> {
#[inline]
fn from(o: T) -> Self {
EhFrameOffset(o)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Hash)]
pub enum UnitSectionOffset<T = usize> {
DebugInfoOffset(DebugInfoOffset<T>),
DebugTypesOffset(DebugTypesOffset<T>),
}
impl<T> From<DebugInfoOffset<T>> for UnitSectionOffset<T> {
fn from(offset: DebugInfoOffset<T>) -> Self {
UnitSectionOffset::DebugInfoOffset(offset)
}
}
impl<T> From<DebugTypesOffset<T>> for UnitSectionOffset<T> {
fn from(offset: DebugTypesOffset<T>) -> Self {
UnitSectionOffset::DebugTypesOffset(offset)
}
}
impl<T> UnitSectionOffset<T>
where
T: Clone,
{
pub fn as_debug_info_offset(&self) -> Option<DebugInfoOffset<T>> {
match self {
UnitSectionOffset::DebugInfoOffset(offset) => Some(offset.clone()),
UnitSectionOffset::DebugTypesOffset(_) => None,
}
}
pub fn as_debug_types_offset(&self) -> Option<DebugTypesOffset<T>> {
match self {
UnitSectionOffset::DebugInfoOffset(_) => None,
UnitSectionOffset::DebugTypesOffset(offset) => Some(offset.clone()),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Hash)]
pub enum SectionId {
DebugAbbrev,
DebugAddr,
DebugAranges,
DebugFrame,
EhFrame,
EhFrameHdr,
DebugInfo,
DebugLine,
DebugLineStr,
DebugLoc,
DebugLocLists,
DebugMacinfo,
DebugMacro,
DebugPubNames,
DebugPubTypes,
DebugRanges,
DebugRngLists,
DebugStr,
DebugStrOffsets,
DebugTypes,
}
impl SectionId {
pub fn name(self) -> &'static str {
match self {
SectionId::DebugAbbrev => ".debug_abbrev",
SectionId::DebugAddr => ".debug_addr",
SectionId::DebugAranges => ".debug_aranges",
SectionId::DebugFrame => ".debug_frame",
SectionId::EhFrame => ".eh_frame",
SectionId::EhFrameHdr => ".eh_frame_hdr",
SectionId::DebugInfo => ".debug_info",
SectionId::DebugLine => ".debug_line",
SectionId::DebugLineStr => ".debug_line_str",
SectionId::DebugLoc => ".debug_loc",
SectionId::DebugLocLists => ".debug_loclists",
SectionId::DebugMacinfo => ".debug_macinfo",
SectionId::DebugMacro => ".debug_macro",
SectionId::DebugPubNames => ".debug_pubnames",
SectionId::DebugPubTypes => ".debug_pubtypes",
SectionId::DebugRanges => ".debug_ranges",
SectionId::DebugRngLists => ".debug_rnglists",
SectionId::DebugStr => ".debug_str",
SectionId::DebugStrOffsets => ".debug_str_offsets",
SectionId::DebugTypes => ".debug_types",
}
}
pub fn dwo_name(self) -> Option<&'static str> {
Some(match self {
SectionId::DebugAbbrev => ".debug_abbrev.dwo",
SectionId::DebugInfo => ".debug_info.dwo",
SectionId::DebugLine => ".debug_line.dwo",
SectionId::DebugLoc => ".debug_loc.dwo",
SectionId::DebugLocLists => ".debug_loclists.dwo",
SectionId::DebugMacro => ".debug_macro.dwo",
SectionId::DebugRngLists => ".debug_rnglists.dwo",
SectionId::DebugStr => ".debug_str.dwo",
SectionId::DebugStrOffsets => ".debug_str_offsets.dwo",
_ => return None,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct DwoId(pub u64);
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DwarfFileType {
Main,
Dwo,
}
impl Default for DwarfFileType {
fn default() -> Self {
DwarfFileType::Main
}
}