Stream: git-wasmtime

Topic: wasmtime / PR #1482 Utility methods for artificial debug ...


view this post on Zulip Wasmtime GitHub notifications bot (Apr 07 2020 at 21:25):

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* and operator->.

The runtime/host has to have set_vmctx_memory and resolve_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:

view this post on Zulip Wasmtime GitHub notifications bot (Apr 07 2020 at 21:36):

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* and operator->.

The runtime/host has to have set_vmctx_memory and resolve_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:

view this post on Zulip Wasmtime GitHub notifications bot (Apr 08 2020 at 18:35):

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* and operator->.

The runtime/host has to have set_vmctx_memory and resolve_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:

view this post on Zulip Wasmtime GitHub notifications bot (Apr 08 2020 at 20:00):

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* and operator->.

The runtime/host has to have set_vmctx_memory and resolve_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:

view this post on Zulip Wasmtime GitHub notifications bot (Apr 08 2020 at 20:35):

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* and operator->.

The runtime/host has to have set_vmctx_memory and resolve_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:

view this post on Zulip Wasmtime GitHub notifications bot (Apr 08 2020 at 21:32):

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* and operator->.

The runtime/host has to have set_vmctx_memory and resolve_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:

view this post on Zulip Wasmtime GitHub notifications bot (Apr 08 2020 at 21:32):

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* and operator->.

The runtime/host has to have set_vmctx_memory and resolve_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:

view this post on Zulip Wasmtime GitHub notifications bot (Apr 08 2020 at 22:37):

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* and operator->.

The runtime/host has to have set_vmctx_memory and resolve_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:

view this post on Zulip Wasmtime GitHub notifications bot (Apr 09 2020 at 15:09):

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* and operator->.

The runtime/host has to have set_vmctx_memory and resolve_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:

view this post on Zulip Wasmtime GitHub notifications bot (Apr 09 2020 at 16:23):

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* and operator->.

The runtime/host has to have set_vmctx_memory and resolve_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:

view this post on Zulip Wasmtime GitHub notifications bot (Apr 09 2020 at 16:24):

yurydelendik requested fitzgen for a review on PR #1482.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 09 2020 at 17:37):

fitzgen submitted PR Review.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 09 2020 at 17:37):

fitzgen submitted PR Review.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 09 2020 at 17:37):

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.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 09 2020 at 17:37):

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.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 09 2020 at 17:37):

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.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 09 2020 at 18:44):

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* and operator->.

The runtime/host has to have set_vmctx_memory and resolve_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:

view this post on Zulip Wasmtime GitHub notifications bot (Apr 09 2020 at 18:49):

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* and operator->.

The runtime/host has to have set_vmctx_memory and resolve_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:

view this post on Zulip Wasmtime GitHub notifications bot (Apr 09 2020 at 18:59):

yurydelendik submitted PR Review.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 09 2020 at 18:59):

yurydelendik created PR Review Comment:

https://github.com/bytecodealliance/wasmtime/issues/1489

view this post on Zulip Wasmtime GitHub notifications bot (Apr 09 2020 at 19:00):

bjorn3 submitted PR Review.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 09 2020 at 19:00):

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.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 09 2020 at 19:58):

yurydelendik submitted PR Review.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 09 2020 at 19:58):

yurydelendik created PR Review Comment:

If you are suggesting to remove ensure_exported, then it does not work. See rust-lang/rust#25057

view this post on Zulip Wasmtime GitHub notifications bot (Apr 10 2020 at 15:13):

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* and operator->.

The runtime/host has to have set_vmctx_memory and resolve_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:

view this post on Zulip Wasmtime GitHub notifications bot (Apr 10 2020 at 16:00):

yurydelendik merged PR #1482.


Last updated: Dec 23 2024 at 13:07 UTC