use std::fmt;
use crate::AddressRange;
#[derive(Clone, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub enum ConversionWarning {
EmbeddedDebugData {
reason: Box<str>,
},
Debuginfod {
endpoint: Option<Box<str>>,
reason: Box<str>,
},
SplitDwarfUnavailable {
dwo_id: u64,
reasons: Box<[Box<str>]>,
},
NoInlineRecords,
MalformedRanges {
stopped: bool,
reason: Box<str>,
},
RejectedRange {
range: AddressRange,
},
InvalidStatementSequence {
die_offset: u64,
sequence_offset: u64,
},
LineSequenceMismatch {
sequences: usize,
offsets: usize,
},
MissingLineFile {
address: u64,
index: u64,
},
UnrepresentableLine {
address: u64,
line: u64,
},
MissingInlineCallFile {
die_offset: u64,
index: u64,
},
InvalidInlineCallLine {
die_offset: u64,
line: u64,
},
InvalidDeclarationFile {
die_offset: u64,
index: u64,
},
InvalidDeclarationLine {
die_offset: u64,
line: u64,
},
}
impl fmt::Display for ConversionWarning {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::EmbeddedDebugData { reason } => {
write!(formatter, "ignoring malformed .gnu_debugdata: {reason}")
}
Self::Debuginfod { endpoint, reason } => {
formatter.write_str("debuginfod")?;
if let Some(endpoint) = endpoint {
write!(formatter, " {endpoint}")?;
}
write!(formatter, ": {reason}")
}
Self::SplitDwarfUnavailable { dwo_id, reasons } => {
write!(
formatter,
"split DWARF unit {dwo_id:#x} has no usable .dwo or .dwp data"
)?;
for (index, reason) in reasons.iter().enumerate() {
formatter.write_str(if index == 0 { ": " } else { "; " })?;
formatter.write_str(reason)?;
}
Ok(())
}
Self::NoInlineRecords => {
formatter.write_str("no valid DWARF inline records were found")
}
Self::MalformedRanges { stopped, reason } => write!(
formatter,
"{} malformed DWARF ranges: {reason}",
if *stopped { "stopped at" } else { "skipping" }
),
Self::RejectedRange { range } => write!(
formatter,
"skipping non-live or invalid DWARF range {:#x}..{:#x}",
range.start, range.end
),
Self::InvalidStatementSequence {
die_offset,
sequence_offset,
} => write!(
formatter,
"function DIE at {die_offset:#x} has an invalid DW_AT_LLVM_stmt_sequence value {sequence_offset:#x}; using matching rows from other sequences"
),
Self::LineSequenceMismatch { sequences, offsets } => write!(
formatter,
"could not associate {sequences} line sequences with {offsets} statement-sequence offsets"
),
Self::MissingLineFile { address, index } => write!(
formatter,
"ignoring DWARF line row at {address:#x} with missing file index {index}"
),
Self::UnrepresentableLine { address, line } => write!(
formatter,
"ignoring DWARF line row at {address:#x} with unrepresentable line number {line}"
),
Self::MissingInlineCallFile { die_offset, index } => write!(
formatter,
"inline DIE at {die_offset:#x} references missing DW_AT_call_file index {index}"
),
Self::InvalidInlineCallLine { die_offset, line } => write!(
formatter,
"inline DIE at {die_offset:#x} has unrepresentable DW_AT_call_line value {line}"
),
Self::InvalidDeclarationFile { die_offset, index } => write!(
formatter,
"function DIE at {die_offset:#x} has invalid DW_AT_decl_file index {index}"
),
Self::InvalidDeclarationLine { die_offset, line } => write!(
formatter,
"function DIE at {die_offset:#x} has unrepresentable DW_AT_decl_line value {line}"
),
}
}
}