[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #77949)

Quentin Michaud via lldb-commits lldb-commits at lists.llvm.org
Tue Jan 23 05:51:43 PST 2024


mh4ck-Thales wrote:

@jimingham sorry if I wasn't clear. `frame var` and `target var` are commands for viewing *language* local and global variables (be it C or another one). They are indeed working with this patch. These commands are using the Wasm linear memory, where most of the data about the program is stored, and is similar to classical binaries memory. This linear memory can be accessed using Wasm [memory instructions](https://webassembly.github.io/spec/core/syntax/instructions.html#memory-instructions).

However for the sake of debugging Wasm, I am interested in accessing *Wasm* local and global variables (these are the variables I meant to address in my first comment). These variables are used, for example, to manage the stack pointer. They are accessed using the Wasm [variable instructions](https://webassembly.github.io/spec/core/syntax/instructions.html#variable-instructions).

The current patch allows us to inspect the Wasm linear memory as one would inspect memory in a classic binary. Likewise, the Wasm *code memory* (containing the actual Wasm bytecode, which in Wasm is separated from the linear memory) is accessible with this patch with an offset of $2^{62}$. I guess this is a workaround that may be explained in [this comment](https://github.com/llvm/llvm-project/pull/77949/files#diff-ab1275eefb2cafbfa3bb7a9093caf11615867bd7ff76db85949db6811b616f3cR18). However, I'm not sure this patch provides an access to Wasm local and global variables. I thought it was implemented as I saw mentions of `WasmLocal` and `WasmGlobal`, but I may have mixed up with language variables.

If Wasm variables support is indeed implemented in this patch as I first thought, I'm not able to see which lldb command would allow to see them. If not, I think it would be a nice addition to this patch (or another patch in the future) to allow one to debug Wasm instructions and variables directly. A way I can see to implement that would be to use the same workaround used to display the code memory with an offset, and utility commands allowing to easily access variables from this offset (something like `wasm local 0` to dump the value of local variable n°0).

https://github.com/llvm/llvm-project/pull/77949


More information about the lldb-commits mailing list