Stream: git-wasmtime

Topic: wasmtime / issue #10674 Debugging with GDB and LLDB has w...


view this post on Zulip Wasmtime GitHub notifications bot (Apr 25 2025 at 02:54):

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

Reproduction goes as follows.

0. Requirement

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 lldb

Executing expr (void)__vmctx->set() would trigger following errors

error: Couldn't materialize: couldn't get the value of variable __vmctx: variable not available
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression

Question: How to fix this?

3. Problems of debugging with GDB

make gdb

We got following warnings

Reading symbols from wasmtime...
(No debugging symbols found in wasmtime)

Question: Does it matters?

References

view this post on Zulip Wasmtime GitHub notifications bot (Apr 25 2025 at 14:50):

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.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 25 2025 at 19:57):

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.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 25 2025 at 20:18):

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!

view this post on Zulip Wasmtime GitHub notifications bot (Apr 26 2025 at 02:03):

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

view this post on Zulip Wasmtime GitHub notifications bot (Apr 26 2025 at 02:03):

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

Reproduction goes as follows.

0. Requirement

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 lldb

Executing expr (void)__vmctx->set() would trigger following errors

error: Couldn't materialize: couldn't get the value of variable __vmctx: variable not available
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression

Question: How to fix this?

3. Problems of debugging with GDB

make gdb

We got following warnings

Reading symbols from wasmtime...
(No debugging symbols found in wasmtime)

Question: Does it matters?

References

view this post on Zulip Wasmtime GitHub notifications bot (Apr 27 2025 at 18:52):

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