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

via lldb-commits lldb-commits at lists.llvm.org
Tue Jan 23 12:19:34 PST 2024


jimingham wrote:

I see, thanks for the clarification.

In the patch, the WasmLocal and WasmGlobal calls are done in ReadRegister, so it seems like those are being presented as register values?  `register read` should show them.

BTW, we shouldn't make a top level `wasm` command, we really try hard not to occupy more of the "easy to type" parts of the lldb command set than we can help, so there is lots left free for users to customize.  There's a `language cplusplus` command (and on the swift fork `language swift`, so it would make sense to have wasm commands be vended as `language wasm`.  Then people who do a lot of WebAssembly debugging can make an alias to wasm if that helps.

Jim  


> On Jan 23, 2024, at 5:51 AM, Quentin Michaud ***@***.***> wrote:
> 
> 
> @jimingham <https://github.com/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).
> 
>> Reply to this email directly, view it on GitHub <https://github.com/llvm/llvm-project/pull/77949#issuecomment-1906103928>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ADUPVW2HLQMCXODX2S7W3H3YP657NAVCNFSM6AAAAABBYOS6L2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBWGEYDGOJSHA>.
> You are receiving this because you were mentioned.
> 



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


More information about the lldb-commits mailing list