Skip to content

Commit e5f0973

Browse files
committed
feat: add missing unw_* wrappers
1 parent 47528c1 commit e5f0973

File tree

3 files changed

+359
-172
lines changed

3 files changed

+359
-172
lines changed

packages/vex-libunwind-sys/src/lib.rs

+139-134
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
//! Bindings to the low-level `unw_*` LLVM libunwind APIs which are an interface defined by the HP libunwind project.
1+
//! Bindings to the low-level `unw_*` LLVM libunwind APIs which are an interface
2+
//! defined by the HP libunwind project.
23
#![allow(non_camel_case_types, missing_docs)]
34
#![no_std]
45

@@ -53,13 +54,13 @@ pub const UNW_STEP_SUCCESS: c_int = 1;
5354
pub const UNW_STEP_END: c_int = 0;
5455

5556
#[repr(C)]
56-
#[derive(Debug, Copy, Clone)]
57+
#[derive(Copy, Clone)]
5758
pub struct unw_context_t {
5859
_data: [u64; CONTEXT_SIZE],
5960
}
6061

6162
#[repr(C)]
62-
#[derive(Debug, Copy, Clone)]
63+
#[derive(Copy, Clone)]
6364
pub struct unw_cursor_t {
6465
_data: [u64; CURSOR_SIZE],
6566
}
@@ -136,135 +137,139 @@ extern "C" {
136137
pub static mut unw_local_addr_space: unw_addr_space_t;
137138
}
138139

139-
/// Instruction pointer
140-
pub const UNW_REG_IP: unw_regnum_t = -1;
141-
/// Stack pointer
142-
pub const UNW_REG_SP: unw_regnum_t = -2;
140+
pub mod registers {
141+
use super::unw_regnum_t;
143142

144-
// 32-bit ARM registers. Numbers match DWARF for ARM spec #3.1 Table 1.
145-
// Naming scheme uses recommendations given in Note 4 for VFP-v2 and VFP-v3.
146-
// In this scheme, even though the 64-bit floating point registers D0-D31
147-
// overlap physically with the 32-bit floating pointer registers S0-S31,
148-
// they are given a non-overlapping range of register numbers.
149-
//
150-
// Commented out ranges are not preserved during unwinding.
151-
pub const UNW_ARM_R0: unw_regnum_t = 0;
152-
pub const UNW_ARM_R1: unw_regnum_t = 1;
153-
pub const UNW_ARM_R2: unw_regnum_t = 2;
154-
pub const UNW_ARM_R3: unw_regnum_t = 3;
155-
pub const UNW_ARM_R4: unw_regnum_t = 4;
156-
pub const UNW_ARM_R5: unw_regnum_t = 5;
157-
pub const UNW_ARM_R6: unw_regnum_t = 6;
158-
pub const UNW_ARM_R7: unw_regnum_t = 7;
159-
pub const UNW_ARM_R8: unw_regnum_t = 8;
160-
pub const UNW_ARM_R9: unw_regnum_t = 9;
161-
pub const UNW_ARM_R10: unw_regnum_t = 10;
162-
pub const UNW_ARM_R11: unw_regnum_t = 11;
163-
pub const UNW_ARM_R12: unw_regnum_t = 12;
164-
pub const UNW_ARM_SP: unw_regnum_t = 13; // Logical alias for UNW_REG_SP
165-
pub const UNW_ARM_R13: unw_regnum_t = 13;
166-
pub const UNW_ARM_LR: unw_regnum_t = 14;
167-
pub const UNW_ARM_R14: unw_regnum_t = 14;
168-
pub const UNW_ARM_IP: unw_regnum_t = 15; // Logical alias for UNW_REG_IP
169-
pub const UNW_ARM_R15: unw_regnum_t = 15;
170-
// 16-63 -- OBSOLETE. Used in VFP1 to represent both S0-S31 and D0-D31.
171-
pub const UNW_ARM_S0: unw_regnum_t = 64;
172-
pub const UNW_ARM_S1: unw_regnum_t = 65;
173-
pub const UNW_ARM_S2: unw_regnum_t = 66;
174-
pub const UNW_ARM_S3: unw_regnum_t = 67;
175-
pub const UNW_ARM_S4: unw_regnum_t = 68;
176-
pub const UNW_ARM_S5: unw_regnum_t = 69;
177-
pub const UNW_ARM_S6: unw_regnum_t = 70;
178-
pub const UNW_ARM_S7: unw_regnum_t = 71;
179-
pub const UNW_ARM_S8: unw_regnum_t = 72;
180-
pub const UNW_ARM_S9: unw_regnum_t = 73;
181-
pub const UNW_ARM_S10: unw_regnum_t = 74;
182-
pub const UNW_ARM_S11: unw_regnum_t = 75;
183-
pub const UNW_ARM_S12: unw_regnum_t = 76;
184-
pub const UNW_ARM_S13: unw_regnum_t = 77;
185-
pub const UNW_ARM_S14: unw_regnum_t = 78;
186-
pub const UNW_ARM_S15: unw_regnum_t = 79;
187-
pub const UNW_ARM_S16: unw_regnum_t = 80;
188-
pub const UNW_ARM_S17: unw_regnum_t = 81;
189-
pub const UNW_ARM_S18: unw_regnum_t = 82;
190-
pub const UNW_ARM_S19: unw_regnum_t = 83;
191-
pub const UNW_ARM_S20: unw_regnum_t = 84;
192-
pub const UNW_ARM_S21: unw_regnum_t = 85;
193-
pub const UNW_ARM_S22: unw_regnum_t = 86;
194-
pub const UNW_ARM_S23: unw_regnum_t = 87;
195-
pub const UNW_ARM_S24: unw_regnum_t = 88;
196-
pub const UNW_ARM_S25: unw_regnum_t = 89;
197-
pub const UNW_ARM_S26: unw_regnum_t = 90;
198-
pub const UNW_ARM_S27: unw_regnum_t = 91;
199-
pub const UNW_ARM_S28: unw_regnum_t = 92;
200-
pub const UNW_ARM_S29: unw_regnum_t = 93;
201-
pub const UNW_ARM_S30: unw_regnum_t = 94;
202-
pub const UNW_ARM_S31: unw_regnum_t = 95;
203-
// 96-103 -- OBSOLETE. F0-F7. Used by the FPA system. Superseded by VFP.
204-
// 104-111 -- wCGR0-wCGR7, ACC0-ACC7 (Intel wireless MMX)
205-
pub const UNW_ARM_WR0: unw_regnum_t = 112;
206-
pub const UNW_ARM_WR1: unw_regnum_t = 113;
207-
pub const UNW_ARM_WR2: unw_regnum_t = 114;
208-
pub const UNW_ARM_WR3: unw_regnum_t = 115;
209-
pub const UNW_ARM_WR4: unw_regnum_t = 116;
210-
pub const UNW_ARM_WR5: unw_regnum_t = 117;
211-
pub const UNW_ARM_WR6: unw_regnum_t = 118;
212-
pub const UNW_ARM_WR7: unw_regnum_t = 119;
213-
pub const UNW_ARM_WR8: unw_regnum_t = 120;
214-
pub const UNW_ARM_WR9: unw_regnum_t = 121;
215-
pub const UNW_ARM_WR10: unw_regnum_t = 122;
216-
pub const UNW_ARM_WR11: unw_regnum_t = 123;
217-
pub const UNW_ARM_WR12: unw_regnum_t = 124;
218-
pub const UNW_ARM_WR13: unw_regnum_t = 125;
219-
pub const UNW_ARM_WR14: unw_regnum_t = 126;
220-
pub const UNW_ARM_WR15: unw_regnum_t = 127;
221-
// 128-133 -- SPSR, SPSR_{FIQ|IRQ|ABT|UND|SVC}
222-
// 134-143 -- Reserved
223-
// 144-150 -- R8_USR-R14_USR
224-
// 151-157 -- R8_FIQ-R14_FIQ
225-
// 158-159 -- R13_IRQ-R14_IRQ
226-
// 160-161 -- R13_ABT-R14_ABT
227-
// 162-163 -- R13_UND-R14_UND
228-
// 164-165 -- R13_SVC-R14_SVC
229-
// 166-191 -- Reserved
230-
pub const UNW_ARM_WC0: unw_regnum_t = 192;
231-
pub const UNW_ARM_WC1: unw_regnum_t = 193;
232-
pub const UNW_ARM_WC2: unw_regnum_t = 194;
233-
pub const UNW_ARM_WC3: unw_regnum_t = 195;
234-
// 196-199 -- wC4-wC7 (Intel wireless MMX control)
235-
// 200-255 -- Reserved
236-
pub const UNW_ARM_D0: unw_regnum_t = 256;
237-
pub const UNW_ARM_D1: unw_regnum_t = 257;
238-
pub const UNW_ARM_D2: unw_regnum_t = 258;
239-
pub const UNW_ARM_D3: unw_regnum_t = 259;
240-
pub const UNW_ARM_D4: unw_regnum_t = 260;
241-
pub const UNW_ARM_D5: unw_regnum_t = 261;
242-
pub const UNW_ARM_D6: unw_regnum_t = 262;
243-
pub const UNW_ARM_D7: unw_regnum_t = 263;
244-
pub const UNW_ARM_D8: unw_regnum_t = 264;
245-
pub const UNW_ARM_D9: unw_regnum_t = 265;
246-
pub const UNW_ARM_D10: unw_regnum_t = 266;
247-
pub const UNW_ARM_D11: unw_regnum_t = 267;
248-
pub const UNW_ARM_D12: unw_regnum_t = 268;
249-
pub const UNW_ARM_D13: unw_regnum_t = 269;
250-
pub const UNW_ARM_D14: unw_regnum_t = 270;
251-
pub const UNW_ARM_D15: unw_regnum_t = 271;
252-
pub const UNW_ARM_D16: unw_regnum_t = 272;
253-
pub const UNW_ARM_D17: unw_regnum_t = 273;
254-
pub const UNW_ARM_D18: unw_regnum_t = 274;
255-
pub const UNW_ARM_D19: unw_regnum_t = 275;
256-
pub const UNW_ARM_D20: unw_regnum_t = 276;
257-
pub const UNW_ARM_D21: unw_regnum_t = 277;
258-
pub const UNW_ARM_D22: unw_regnum_t = 278;
259-
pub const UNW_ARM_D23: unw_regnum_t = 279;
260-
pub const UNW_ARM_D24: unw_regnum_t = 280;
261-
pub const UNW_ARM_D25: unw_regnum_t = 281;
262-
pub const UNW_ARM_D26: unw_regnum_t = 282;
263-
pub const UNW_ARM_D27: unw_regnum_t = 283;
264-
pub const UNW_ARM_D28: unw_regnum_t = 284;
265-
pub const UNW_ARM_D29: unw_regnum_t = 285;
266-
pub const UNW_ARM_D30: unw_regnum_t = 286;
267-
pub const UNW_ARM_D31: unw_regnum_t = 287;
268-
// 288-319 -- Reserved for VFP/Neon
269-
// 320-8191 -- Reserved
270-
// 8192-16383 -- Unspecified vendor co-processor register.
143+
/// Instruction pointer
144+
pub const UNW_REG_IP: unw_regnum_t = -1;
145+
/// Stack pointer
146+
pub const UNW_REG_SP: unw_regnum_t = -2;
147+
148+
// 32-bit ARM registers. Numbers match DWARF for ARM spec #3.1 Table 1.
149+
// Naming scheme uses recommendations given in Note 4 for VFP-v2 and VFP-v3.
150+
// In this scheme, even though the 64-bit floating point registers D0-D31
151+
// overlap physically with the 32-bit floating pointer registers S0-S31,
152+
// they are given a non-overlapping range of register numbers.
153+
//
154+
// Commented out ranges are not preserved during unwinding.
155+
pub const UNW_ARM_R0: unw_regnum_t = 0;
156+
pub const UNW_ARM_R1: unw_regnum_t = 1;
157+
pub const UNW_ARM_R2: unw_regnum_t = 2;
158+
pub const UNW_ARM_R3: unw_regnum_t = 3;
159+
pub const UNW_ARM_R4: unw_regnum_t = 4;
160+
pub const UNW_ARM_R5: unw_regnum_t = 5;
161+
pub const UNW_ARM_R6: unw_regnum_t = 6;
162+
pub const UNW_ARM_R7: unw_regnum_t = 7;
163+
pub const UNW_ARM_R8: unw_regnum_t = 8;
164+
pub const UNW_ARM_R9: unw_regnum_t = 9;
165+
pub const UNW_ARM_R10: unw_regnum_t = 10;
166+
pub const UNW_ARM_R11: unw_regnum_t = 11;
167+
pub const UNW_ARM_R12: unw_regnum_t = 12;
168+
pub const UNW_ARM_SP: unw_regnum_t = 13; // Logical alias for UNW_REG_SP
169+
pub const UNW_ARM_R13: unw_regnum_t = 13;
170+
pub const UNW_ARM_LR: unw_regnum_t = 14;
171+
pub const UNW_ARM_R14: unw_regnum_t = 14;
172+
pub const UNW_ARM_IP: unw_regnum_t = 15; // Logical alias for UNW_REG_IP
173+
pub const UNW_ARM_R15: unw_regnum_t = 15;
174+
// 16-63 -- OBSOLETE. Used in VFP1 to represent both S0-S31 and D0-D31.
175+
pub const UNW_ARM_S0: unw_regnum_t = 64;
176+
pub const UNW_ARM_S1: unw_regnum_t = 65;
177+
pub const UNW_ARM_S2: unw_regnum_t = 66;
178+
pub const UNW_ARM_S3: unw_regnum_t = 67;
179+
pub const UNW_ARM_S4: unw_regnum_t = 68;
180+
pub const UNW_ARM_S5: unw_regnum_t = 69;
181+
pub const UNW_ARM_S6: unw_regnum_t = 70;
182+
pub const UNW_ARM_S7: unw_regnum_t = 71;
183+
pub const UNW_ARM_S8: unw_regnum_t = 72;
184+
pub const UNW_ARM_S9: unw_regnum_t = 73;
185+
pub const UNW_ARM_S10: unw_regnum_t = 74;
186+
pub const UNW_ARM_S11: unw_regnum_t = 75;
187+
pub const UNW_ARM_S12: unw_regnum_t = 76;
188+
pub const UNW_ARM_S13: unw_regnum_t = 77;
189+
pub const UNW_ARM_S14: unw_regnum_t = 78;
190+
pub const UNW_ARM_S15: unw_regnum_t = 79;
191+
pub const UNW_ARM_S16: unw_regnum_t = 80;
192+
pub const UNW_ARM_S17: unw_regnum_t = 81;
193+
pub const UNW_ARM_S18: unw_regnum_t = 82;
194+
pub const UNW_ARM_S19: unw_regnum_t = 83;
195+
pub const UNW_ARM_S20: unw_regnum_t = 84;
196+
pub const UNW_ARM_S21: unw_regnum_t = 85;
197+
pub const UNW_ARM_S22: unw_regnum_t = 86;
198+
pub const UNW_ARM_S23: unw_regnum_t = 87;
199+
pub const UNW_ARM_S24: unw_regnum_t = 88;
200+
pub const UNW_ARM_S25: unw_regnum_t = 89;
201+
pub const UNW_ARM_S26: unw_regnum_t = 90;
202+
pub const UNW_ARM_S27: unw_regnum_t = 91;
203+
pub const UNW_ARM_S28: unw_regnum_t = 92;
204+
pub const UNW_ARM_S29: unw_regnum_t = 93;
205+
pub const UNW_ARM_S30: unw_regnum_t = 94;
206+
pub const UNW_ARM_S31: unw_regnum_t = 95;
207+
// 96-103 -- OBSOLETE. F0-F7. Used by the FPA system. Superseded by VFP.
208+
// 104-111 -- wCGR0-wCGR7, ACC0-ACC7 (Intel wireless MMX)
209+
pub const UNW_ARM_WR0: unw_regnum_t = 112;
210+
pub const UNW_ARM_WR1: unw_regnum_t = 113;
211+
pub const UNW_ARM_WR2: unw_regnum_t = 114;
212+
pub const UNW_ARM_WR3: unw_regnum_t = 115;
213+
pub const UNW_ARM_WR4: unw_regnum_t = 116;
214+
pub const UNW_ARM_WR5: unw_regnum_t = 117;
215+
pub const UNW_ARM_WR6: unw_regnum_t = 118;
216+
pub const UNW_ARM_WR7: unw_regnum_t = 119;
217+
pub const UNW_ARM_WR8: unw_regnum_t = 120;
218+
pub const UNW_ARM_WR9: unw_regnum_t = 121;
219+
pub const UNW_ARM_WR10: unw_regnum_t = 122;
220+
pub const UNW_ARM_WR11: unw_regnum_t = 123;
221+
pub const UNW_ARM_WR12: unw_regnum_t = 124;
222+
pub const UNW_ARM_WR13: unw_regnum_t = 125;
223+
pub const UNW_ARM_WR14: unw_regnum_t = 126;
224+
pub const UNW_ARM_WR15: unw_regnum_t = 127;
225+
// 128-133 -- SPSR, SPSR_{FIQ|IRQ|ABT|UND|SVC}
226+
// 134-143 -- Reserved
227+
// 144-150 -- R8_USR-R14_USR
228+
// 151-157 -- R8_FIQ-R14_FIQ
229+
// 158-159 -- R13_IRQ-R14_IRQ
230+
// 160-161 -- R13_ABT-R14_ABT
231+
// 162-163 -- R13_UND-R14_UND
232+
// 164-165 -- R13_SVC-R14_SVC
233+
// 166-191 -- Reserved
234+
pub const UNW_ARM_WC0: unw_regnum_t = 192;
235+
pub const UNW_ARM_WC1: unw_regnum_t = 193;
236+
pub const UNW_ARM_WC2: unw_regnum_t = 194;
237+
pub const UNW_ARM_WC3: unw_regnum_t = 195;
238+
// 196-199 -- wC4-wC7 (Intel wireless MMX control)
239+
// 200-255 -- Reserved
240+
pub const UNW_ARM_D0: unw_regnum_t = 256;
241+
pub const UNW_ARM_D1: unw_regnum_t = 257;
242+
pub const UNW_ARM_D2: unw_regnum_t = 258;
243+
pub const UNW_ARM_D3: unw_regnum_t = 259;
244+
pub const UNW_ARM_D4: unw_regnum_t = 260;
245+
pub const UNW_ARM_D5: unw_regnum_t = 261;
246+
pub const UNW_ARM_D6: unw_regnum_t = 262;
247+
pub const UNW_ARM_D7: unw_regnum_t = 263;
248+
pub const UNW_ARM_D8: unw_regnum_t = 264;
249+
pub const UNW_ARM_D9: unw_regnum_t = 265;
250+
pub const UNW_ARM_D10: unw_regnum_t = 266;
251+
pub const UNW_ARM_D11: unw_regnum_t = 267;
252+
pub const UNW_ARM_D12: unw_regnum_t = 268;
253+
pub const UNW_ARM_D13: unw_regnum_t = 269;
254+
pub const UNW_ARM_D14: unw_regnum_t = 270;
255+
pub const UNW_ARM_D15: unw_regnum_t = 271;
256+
pub const UNW_ARM_D16: unw_regnum_t = 272;
257+
pub const UNW_ARM_D17: unw_regnum_t = 273;
258+
pub const UNW_ARM_D18: unw_regnum_t = 274;
259+
pub const UNW_ARM_D19: unw_regnum_t = 275;
260+
pub const UNW_ARM_D20: unw_regnum_t = 276;
261+
pub const UNW_ARM_D21: unw_regnum_t = 277;
262+
pub const UNW_ARM_D22: unw_regnum_t = 278;
263+
pub const UNW_ARM_D23: unw_regnum_t = 279;
264+
pub const UNW_ARM_D24: unw_regnum_t = 280;
265+
pub const UNW_ARM_D25: unw_regnum_t = 281;
266+
pub const UNW_ARM_D26: unw_regnum_t = 282;
267+
pub const UNW_ARM_D27: unw_regnum_t = 283;
268+
pub const UNW_ARM_D28: unw_regnum_t = 284;
269+
pub const UNW_ARM_D29: unw_regnum_t = 285;
270+
pub const UNW_ARM_D30: unw_regnum_t = 286;
271+
pub const UNW_ARM_D31: unw_regnum_t = 287;
272+
// 288-319 -- Reserved for VFP/Neon
273+
// 320-8191 -- Reserved
274+
// 8192-16383 -- Unspecified vendor co-processor register.
275+
}

0 commit comments

Comments
 (0)