[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #77949)
mh4ck-Thales wrote: Seems like support for reading Wasm local and global variables is available in your code, but I don't understand how can one effectively read these variables from the lldb command line. Maybe adding commands to access these can be useful ? https://github.com/llvm/llvm-project/pull/77949 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #77949)
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 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #77949)
mh4ck-Thales wrote: I already tried to use `register read` to access Wasm variables without success. But it was the patch available [here](https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/build-scripts/lldb_wasm.patch) is part of WAMR, maybe this patch is different and will make it work. I tried using this patch without success. It seems like compiling lldb with this patch and use it to debug Wasm with the latest version of WAMR / iwasm do not work correctly (at least for me). lldb can connect to the server embedded into iwasm but doesn't seem to be able to disassemble Wasm bytecode or set breakpoints. Just giving the info here because I'm not sure this patch is supposed to be straightaway compatible with WAMR. https://github.com/llvm/llvm-project/pull/77949 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #77949)
mh4ck-Thales wrote: > Hi @mh4ck-Thales this is caused by [#77949 > (comment)](https://github.com/llvm/llvm-project/pull/77949#discussion_r1463458728), > currently we need to modify it manually. Thanks! That did the trick for the breakpoint and disassembly problems. When using `read register` I can only see `pc` and nothing else though. I'm not sure assimilating Wasm variables to registers is the good way to go anyway, because the number of Wasm variables is not fixed in advance, and subject to the context of execution (with local variables). This is not the case at all for classic CPU registers, and I'm not sure the generic code managing registers in lldb will support that. Using a solution like @jimingham proposed with subcommands of `language wasm` may be a easier, less bug prone way to implement this. https://github.com/llvm/llvm-project/pull/77949 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #77949)
mh4ck-Thales wrote: > On the other hand, as a managed language, I think most people won't need to > read specific local/global of an instance, just like most of the JavaScript > developer won't care about the value of a register in V8 during debugging, > they just care about the value of their variables. I agree that the average developer will not have much use of the possibility of accessing Wasm locals and globals. I also understand that Wasm locals and global are a very specific, Wasm-only concept and that adding this concept in LLVM core is not pertinent. However for people working on the inner workings of Wasm (like me), it may be very useful. I'm not sure it belongs to this PR but implementing support for accessing Wasm locals/globals in the future (using perhaps a command like `language wasm`) seems an interesting thing to do to complete the debugging experience on Wasm with lldb. What I'm wondering is, does these potential added commands have an impact on this PR ? Or can we imagine commands that will send a specific, Wasm-only request to the debugging server to get the values of the variables without using the implementation of locals and globals of this PR ? https://github.com/llvm/llvm-project/pull/77949 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits