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
use std::fmt;
use failure::Fail;
use symbolic_common::derive_failure;
use symbolic_debuginfo::ObjectError;
#[doc(hidden)]
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum ValueKind {
Symbol,
Function,
File,
Line,
ParentOffset,
Language,
}
impl fmt::Display for ValueKind {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
ValueKind::Symbol => write!(f, "symbol"),
ValueKind::Function => write!(f, "function"),
ValueKind::File => write!(f, "file"),
ValueKind::Line => write!(f, "line record"),
ValueKind::ParentOffset => write!(f, "inline parent offset"),
ValueKind::Language => write!(f, "language"),
}
}
}
#[derive(Clone, Copy, Debug, Eq, Fail, PartialEq)]
pub enum SymCacheErrorKind {
#[fail(display = "bad symcache magic")]
BadFileMagic,
#[fail(display = "invalid symcache header")]
BadFileHeader,
#[fail(display = "cannot read symcache segment")]
BadSegment,
#[fail(display = "malformed symcache file")]
BadCacheFile,
#[fail(display = "unsupported symcache version")]
UnsupportedVersion,
#[fail(display = "malformed debug info file")]
BadDebugFile,
#[fail(display = "missing debug section")]
MissingDebugSection,
#[fail(display = "no debug information found in file")]
MissingDebugInfo,
#[fail(display = "unsupported debug information")]
UnsupportedDebugKind,
#[fail(display = "{} too large for symcache file format", _0)]
ValueTooLarge(ValueKind),
#[fail(display = "too many {}s for symcache", _0)]
TooManyValues(ValueKind),
#[fail(display = "failed to write symcache")]
WriteFailed,
}
derive_failure!(
SymCacheError,
SymCacheErrorKind,
doc = "An error returned when handling `SymCaches`.",
);
impl From<ObjectError> for SymCacheError {
fn from(error: ObjectError) -> SymCacheError {
error.context(SymCacheErrorKind::BadDebugFile).into()
}
}