sammyne opened issue #10674:
A repository https://github.com/sammyne/debug-wasm-cc is maded to check Debugging with gdb and lldb.
I got a error and a warning
- Error:
Couldn't materialize: couldn't get the value of variable __vmctx: variable not available- Warning:
No debugging symbols found in wasmtimeReproduction goes as follows.
0. Requirement
- debian 12
- GNU gdb (Debian 13.1-3) 13.1
- lldb version 18.1.8
- wasi-sdk 22.0
- wasmtime 22.0.0
1. Project Layout
foo.cc: c++ source code
#include <cstdio> int main() { int a = 123; int b = 456; int c = a + b; printf("c = %d\n", c); return 0; }Makefile: build script
APP = foo.wasm CXX = /opt/wasi-sdk/bin/clang++ .PHONY: all all: $(APP) $(APP): foo.cc $(CXX) $< -g -o $@ # 添加 -O opt-level=0 选项会触发 '$1 = <optimized out>' 告警。 gdb: $(APP) gdb -ex 'set disable-randomization off' \ -ex 'b main' \ -ex 'r' \ -ex 'n' \ -ex 'n' \ -ex 'n' \ -ex 'p a' \ --args wasmtime run -D debug-info $< lldb: $(APP) lldb-18 -O 'settings set target.disable-aslr false' \ -o 'breakpoint set -n main' \ -o 'r' \ -o 'c' \ -o 'expr (void)__vmctx->set()' \ -- wasmtime run -D debug-info -O opt-level=0 $< .PHONY: clean clean: rm -rf $(APP)2. Problems of debugging with LLDB
make lldbExecuting
expr (void)__vmctx->set()would trigger following errorserror: Couldn't materialize: couldn't get the value of variable __vmctx: variable not available error: errored out in DoExecute, couldn't PrepareToExecuteJITExpressionQuestion: How to fix this?
3. Problems of debugging with GDB
make gdbWe got following warnings
Reading symbols from wasmtime... (No debugging symbols found in wasmtime)Question: Does it matters?
References
alexcrichton commented on issue #10674:
Wasmtime 22.0.0 is relatively old at this point and the LLDB example here works for me on Wasmtime 32 (the current version). Could you try updating Wasmtime and see if that works?
I also can't get gdb working, but I've never been able to get gdb working, so my failure to get something working I don't think means much.
SingleAccretion commented on issue #10674:
Reading symbols from wasmtime... (No debugging symbols found in wasmtime)
Does it matters?This can be safely ignored (unless you want to debug wasmtime Rust code itself, of course).
I wonder if it would be best to put a bit of emphasis in the documentation that LLDB is really the preferred debugger, since we definitively know that (a new enough) gdb doesn't work.
alexcrichton commented on issue #10674:
Oh I hadn't even realized (or more likely I forgot) that a recent gdb is known to not work. Agreed that we should mention this in the documentation!
sammyne commented on issue #10674:
Reading symbols from wasmtime... (No debugging symbols found in wasmtime)
Does it matters?This can be safely ignored (unless you want to debug wasmtime Rust code itself, of course).
I wonder if it would be best to put a bit of emphasis in the documentation that LLDB is really the preferred debugger, since we definitively know that (a new enough) gdb doesn't work.
It would be better if emphasis on preferrence of LLDB is added to doc
sammyne closed issue #10674:
A repository https://github.com/sammyne/debug-wasm-cc is maded to check Debugging with gdb and lldb.
I got a error and a warning
- Error:
Couldn't materialize: couldn't get the value of variable __vmctx: variable not available- Warning:
No debugging symbols found in wasmtimeReproduction goes as follows.
0. Requirement
- debian 12
- GNU gdb (Debian 13.1-3) 13.1
- lldb version 18.1.8
- wasi-sdk 22.0
- wasmtime 22.0.0
1. Project Layout
foo.cc: c++ source code
#include <cstdio> int main() { int a = 123; int b = 456; int c = a + b; printf("c = %d\n", c); return 0; }Makefile: build script
APP = foo.wasm CXX = /opt/wasi-sdk/bin/clang++ .PHONY: all all: $(APP) $(APP): foo.cc $(CXX) $< -g -o $@ # 添加 -O opt-level=0 选项会触发 '$1 = <optimized out>' 告警。 gdb: $(APP) gdb -ex 'set disable-randomization off' \ -ex 'b main' \ -ex 'r' \ -ex 'n' \ -ex 'n' \ -ex 'n' \ -ex 'p a' \ --args wasmtime run -D debug-info $< lldb: $(APP) lldb-18 -O 'settings set target.disable-aslr false' \ -o 'breakpoint set -n main' \ -o 'r' \ -o 'c' \ -o 'expr (void)__vmctx->set()' \ -- wasmtime run -D debug-info -O opt-level=0 $< .PHONY: clean clean: rm -rf $(APP)2. Problems of debugging with LLDB
make lldbExecuting
expr (void)__vmctx->set()would trigger following errorserror: Couldn't materialize: couldn't get the value of variable __vmctx: variable not available error: errored out in DoExecute, couldn't PrepareToExecuteJITExpressionQuestion: How to fix this?
3. Problems of debugging with GDB
make gdbWe got following warnings
Reading symbols from wasmtime... (No debugging symbols found in wasmtime)Question: Does it matters?
References
bjorn3 commented on issue #10674:
The GDB issues is https://github.com/bytecodealliance/wasmtime/issues/9731.
Last updated: Dec 06 2025 at 07:03 UTC