[Lldb-commits] [PATCH] D78801: [LLDB] Add class ProcessWasm for WebAssembly debugging

Paolo Severini via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Apr 24 02:06:35 PDT 2020


paolosev created this revision.
paolosev added reviewers: clayborg, labath.
paolosev added a project: LLDB.
Herald added subscribers: lldb-commits, sunfish, aheejin, jgravelle-google, sbc100, aprantl, mgorny.
paolosev marked 2 inline comments as done.
paolosev added a comment.

What is the best way to test classes WasmProcessGDBRemote and UnwindWasm?



================
Comment at: lldb/source/Plugins/Process/wasm/ProcessWasm.cpp:92
+                                        size_t buffer_size, size_t &size) {
+  // TODO(paolosev): Implement in GDBRemoteComunicationClient
+  return false;
----------------
This will be implemented as:
```
  return GetGDBRemote().GetWasmLocal(frame_index, index, buf, buffer_size, size);
```
as soon as `GetWasmLocal` can be added to GDBRemoteCommunicationClient.


================
Comment at: lldb/source/Plugins/Process/wasm/UnwindWasm.cpp:34-35
+
+    IWasmProcess *wasm_process =
+        static_cast<WasmProcessGDBRemote *>(GetThread().GetProcess().get());
+    if (wasm_process)
----------------
This cast works but it is ugly. Is there a better coding pattern I could use here?


This is the fourth in a series of patches to enable LLDB debugging of WebAssembly code that runs in a WebAssembly engine. Previous patches added ObjectFile, SymbolVendor and DynamicLoader plugin classes for Wasm, see:  D71575 <https://reviews.llvm.org/D71575>, D72751 <https://reviews.llvm.org/D72751>, D72650 <https://reviews.llvm.org/D72650>.

The idea is to use the GDB-remote protocol to connect to a Wasm engine that implements a GDB-remote stub that offers the ability to access the engine runtime internal state. This patch introduce a new Process plugin //wasm//, with:

- class `IWasmProcess` that defines the interface with functions to access the Wasm engine state.
- class `WasmProcessGDBRemote` that inherits from `ProcessGDBRemote` and that will implement `IWasmProcess` by forwarding requests to the Wasm engine through a GDBRemote connection.
- class `UnwindWasm` that manages stack unwinding for Wasm.

Note that the GDB-remote protocol needs to be extended with a few Wasm-specific custom query commands, used to access Wasm-specific constructs like the Wasm memory, Wasm locals and globals. A patch for this with changes to `GDBRemoteCommunicationClient` will be proposed separately, like also a patch to `DWARFExpression` to handle Wasm-specific DWARF location expression operators, like `DW_OP_WASM_location`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78801

Files:
  lldb/source/Plugins/CMakeLists.txt
  lldb/source/Plugins/Plugins.def.in
  lldb/source/Plugins/Process/CMakeLists.txt
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
  lldb/source/Plugins/Process/wasm/CMakeLists.txt
  lldb/source/Plugins/Process/wasm/ProcessWasm.cpp
  lldb/source/Plugins/Process/wasm/ProcessWasm.h
  lldb/source/Plugins/Process/wasm/UnwindWasm.cpp
  lldb/source/Plugins/Process/wasm/UnwindWasm.h
  lldb/source/Target/Thread.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78801.259830.patch
Type: text/x-patch
Size: 15371 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200424/2b7e3cbc/attachment-0001.bin>


More information about the lldb-commits mailing list