1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
use endianity::{Endianity, EndianBuf};
use lookup::{PubStuffParser, LookupEntryIter, DebugLookup, NamesOrTypesSwitch};
use parser::{Format, Result};
use unit::{DebugInfoOffset, parse_debug_info_offset};
use std::ffi;
use std::marker::PhantomData;
use std::rc::Rc;
use Section;
#[derive(Debug, PartialEq, Eq)]
pub struct PubNamesHeader {
format: Format,
length: u64,
version: u16,
info_offset: DebugInfoOffset,
info_length: u64,
}
#[derive(Debug, Clone)]
pub struct PubNamesEntry<'input> {
offset: u64,
name: &'input ffi::CStr,
header: Rc<PubNamesHeader>,
}
impl<'input> PubNamesEntry<'input> {
pub fn name(&self) -> &'input ffi::CStr {
self.name
}
pub fn info_offset(&self) -> DebugInfoOffset {
self.header.info_offset
}
}
#[derive(Clone, Debug)]
pub struct NamesSwitch<'input, Endian>
where Endian: 'input + Endianity
{
phantom: PhantomData<&'input Endian>,
}
impl<'input, Endian> NamesOrTypesSwitch<'input, Endian> for NamesSwitch<'input, Endian>
where Endian: Endianity
{
type Header = PubNamesHeader;
type Entry = PubNamesEntry<'input>;
type Offset = DebugInfoOffset;
fn new_header(format: Format,
set_length: u64,
version: u16,
offset: DebugInfoOffset,
length: u64)
-> Rc<PubNamesHeader> {
Rc::new(PubNamesHeader {
format: format,
length: set_length,
version: version,
info_offset: offset,
info_length: length,
})
}
fn new_entry(offset: u64,
name: &'input ffi::CStr,
header: &Rc<PubNamesHeader>)
-> PubNamesEntry<'input> {
PubNamesEntry {
offset: offset,
name: name,
header: header.clone(),
}
}
fn parse_offset(input: EndianBuf<Endian>,
format: Format)
-> Result<(EndianBuf<Endian>, Self::Offset)> {
parse_debug_info_offset(input, format)
}
fn format_from(header: &PubNamesHeader) -> Format {
header.format
}
}
pub type DebugPubNames<'input, Endian> = DebugLookup<'input,
Endian,
PubStuffParser<'input,
Endian,
NamesSwitch<'input, Endian>>>;
impl<'input, Endian> Section<'input> for DebugPubNames<'input, Endian>
where Endian: Endianity
{
fn section_name() -> &'static str {
".debug_pubnames"
}
}
impl<'input, Endian> From<&'input [u8]> for DebugPubNames<'input, Endian>
where Endian: Endianity
{
fn from(v: &'input [u8]) -> Self {
Self::new(v)
}
}
pub type PubNamesEntryIter<'input, Endian> = LookupEntryIter<'input,
Endian,
PubStuffParser<'input,
Endian,
NamesSwitch<'input,
Endian>>>;