yurydelendik opened PR #1482 from unwrap-ptr
to master
:
Currently, artificial "wrapper" types are created for pointer types. These wrappers display Wasm pointers as i32. To deference such wrapper/pointer the function's vmctx is needed. This PR is an attempt to provide overrides for artificial type for
operator*
andoperator->
.The runtime/host has to have
set_vmctx_memory
andresolve_vmctx_memory_ptr
builtins. The former sets current context and the former derefernces the Wasm pointer using current context's memory base.During LLDB session, a user has to call
__vmctx.set()
to set the current context before calling any dereference operators. It can be automated via e.g.command regex pp 's/(.+)/p __vmctx->set(),%1/'
.Example of the LLDB session (see also gist):
Process 50041 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 frame #0: 0x00000001042ca05d JIT(0x105000600)`check(i=1) at t.c:13:3 10 11 int check(size_t i) { 12 struct Test *y = t + i; -> 13 y->i++; 14 return y->j; 15 } 16 (lldb) p y (WebAssemblyPtrWrapper<Test>) $0 = (__ptr = 1032) (lldb) pp *y (Test) $1 = (i = 3, j = 4) (lldb) pp y->j (int) $2 = 4 (lldb) fr v (WasmtimeVMContext *) __vmctx = 0x0000000103503ba0 (size_t) i = 1 (WebAssemblyPtrWrapper<Test>) y = (__ptr = 1032)TODO:
- [ ] access to non-exported memory
- [ ] find better way to keep
_set_vmctx_memory
/_resolve_vmctx_memory_ptr
exported
yurydelendik edited PR #1482 from unwrap-ptr
to master
:
Currently, artificial "wrapper" types are created for pointer types. These wrappers display Wasm pointers as i32. To deference such wrapper/pointer the function's vmctx is needed. This PR is an attempt to provide overrides for artificial type for
operator*
andoperator->
.The runtime/host has to have
set_vmctx_memory
andresolve_vmctx_memory_ptr
builtins. The former sets current context and the former derefernces the Wasm pointer using current context's memory base.During LLDB session, a user has to call
__vmctx.set()
to set the current context before calling any dereference operators. It can be automated via e.g.command regex pp 's/(.+)/p __vmctx->set(),%1/'
.Example of the LLDB session (see also gist):
Process 50041 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 frame #0: 0x00000001042ca05d JIT(0x105000600)`check(i=1) at t.c:13:3 10 11 int check(size_t i) { 12 struct Test *y = t + i; -> 13 y->i++; 14 return y->j; 15 } 16 (lldb) p y (WebAssemblyPtrWrapper<Test>) $0 = (__ptr = 1032) (lldb) pp *y (Test) $1 = (i = 3, j = 4) (lldb) pp y->j (int) $2 = 4 (lldb) fr v (WasmtimeVMContext *) __vmctx = 0x0000000103503ba0 (size_t) i = 1 (WebAssemblyPtrWrapper<Test>) y = (__ptr = 1032)TODO:
- [ ] access to non-exported memory
- [ ] find better way to keep
_set_vmctx_memory
/_resolve_vmctx_memory_ptr
exported (https://github.com/rust-lang/rust/issues/25057 ?)
yurydelendik edited PR #1482 from unwrap-ptr
to master
:
Currently, artificial "wrapper" types are created for pointer types. These wrappers display Wasm pointers as i32. To dereference such wrapper/pointer the function's vmctx is needed. This PR is an attempt to provide overrides for artificial type for
operator*
andoperator->
.The runtime/host has to have
set_vmctx_memory
andresolve_vmctx_memory_ptr
builtins. The former sets current context and the former derefernces the Wasm pointer using current context's memory base.During LLDB session, a user has to call
__vmctx.set()
to set the current context before calling any dereference operators. It can be automated via e.g.command regex pp 's/(.+)/p __vmctx->set(),%1/'
.Example of the LLDB session (see also gist):
Process 50041 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 frame #0: 0x00000001042ca05d JIT(0x105000600)`check(i=1) at t.c:13:3 10 11 int check(size_t i) { 12 struct Test *y = t + i; -> 13 y->i++; 14 return y->j; 15 } 16 (lldb) p y (WebAssemblyPtrWrapper<Test>) $0 = (__ptr = 1032) (lldb) pp *y (Test) $1 = (i = 3, j = 4) (lldb) pp y->j (int) $2 = 4 (lldb) fr v (WasmtimeVMContext *) __vmctx = 0x0000000103503ba0 (size_t) i = 1 (WebAssemblyPtrWrapper<Test>) y = (__ptr = 1032)TODO:
- [ ] access to non-exported memory
- [ ] find better way to keep
_set_vmctx_memory
/_resolve_vmctx_memory_ptr
exported (https://github.com/rust-lang/rust/issues/25057 ?)
yurydelendik edited PR #1482 from unwrap-ptr
to master
:
Currently, artificial "wrapper" types are created for pointer types. These wrappers display Wasm pointers as i32. To dereference such wrapper/pointer the function's vmctx is needed. This PR is an attempt to provide overrides for artificial type for
operator*
andoperator->
.The runtime/host has to have
set_vmctx_memory
andresolve_vmctx_memory_ptr
builtins. The former sets current context and the former derefernces the Wasm pointer using current context's memory base.During LLDB session, a user has to call
__vmctx.set()
to set the current context before calling any dereference operators. It can be automated via e.g.command regex pp 's/(.+)/p __vmctx->set(),%1/'
.Example of the LLDB session (see also gist):
Process 50041 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 frame #0: 0x00000001042ca05d JIT(0x105000600)`check(i=1) at t.c:13:3 10 11 int check(size_t i) { 12 struct Test *y = t + i; -> 13 y->i++; 14 return y->j; 15 } 16 (lldb) p y (WebAssemblyPtrWrapper<Test>) $0 = (__ptr = 1032) (lldb) pp *y (Test) $1 = (i = 3, j = 4) (lldb) pp y->j (int) $2 = 4 (lldb) fr v (WasmtimeVMContext *) __vmctx = 0x0000000103503ba0 (size_t) i = 1 (WebAssemblyPtrWrapper<Test>) y = (__ptr = 1032)TODO:
- [ ] access to non-exported memory
- [x] find better way to keep
_set_vmctx_memory
/_resolve_vmctx_memory_ptr
exported (https://github.com/rust-lang/rust/issues/25057 ?)
yurydelendik updated PR #1482 from unwrap-ptr
to master
:
Currently, artificial "wrapper" types are created for pointer types. These wrappers display Wasm pointers as i32. To dereference such wrapper/pointer the function's vmctx is needed. This PR is an attempt to provide overrides for artificial type for
operator*
andoperator->
.The runtime/host has to have
set_vmctx_memory
andresolve_vmctx_memory_ptr
builtins. The former sets current context and the former derefernces the Wasm pointer using current context's memory base.During LLDB session, a user has to call
__vmctx.set()
to set the current context before calling any dereference operators. It can be automated via e.g.command regex pp 's/(.+)/p __vmctx->set(),%1/'
.Example of the LLDB session (see also gist):
Process 50041 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 frame #0: 0x00000001042ca05d JIT(0x105000600)`check(i=1) at t.c:13:3 10 11 int check(size_t i) { 12 struct Test *y = t + i; -> 13 y->i++; 14 return y->j; 15 } 16 (lldb) p y (WebAssemblyPtrWrapper<Test>) $0 = (__ptr = 1032) (lldb) pp *y (Test) $1 = (i = 3, j = 4) (lldb) pp y->j (int) $2 = 4 (lldb) fr v (WasmtimeVMContext *) __vmctx = 0x0000000103503ba0 (size_t) i = 1 (WebAssemblyPtrWrapper<Test>) y = (__ptr = 1032)TODO:
- [ ] access to non-exported memory
- [x] find better way to keep
_set_vmctx_memory
/_resolve_vmctx_memory_ptr
exported (https://github.com/rust-lang/rust/issues/25057 ?)
yurydelendik updated PR #1482 from unwrap-ptr
to master
:
Currently, artificial "wrapper" types are created for pointer types. These wrappers display Wasm pointers as i32. To dereference such wrapper/pointer the function's vmctx is needed. This PR is an attempt to provide overrides for artificial type for
operator*
andoperator->
.The runtime/host has to have
set_vmctx_memory
andresolve_vmctx_memory_ptr
builtins. The former sets current context and the former derefernces the Wasm pointer using current context's memory base.During LLDB session, a user has to call
__vmctx.set()
to set the current context before calling any dereference operators. It can be automated via e.g.command regex pp 's/(.+)/p __vmctx->set(),%1/'
.Example of the LLDB session (see also gist):
Process 50041 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 frame #0: 0x00000001042ca05d JIT(0x105000600)`check(i=1) at t.c:13:3 10 11 int check(size_t i) { 12 struct Test *y = t + i; -> 13 y->i++; 14 return y->j; 15 } 16 (lldb) p y (WebAssemblyPtrWrapper<Test>) $0 = (__ptr = 1032) (lldb) pp *y (Test) $1 = (i = 3, j = 4) (lldb) pp y->j (int) $2 = 4 (lldb) fr v (WasmtimeVMContext *) __vmctx = 0x0000000103503ba0 (size_t) i = 1 (WebAssemblyPtrWrapper<Test>) y = (__ptr = 1032)TODO:
- [ ] access to non-exported memory
- [x] find better way to keep
_set_vmctx_memory
/_resolve_vmctx_memory_ptr
exported (https://github.com/rust-lang/rust/issues/25057 ?)
yurydelendik edited PR #1482 from unwrap-ptr
to master
:
Currently, artificial "wrapper" types are created for pointer types. These wrappers display Wasm pointers as i32. To dereference such wrapper/pointer the function's vmctx is needed. This PR is an attempt to provide overrides for artificial type for
operator*
andoperator->
.The runtime/host has to have
set_vmctx_memory
andresolve_vmctx_memory_ptr
builtins. The former sets current context and the former derefernces the Wasm pointer using current context's memory base.During LLDB session, a user has to call
__vmctx.set()
to set the current context before calling any dereference operators. It can be automated via e.g.command regex pp 's/(.+)/p __vmctx->set(),%1/'
.Example of the LLDB session (see also gist):
Process 50041 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 frame #0: 0x00000001042ca05d JIT(0x105000600)`check(i=1) at t.c:13:3 10 11 int check(size_t i) { 12 struct Test *y = t + i; -> 13 y->i++; 14 return y->j; 15 } 16 (lldb) p y (WebAssemblyPtrWrapper<Test>) $0 = (__ptr = 1032) (lldb) pp *y (Test) $1 = (i = 3, j = 4) (lldb) pp y->j (int) $2 = 4 (lldb) fr v (WasmtimeVMContext *) __vmctx = 0x0000000103503ba0 (size_t) i = 1 (WebAssemblyPtrWrapper<Test>) y = (__ptr = 1032)TODO:
- [x] access to non-exported memory
- [x] find better way to keep
_set_vmctx_memory
/_resolve_vmctx_memory_ptr
exported (https://github.com/rust-lang/rust/issues/25057 ?)
yurydelendik updated PR #1482 from unwrap-ptr
to master
:
Currently, artificial "wrapper" types are created for pointer types. These wrappers display Wasm pointers as i32. To dereference such wrapper/pointer the function's vmctx is needed. This PR is an attempt to provide overrides for artificial type for
operator*
andoperator->
.The runtime/host has to have
set_vmctx_memory
andresolve_vmctx_memory_ptr
builtins. The former sets current context and the former derefernces the Wasm pointer using current context's memory base.During LLDB session, a user has to call
__vmctx.set()
to set the current context before calling any dereference operators. It can be automated via e.g.command regex pp 's/(.+)/p __vmctx->set(),%1/'
.Example of the LLDB session (see also gist):
Process 50041 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 frame #0: 0x00000001042ca05d JIT(0x105000600)`check(i=1) at t.c:13:3 10 11 int check(size_t i) { 12 struct Test *y = t + i; -> 13 y->i++; 14 return y->j; 15 } 16 (lldb) p y (WebAssemblyPtrWrapper<Test>) $0 = (__ptr = 1032) (lldb) pp *y (Test) $1 = (i = 3, j = 4) (lldb) pp y->j (int) $2 = 4 (lldb) fr v (WasmtimeVMContext *) __vmctx = 0x0000000103503ba0 (size_t) i = 1 (WebAssemblyPtrWrapper<Test>) y = (__ptr = 1032)TODO:
- [x] access to non-exported memory
- [x] find better way to keep
_set_vmctx_memory
/_resolve_vmctx_memory_ptr
exported (https://github.com/rust-lang/rust/issues/25057 ?)
yurydelendik updated PR #1482 from unwrap-ptr
to master
:
Currently, artificial "wrapper" types are created for pointer types. These wrappers display Wasm pointers as i32. To dereference such wrapper/pointer the function's vmctx is needed. This PR is an attempt to provide overrides for artificial type for
operator*
andoperator->
.The runtime/host has to have
set_vmctx_memory
andresolve_vmctx_memory_ptr
builtins. The former sets current context and the former derefernces the Wasm pointer using current context's memory base.During LLDB session, a user has to call
__vmctx.set()
to set the current context before calling any dereference operators. It can be automated via e.g.command regex pp 's/(.+)/p __vmctx->set(),%1/'
.Example of the LLDB session (see also gist):
Process 50041 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 frame #0: 0x00000001042ca05d JIT(0x105000600)`check(i=1) at t.c:13:3 10 11 int check(size_t i) { 12 struct Test *y = t + i; -> 13 y->i++; 14 return y->j; 15 } 16 (lldb) p y (WebAssemblyPtrWrapper<Test>) $0 = (__ptr = 1032) (lldb) pp *y (Test) $1 = (i = 3, j = 4) (lldb) pp y->j (int) $2 = 4 (lldb) fr v (WasmtimeVMContext *) __vmctx = 0x0000000103503ba0 (size_t) i = 1 (WebAssemblyPtrWrapper<Test>) y = (__ptr = 1032)TODO:
- [x] access to non-exported memory
- [x] find better way to keep
_set_vmctx_memory
/_resolve_vmctx_memory_ptr
exported (https://github.com/rust-lang/rust/issues/25057 ?)
yurydelendik updated PR #1482 from unwrap-ptr
to master
:
Currently, artificial "wrapper" types are created for pointer types. These wrappers display Wasm pointers as i32. To dereference such wrapper/pointer the function's vmctx is needed. This PR is an attempt to provide overrides for artificial type for
operator*
andoperator->
.The runtime/host has to have
set_vmctx_memory
andresolve_vmctx_memory_ptr
builtins. The former sets current context and the former derefernces the Wasm pointer using current context's memory base.During LLDB session, a user has to call
__vmctx.set()
to set the current context before calling any dereference operators. It can be automated via e.g.command regex pp 's/(.+)/p __vmctx->set(),%1/'
.Example of the LLDB session (see also gist):
Process 50041 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 frame #0: 0x00000001042ca05d JIT(0x105000600)`check(i=1) at t.c:13:3 10 11 int check(size_t i) { 12 struct Test *y = t + i; -> 13 y->i++; 14 return y->j; 15 } 16 (lldb) p y (WebAssemblyPtrWrapper<Test>) $0 = (__ptr = 1032) (lldb) pp *y (Test) $1 = (i = 3, j = 4) (lldb) pp y->j (int) $2 = 4 (lldb) fr v (WasmtimeVMContext *) __vmctx = 0x0000000103503ba0 (size_t) i = 1 (WebAssemblyPtrWrapper<Test>) y = (__ptr = 1032)TODO:
- [x] access to non-exported memory
- [x] find better way to keep
_set_vmctx_memory
/_resolve_vmctx_memory_ptr
exported (https://github.com/rust-lang/rust/issues/25057 ?)
yurydelendik requested fitzgen for a review on PR #1482.
fitzgen submitted PR Review.
fitzgen submitted PR Review.
fitzgen created PR Review Comment:
Want to create a tracking issue for multi-memory and add a checkbox for this there? That way we're less likely to forget about this when we actually implement multi-memory.
fitzgen created PR Review Comment:
If this module is
pub
(can also be#[doc(hidden)]
to avoid "really" making it public) then I _think_ we don't need this hack.
fitzgen created PR Review Comment:
assert!(!VMCTX_AND_MEMORY.0.is_null(), "must call `__vmctx->set()` before resolving Wasm pointers");So that users get a slightly better message if they get here.
yurydelendik updated PR #1482 from unwrap-ptr
to master
:
Currently, artificial "wrapper" types are created for pointer types. These wrappers display Wasm pointers as i32. To dereference such wrapper/pointer the function's vmctx is needed. This PR is an attempt to provide overrides for artificial type for
operator*
andoperator->
.The runtime/host has to have
set_vmctx_memory
andresolve_vmctx_memory_ptr
builtins. The former sets current context and the former derefernces the Wasm pointer using current context's memory base.During LLDB session, a user has to call
__vmctx.set()
to set the current context before calling any dereference operators. It can be automated via e.g.command regex pp 's/(.+)/p __vmctx->set(),%1/'
.Example of the LLDB session (see also gist):
Process 50041 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 frame #0: 0x00000001042ca05d JIT(0x105000600)`check(i=1) at t.c:13:3 10 11 int check(size_t i) { 12 struct Test *y = t + i; -> 13 y->i++; 14 return y->j; 15 } 16 (lldb) p y (WebAssemblyPtrWrapper<Test>) $0 = (__ptr = 1032) (lldb) pp *y (Test) $1 = (i = 3, j = 4) (lldb) pp y->j (int) $2 = 4 (lldb) fr v (WasmtimeVMContext *) __vmctx = 0x0000000103503ba0 (size_t) i = 1 (WebAssemblyPtrWrapper<Test>) y = (__ptr = 1032)TODO:
- [x] access to non-exported memory
- [x] find better way to keep
_set_vmctx_memory
/_resolve_vmctx_memory_ptr
exported (https://github.com/rust-lang/rust/issues/25057 ?)
yurydelendik updated PR #1482 from unwrap-ptr
to master
:
Currently, artificial "wrapper" types are created for pointer types. These wrappers display Wasm pointers as i32. To dereference such wrapper/pointer the function's vmctx is needed. This PR is an attempt to provide overrides for artificial type for
operator*
andoperator->
.The runtime/host has to have
set_vmctx_memory
andresolve_vmctx_memory_ptr
builtins. The former sets current context and the former derefernces the Wasm pointer using current context's memory base.During LLDB session, a user has to call
__vmctx.set()
to set the current context before calling any dereference operators. It can be automated via e.g.command regex pp 's/(.+)/p __vmctx->set(),%1/'
.Example of the LLDB session (see also gist):
Process 50041 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 frame #0: 0x00000001042ca05d JIT(0x105000600)`check(i=1) at t.c:13:3 10 11 int check(size_t i) { 12 struct Test *y = t + i; -> 13 y->i++; 14 return y->j; 15 } 16 (lldb) p y (WebAssemblyPtrWrapper<Test>) $0 = (__ptr = 1032) (lldb) pp *y (Test) $1 = (i = 3, j = 4) (lldb) pp y->j (int) $2 = 4 (lldb) fr v (WasmtimeVMContext *) __vmctx = 0x0000000103503ba0 (size_t) i = 1 (WebAssemblyPtrWrapper<Test>) y = (__ptr = 1032)TODO:
- [x] access to non-exported memory
- [x] find better way to keep
_set_vmctx_memory
/_resolve_vmctx_memory_ptr
exported (https://github.com/rust-lang/rust/issues/25057 ?)
yurydelendik submitted PR Review.
yurydelendik created PR Review Comment:
bjorn3 submitted PR Review.
bjorn3 created PR Review Comment:
Or use
#[doc(hidden)] pub use crate::debug_builtins::{set_vmctx_memory, resolve_vmctx_memory_ptr};
in the crate root.
yurydelendik submitted PR Review.
yurydelendik created PR Review Comment:
If you are suggesting to remove
ensure_exported
, then it does not work. See rust-lang/rust#25057
yurydelendik updated PR #1482 from unwrap-ptr
to master
:
Currently, artificial "wrapper" types are created for pointer types. These wrappers display Wasm pointers as i32. To dereference such wrapper/pointer the function's vmctx is needed. This PR is an attempt to provide overrides for artificial type for
operator*
andoperator->
.The runtime/host has to have
set_vmctx_memory
andresolve_vmctx_memory_ptr
builtins. The former sets current context and the former derefernces the Wasm pointer using current context's memory base.During LLDB session, a user has to call
__vmctx.set()
to set the current context before calling any dereference operators. It can be automated via e.g.command regex pp 's/(.+)/p __vmctx->set(),%1/'
.Example of the LLDB session (see also gist):
Process 50041 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 frame #0: 0x00000001042ca05d JIT(0x105000600)`check(i=1) at t.c:13:3 10 11 int check(size_t i) { 12 struct Test *y = t + i; -> 13 y->i++; 14 return y->j; 15 } 16 (lldb) p y (WebAssemblyPtrWrapper<Test>) $0 = (__ptr = 1032) (lldb) pp *y (Test) $1 = (i = 3, j = 4) (lldb) pp y->j (int) $2 = 4 (lldb) fr v (WasmtimeVMContext *) __vmctx = 0x0000000103503ba0 (size_t) i = 1 (WebAssemblyPtrWrapper<Test>) y = (__ptr = 1032)TODO:
- [x] access to non-exported memory
- [x] find better way to keep
_set_vmctx_memory
/_resolve_vmctx_memory_ptr
exported (https://github.com/rust-lang/rust/issues/25057 ?)
yurydelendik merged PR #1482.
Last updated: Nov 22 2024 at 17:03 UTC