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
use std::convert::Infallible;
use std::iter;
use symbolic_common::{Arch, CodeId, DebugId};
use symbolic_ppdb::{FormatError, PortablePdb};
use crate::{
DebugSession, FileEntry, FileFormat, Function, ObjectKind, ObjectLike, Parse, Symbol, SymbolMap,
};
pub type PortablePdbSymbolIterator<'data> = iter::Empty<Symbol<'data>>;
pub type PortablePdbFunctionIterator<'session> =
iter::Empty<Result<Function<'session>, Infallible>>;
pub type PortablePdbFileIterator<'session> = iter::Empty<Result<FileEntry<'session>, Infallible>>;
#[derive(Debug)]
pub struct PortablePdbObject<'data> {
data: &'data [u8],
ppdb: PortablePdb<'data>,
}
impl<'data> PortablePdbObject<'data> {
pub fn portable_pdb(&self) -> &PortablePdb {
&self.ppdb
}
pub fn data(&self) -> &'data [u8] {
self.data
}
}
impl<'data, 'object> ObjectLike<'data, 'object> for PortablePdbObject<'data> {
type Error = Infallible;
type Session = PortablePdbDebugSession;
type SymbolIterator = PortablePdbSymbolIterator<'data>;
fn debug_id(&self) -> DebugId {
self.ppdb.pdb_id().unwrap_or_default()
}
fn code_id(&self) -> Option<CodeId> {
None
}
fn arch(&self) -> Arch {
Arch::Unknown
}
fn kind(&self) -> ObjectKind {
ObjectKind::Debug
}
fn load_address(&self) -> u64 {
0
}
fn has_symbols(&self) -> bool {
false
}
fn symbols(&self) -> PortablePdbSymbolIterator<'data> {
iter::empty()
}
fn symbol_map(&self) -> SymbolMap<'data> {
SymbolMap::new()
}
fn has_debug_info(&self) -> bool {
self.ppdb.has_debug_info()
}
fn debug_session(&self) -> Result<PortablePdbDebugSession, Infallible> {
Ok(PortablePdbDebugSession)
}
fn has_unwind_info(&self) -> bool {
false
}
fn has_sources(&self) -> bool {
false
}
fn is_malformed(&self) -> bool {
false
}
fn file_format(&self) -> FileFormat {
FileFormat::PortablePdb
}
}
impl<'data> Parse<'data> for PortablePdbObject<'data> {
type Error = FormatError;
fn test(data: &[u8]) -> bool {
PortablePdb::peek(data)
}
fn parse(data: &'data [u8]) -> Result<Self, Self::Error> {
let ppdb = PortablePdb::parse(data)?;
Ok(Self { data, ppdb })
}
}
pub struct PortablePdbDebugSession;
impl<'session> DebugSession<'session> for PortablePdbDebugSession {
type Error = Infallible;
type FunctionIterator = PortablePdbFunctionIterator<'session>;
type FileIterator = PortablePdbFileIterator<'session>;
fn functions(&'session self) -> Self::FunctionIterator {
iter::empty()
}
fn files(&'session self) -> Self::FileIterator {
iter::empty()
}
fn source_by_path(
&self,
_path: &str,
) -> Result<Option<std::borrow::Cow<'_, str>>, Self::Error> {
Ok(None)
}
}