mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-13 06:15:33 +00:00
Fix trap handler in WSL environment.
This commit is contained in:
parent
8a471cc235
commit
263afa8a80
@ -304,8 +304,9 @@ pub struct FaultInfo {
|
|||||||
#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
|
#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
|
||||||
pub unsafe fn get_fault_info(siginfo: *const c_void, ucontext: *const c_void) -> FaultInfo {
|
pub unsafe fn get_fault_info(siginfo: *const c_void, ucontext: *const c_void) -> FaultInfo {
|
||||||
use libc::{
|
use libc::{
|
||||||
_libc_xmmreg, ucontext_t, REG_R10, REG_R11, REG_R12, REG_R13, REG_R14, REG_R15, REG_R8,
|
_libc_fpstate, _libc_xmmreg, mcontext_t, ucontext_t, REG_R10, REG_R11, REG_R12, REG_R13,
|
||||||
REG_R9, REG_RAX, REG_RBP, REG_RBX, REG_RCX, REG_RDI, REG_RDX, REG_RIP, REG_RSI, REG_RSP,
|
REG_R14, REG_R15, REG_R8, REG_R9, REG_RAX, REG_RBP, REG_RBX, REG_RCX, REG_RDI, REG_RDX,
|
||||||
|
REG_RIP, REG_RSI, REG_RSP,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn read_xmm(reg: &_libc_xmmreg) -> u64 {
|
fn read_xmm(reg: &_libc_xmmreg) -> u64 {
|
||||||
@ -327,7 +328,16 @@ pub unsafe fn get_fault_info(siginfo: *const c_void, ucontext: *const c_void) ->
|
|||||||
|
|
||||||
let ucontext = ucontext as *const ucontext_t;
|
let ucontext = ucontext as *const ucontext_t;
|
||||||
let gregs = &(*ucontext).uc_mcontext.gregs;
|
let gregs = &(*ucontext).uc_mcontext.gregs;
|
||||||
let fpregs = &*(*ucontext).uc_mcontext.fpregs;
|
|
||||||
|
// WSL bug: (*ucontext).uc_mcontext.fpregs is always null.
|
||||||
|
let fpregs: &_libc_fpstate =
|
||||||
|
&*(((&(*ucontext).uc_mcontext) as *const mcontext_t).offset(1) as *const _libc_fpstate);
|
||||||
|
if !(*ucontext).uc_mcontext.fpregs.is_null() {
|
||||||
|
assert_eq!(
|
||||||
|
(*ucontext).uc_mcontext.fpregs as *const _,
|
||||||
|
fpregs as *const _
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let mut known_registers: [Option<u64>; 24] = [None; 24];
|
let mut known_registers: [Option<u64>; 24] = [None; 24];
|
||||||
known_registers[X64Register::GPR(GPR::R15).to_index().0] = Some(gregs[REG_R15 as usize] as _);
|
known_registers[X64Register::GPR(GPR::R15).to_index().0] = Some(gregs[REG_R15 as usize] as _);
|
||||||
|
Loading…
Reference in New Issue
Block a user