1#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3pub enum Format {
4 Dwarf64 = 8,
6 Dwarf32 = 4,
8}
9
10impl Format {
11 #[inline]
13 pub fn initial_length_size(self) -> u8 {
14 match self {
15 Format::Dwarf32 => 4,
16 Format::Dwarf64 => 12,
17 }
18 }
19
20 #[inline]
22 pub fn word_size(self) -> u8 {
23 match self {
24 Format::Dwarf32 => 4,
25 Format::Dwarf64 => 8,
26 }
27 }
28}
29
30#[derive(Clone, Copy, Debug, PartialEq, Eq)]
32#[non_exhaustive]
33pub enum Vendor {
34 Default,
36 AArch64,
38}
39
40#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
44#[repr(C)]
47pub struct Encoding {
48 pub address_size: u8,
50
51 pub format: Format,
53
54 pub version: u16,
56}
57
58#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
60pub struct LineEncoding {
61 pub minimum_instruction_length: u8,
63
64 pub maximum_operations_per_instruction: u8,
67
68 pub default_is_stmt: bool,
70
71 pub line_base: i8,
73
74 pub line_range: u8,
76}
77
78impl Default for LineEncoding {
79 fn default() -> Self {
80 LineEncoding {
82 minimum_instruction_length: 1,
83 maximum_operations_per_instruction: 1,
84 default_is_stmt: true,
85 line_base: -5,
86 line_range: 14,
87 }
88 }
89}
90
91#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
96pub struct Register(pub u16);
97
98#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
100pub struct DebugAbbrevOffset<T = usize>(pub T);
101
102#[derive(Debug, Clone, Copy, PartialEq, Eq)]
104pub struct DebugAddrOffset<T = usize>(pub T);
105
106#[derive(Debug, Clone, Copy, PartialEq, Eq)]
108pub struct DebugAddrBase<T = usize>(pub T);
109
110#[derive(Debug, Clone, Copy, PartialEq, Eq)]
112pub struct DebugAddrIndex<T = usize>(pub T);
113
114#[derive(Debug, Clone, Copy, PartialEq, Eq)]
116pub struct DebugArangesOffset<T = usize>(pub T);
117
118#[derive(Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Hash)]
120pub struct DebugInfoOffset<T = usize>(pub T);
121
122#[derive(Debug, Clone, Copy, PartialEq, Eq)]
124pub struct DebugLineOffset<T = usize>(pub T);
125
126#[derive(Debug, Clone, Copy, PartialEq, Eq)]
128pub struct DebugLineStrOffset<T = usize>(pub T);
129
130#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
133pub struct LocationListsOffset<T = usize>(pub T);
134
135#[derive(Debug, Clone, Copy, PartialEq, Eq)]
137pub struct DebugLocListsBase<T = usize>(pub T);
138
139#[derive(Debug, Clone, Copy, PartialEq, Eq)]
141pub struct DebugLocListsIndex<T = usize>(pub T);
142
143#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
145pub struct DebugMacinfoOffset<T = usize>(pub T);
146
147#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
149pub struct DebugMacroOffset<T = usize>(pub T);
150
151#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
153pub struct DebugNamesOffset<T = usize>(pub T);
154
155#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
161pub struct RawRangeListsOffset<T = usize>(pub T);
162
163#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
166pub struct RangeListsOffset<T = usize>(pub T);
167
168#[derive(Debug, Clone, Copy, PartialEq, Eq)]
170pub struct DebugRngListsBase<T = usize>(pub T);
171
172#[derive(Debug, Clone, Copy, PartialEq, Eq)]
174pub struct DebugRngListsIndex<T = usize>(pub T);
175
176#[derive(Debug, Clone, Copy, PartialEq, Eq)]
178pub struct DebugStrOffset<T = usize>(pub T);
179
180#[derive(Debug, Clone, Copy, PartialEq, Eq)]
182pub struct DebugStrOffsetsBase<T = usize>(pub T);
183
184#[derive(Debug, Clone, Copy, PartialEq, Eq)]
186pub struct DebugStrOffsetsIndex<T = usize>(pub T);
187
188#[derive(Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Hash)]
190pub struct DebugTypesOffset<T = usize>(pub T);
191
192#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
194pub struct DebugTypeSignature(pub u64);
195
196#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
198pub struct DebugFrameOffset<T = usize>(pub T);
199
200impl<T> From<T> for DebugFrameOffset<T> {
201 #[inline]
202 fn from(o: T) -> Self {
203 DebugFrameOffset(o)
204 }
205}
206
207#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
209pub struct EhFrameOffset<T = usize>(pub T);
210
211impl<T> From<T> for EhFrameOffset<T> {
212 #[inline]
213 fn from(o: T) -> Self {
214 EhFrameOffset(o)
215 }
216}
217
218#[derive(Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Hash)]
223pub struct UnitSectionOffset<T = usize>(pub T);
224
225#[derive(Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Hash)]
227pub enum SectionId {
228 DebugAbbrev,
230 DebugAddr,
232 DebugAranges,
234 DebugCuIndex,
236 DebugFrame,
238 EhFrame,
240 EhFrameHdr,
242 DebugInfo,
244 DebugLine,
246 DebugLineStr,
248 DebugLoc,
250 DebugLocLists,
252 DebugMacinfo,
254 DebugMacro,
256 DebugNames,
258 DebugPubNames,
260 DebugPubTypes,
262 DebugRanges,
264 DebugRngLists,
266 DebugStr,
268 DebugStrOffsets,
270 DebugTuIndex,
272 DebugTypes,
274}
275
276impl SectionId {
277 pub fn name(self) -> &'static str {
279 match self {
280 SectionId::DebugAbbrev => ".debug_abbrev",
281 SectionId::DebugAddr => ".debug_addr",
282 SectionId::DebugAranges => ".debug_aranges",
283 SectionId::DebugCuIndex => ".debug_cu_index",
284 SectionId::DebugFrame => ".debug_frame",
285 SectionId::EhFrame => ".eh_frame",
286 SectionId::EhFrameHdr => ".eh_frame_hdr",
287 SectionId::DebugInfo => ".debug_info",
288 SectionId::DebugLine => ".debug_line",
289 SectionId::DebugLineStr => ".debug_line_str",
290 SectionId::DebugLoc => ".debug_loc",
291 SectionId::DebugLocLists => ".debug_loclists",
292 SectionId::DebugMacinfo => ".debug_macinfo",
293 SectionId::DebugMacro => ".debug_macro",
294 SectionId::DebugNames => ".debug_names",
295 SectionId::DebugPubNames => ".debug_pubnames",
296 SectionId::DebugPubTypes => ".debug_pubtypes",
297 SectionId::DebugRanges => ".debug_ranges",
298 SectionId::DebugRngLists => ".debug_rnglists",
299 SectionId::DebugStr => ".debug_str",
300 SectionId::DebugStrOffsets => ".debug_str_offsets",
301 SectionId::DebugTuIndex => ".debug_tu_index",
302 SectionId::DebugTypes => ".debug_types",
303 }
304 }
305
306 pub fn dwo_name(self) -> Option<&'static str> {
308 Some(match self {
309 SectionId::DebugAbbrev => ".debug_abbrev.dwo",
310 SectionId::DebugCuIndex => ".debug_cu_index",
311 SectionId::DebugInfo => ".debug_info.dwo",
312 SectionId::DebugLine => ".debug_line.dwo",
313 SectionId::DebugLoc => ".debug_loc.dwo",
316 SectionId::DebugLocLists => ".debug_loclists.dwo",
317 SectionId::DebugMacinfo => ".debug_macinfo.dwo",
318 SectionId::DebugMacro => ".debug_macro.dwo",
319 SectionId::DebugRngLists => ".debug_rnglists.dwo",
320 SectionId::DebugStr => ".debug_str.dwo",
321 SectionId::DebugStrOffsets => ".debug_str_offsets.dwo",
322 SectionId::DebugTuIndex => ".debug_tu_index",
323 SectionId::DebugTypes => ".debug_types.dwo",
324 _ => return None,
325 })
326 }
327
328 pub fn xcoff_name(self) -> Option<&'static str> {
330 Some(match self {
331 SectionId::DebugAbbrev => ".dwabrev",
332 SectionId::DebugAranges => ".dwarnge",
333 SectionId::DebugFrame => ".dwframe",
334 SectionId::DebugInfo => ".dwinfo",
335 SectionId::DebugLine => ".dwline",
336 SectionId::DebugLoc => ".dwloc",
337 SectionId::DebugMacinfo => ".dwmac",
338 SectionId::DebugPubNames => ".dwpbnms",
339 SectionId::DebugPubTypes => ".dwpbtyp",
340 SectionId::DebugRanges => ".dwrnges",
341 SectionId::DebugStr => ".dwstr",
342 _ => return None,
343 })
344 }
345
346 pub fn is_string(self) -> bool {
350 matches!(self, SectionId::DebugStr | SectionId::DebugLineStr)
351 }
352}
353
354#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
357pub struct DwoId(pub u64);
358
359#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
362pub enum DwarfFileType {
363 #[default]
365 Main,
366 Dwo,
368 }