Merge pull request #3443 from adv-sw/main
Fixes (indirectly) #3419 by providing debugger with ability to resolve sandbox pointers
This commit is contained in:
@@ -6,6 +6,18 @@ use wasmtime_environ::{EntityRef, MemoryIndex};
|
|||||||
|
|
||||||
static mut VMCTX_AND_MEMORY: (*mut VMContext, usize) = (std::ptr::null_mut(), 0);
|
static mut VMCTX_AND_MEMORY: (*mut VMContext, usize) = (std::ptr::null_mut(), 0);
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn resolve_vmctx_memory(ptr: usize) -> *const u8 {
|
||||||
|
let handle = InstanceHandle::from_vmctx(VMCTX_AND_MEMORY.0);
|
||||||
|
assert!(
|
||||||
|
VMCTX_AND_MEMORY.1 < handle.module().memory_plans.len(),
|
||||||
|
"memory index for debugger is out of bounds"
|
||||||
|
);
|
||||||
|
let index = MemoryIndex::new(VMCTX_AND_MEMORY.1);
|
||||||
|
let mem = handle.instance().get_memory(index);
|
||||||
|
mem.base.add(ptr)
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn resolve_vmctx_memory_ptr(p: *const u32) -> *const u8 {
|
pub unsafe extern "C" fn resolve_vmctx_memory_ptr(p: *const u32) -> *const u8 {
|
||||||
let ptr = std::ptr::read(p);
|
let ptr = std::ptr::read(p);
|
||||||
@@ -36,5 +48,6 @@ pub fn ensure_exported() {
|
|||||||
unsafe {
|
unsafe {
|
||||||
std::ptr::read_volatile(resolve_vmctx_memory_ptr as *const u8);
|
std::ptr::read_volatile(resolve_vmctx_memory_ptr as *const u8);
|
||||||
std::ptr::read_volatile(set_vmctx_memory as *const u8);
|
std::ptr::read_volatile(set_vmctx_memory as *const u8);
|
||||||
|
std::ptr::read_volatile(resolve_vmctx_memory as *const u8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user