Skip to content

Commit a7a2f74

Browse files
committed
Restructure std::sys::personality
Move `dwarf` into `gcc`, since it's only needed there and will need to make GCC-specific assumptions in the next commit.
1 parent f464759 commit a7a2f74

File tree

5 files changed

+26
-6
lines changed

5 files changed

+26
-6
lines changed

library/std/src/sys/personality/gcc.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,12 @@
3737
//! and the last personality routine transfers control to the catch block.
3838
#![forbid(unsafe_op_in_unsafe_fn)]
3939

40+
mod dwarf;
41+
mod eh;
42+
4043
use unwind as uw;
4144

42-
use super::dwarf::eh::{self, EHAction, EHContext};
45+
use self::eh::{EHAction, EHContext};
4346
use crate::ffi::c_int;
4447

4548
// Register ids were lifted from LLVM's TargetLowering::getExceptionPointerRegister()

library/std/src/sys/personality/dwarf/mod.rs renamed to library/std/src/sys/personality/gcc/dwarf.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
#[cfg(test)]
1111
mod tests;
1212

13-
pub mod eh;
14-
1513
pub struct DwarfReader {
1614
pub ptr: *const u8,
1715
}
@@ -67,3 +65,24 @@ impl DwarfReader {
6765
result as i64
6866
}
6967
}
68+
69+
#[cfg(test)]
70+
mod tests {
71+
#[test]
72+
fn dwarf_reader() {
73+
let encoded: &[u8] = &[1, 2, 3, 4, 5, 6, 7, 0xE5, 0x8E, 0x26, 0x9B, 0xF1, 0x59, 0xFF, 0xFF];
74+
75+
let mut reader = DwarfReader::new(encoded.as_ptr());
76+
77+
unsafe {
78+
assert!(reader.read::<u8>() == u8::to_be(1u8));
79+
assert!(reader.read::<u16>() == u16::to_be(0x0203));
80+
assert!(reader.read::<u32>() == u32::to_be(0x04050607));
81+
82+
assert!(reader.read_uleb128() == 624485);
83+
assert!(reader.read_sleb128() == -624485);
84+
85+
assert!(reader.read::<i8>() == i8::to_be(-1));
86+
}
87+
}
88+
}

library/std/src/sys/personality/dwarf/eh.rs renamed to library/std/src/sys/personality/gcc/eh.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
use core::ptr;
1616

17-
use super::DwarfReader;
17+
use super::dwarf::DwarfReader;
1818

1919
pub const DW_EH_PE_omit: u8 = 0xFF;
2020
pub const DW_EH_PE_absptr: u8 = 0x00;

library/std/src/sys/personality/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
//! Additionally, ARM EHABI uses the personality function when generating
1111
//! backtraces.
1212
13-
mod dwarf;
14-
1513
#[cfg(not(any(test, doctest)))]
1614
cfg_select! {
1715
target_os = "emscripten" => {

0 commit comments

Comments
 (0)