gsym/convert/
diagnostic.rs1use std::fmt;
2
3use crate::AddressRange;
4
5#[derive(Clone, Debug, Eq, PartialEq)]
14#[non_exhaustive]
15pub enum ConversionWarning {
16 EmbeddedDebugData {
18 reason: Box<str>,
20 },
21 Debuginfod {
23 endpoint: Option<Box<str>>,
25 reason: Box<str>,
27 },
28 SplitDwarfUnavailable {
30 dwo_id: u64,
32 reasons: Box<[Box<str>]>,
34 },
35 NoInlineRecords,
37 MalformedRanges {
39 stopped: bool,
41 reason: Box<str>,
43 },
44 RejectedRange {
46 range: AddressRange,
48 },
49 InvalidStatementSequence {
51 die_offset: u64,
53 sequence_offset: u64,
55 },
56 LineSequenceMismatch {
58 sequences: usize,
60 offsets: usize,
62 },
63 MissingLineFile {
65 address: u64,
67 index: u64,
69 },
70 UnrepresentableLine {
72 address: u64,
74 line: u64,
76 },
77 MissingInlineCallFile {
79 die_offset: u64,
81 index: u64,
83 },
84 InvalidInlineCallLine {
86 die_offset: u64,
88 line: u64,
90 },
91 InvalidDeclarationFile {
93 die_offset: u64,
95 index: u64,
97 },
98 InvalidDeclarationLine {
100 die_offset: u64,
102 line: u64,
104 },
105}
106
107impl fmt::Display for ConversionWarning {
108 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
109 match self {
110 Self::EmbeddedDebugData { reason } => {
111 write!(formatter, "ignoring malformed .gnu_debugdata: {reason}")
112 }
113 Self::Debuginfod { endpoint, reason } => {
114 formatter.write_str("debuginfod")?;
115 if let Some(endpoint) = endpoint {
116 write!(formatter, " {endpoint}")?;
117 }
118 write!(formatter, ": {reason}")
119 }
120 Self::SplitDwarfUnavailable { dwo_id, reasons } => {
121 write!(
122 formatter,
123 "split DWARF unit {dwo_id:#x} has no usable .dwo or .dwp data"
124 )?;
125 for (index, reason) in reasons.iter().enumerate() {
126 formatter.write_str(if index == 0 { ": " } else { "; " })?;
127 formatter.write_str(reason)?;
128 }
129 Ok(())
130 }
131 Self::NoInlineRecords => {
132 formatter.write_str("no valid DWARF inline records were found")
133 }
134 Self::MalformedRanges { stopped, reason } => write!(
135 formatter,
136 "{} malformed DWARF ranges: {reason}",
137 if *stopped { "stopped at" } else { "skipping" }
138 ),
139 Self::RejectedRange { range } => write!(
140 formatter,
141 "skipping non-live or invalid DWARF range {:#x}..{:#x}",
142 range.start, range.end
143 ),
144 Self::InvalidStatementSequence {
145 die_offset,
146 sequence_offset,
147 } => write!(
148 formatter,
149 "function DIE at {die_offset:#x} has an invalid DW_AT_LLVM_stmt_sequence value {sequence_offset:#x}; using matching rows from other sequences"
150 ),
151 Self::LineSequenceMismatch { sequences, offsets } => write!(
152 formatter,
153 "could not associate {sequences} line sequences with {offsets} statement-sequence offsets"
154 ),
155 Self::MissingLineFile { address, index } => write!(
156 formatter,
157 "ignoring DWARF line row at {address:#x} with missing file index {index}"
158 ),
159 Self::UnrepresentableLine { address, line } => write!(
160 formatter,
161 "ignoring DWARF line row at {address:#x} with unrepresentable line number {line}"
162 ),
163 Self::MissingInlineCallFile { die_offset, index } => write!(
164 formatter,
165 "inline DIE at {die_offset:#x} references missing DW_AT_call_file index {index}"
166 ),
167 Self::InvalidInlineCallLine { die_offset, line } => write!(
168 formatter,
169 "inline DIE at {die_offset:#x} has unrepresentable DW_AT_call_line value {line}"
170 ),
171 Self::InvalidDeclarationFile { die_offset, index } => write!(
172 formatter,
173 "function DIE at {die_offset:#x} has invalid DW_AT_decl_file index {index}"
174 ),
175 Self::InvalidDeclarationLine { die_offset, line } => write!(
176 formatter,
177 "function DIE at {die_offset:#x} has unrepresentable DW_AT_decl_line value {line}"
178 ),
179 }
180 }
181}