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
#[cfg(feature = "enable-serde")]
use serde::{Deserialize, Serialize};
#[cfg(feature = "unwind")]
pub mod systemv;
#[cfg(feature = "unwind")]
pub mod winx64;
#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
#[non_exhaustive]
pub enum UnwindInfo {
#[cfg(feature = "unwind")]
WindowsX64(winx64::UnwindInfo),
#[cfg(feature = "unwind")]
SystemV(systemv::UnwindInfo),
}
pub mod input {
use crate::binemit::CodeOffset;
use alloc::vec::Vec;
#[cfg(feature = "enable-serde")]
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
pub enum UnwindCode<Reg> {
SaveRegister {
reg: Reg,
stack_offset: u32,
},
RestoreRegister {
reg: Reg,
},
StackAlloc {
size: u32,
},
StackDealloc {
size: u32,
},
SetFramePointer {
reg: Reg,
},
RestoreFramePointer,
RememberState,
RestoreState,
}
#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
pub struct UnwindInfo<Reg> {
pub prologue_size: CodeOffset,
pub prologue_unwind_codes: Vec<(CodeOffset, UnwindCode<Reg>)>,
pub epilogues_unwind_codes: Vec<Vec<(CodeOffset, UnwindCode<Reg>)>>,
pub function_size: CodeOffset,
pub word_size: u8,
pub initial_sp_offset: u8,
}
}