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

Paolo Severini via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri May 8 01:34:27 PDT 2020


paolosev updated this revision to Diff 262824.
paolosev marked 8 inline comments as done.
paolosev edited the summary of this revision.
paolosev added a comment.

- For the DWARF expression evaluation, I am here following the suggestion of defining a Factory plugin (`DWARFEvaluatorFactory`) which is cached by Module. Is there a way to define a simple plugin function, avoiding all the overhead of a plugin class? Most of the state is in DWARFExpression, which is passed to the evaluator, so the amount of state to pass around is much smaller.

Note that WasmDWARFEvaluator::Evaluate() not only needs to handle Wasm-specific opcodes like DW_OP_WASM_location, but might also handle in a Wasm-specific way some "standard" opcodes. For example, static variables are generally encoded with `DW_OP_addr`, but for WebAssembly the corresponding offset is the offset in the module Data section, which is mapped into an area of the Memory section when the module is loaded. So, memory reads related to DW_OP_addr refer to a different space and should be dealt differently by the runtime.
This makes `target variable *global_ptr` work when we have multiple modules., because we can retrieve the module_id from the Module associated to the DWARFExpression.

- Wasm addresses may refer to different address spaces, and are internally encoded with 64 bits as:

  63 61           32            0
  +-+-------------+-------------+
  |T|  module_id  |   offset    |
  +-+-------------+-------------+

where T is 0:Code, 1:Data, 2:Memory.

- I introduced a class ThreadWasm, as suggested, which overrides the function to create the unwinder object. This required a small change also to ProcessGDBRemote, a new virtual factory method to create a thread.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78801/new/

https://reviews.llvm.org/D78801

Files:
  lldb/include/lldb/Core/Module.h
  lldb/include/lldb/Core/PluginManager.h
  lldb/include/lldb/Expression/DWARFEvaluator.h
  lldb/include/lldb/Expression/DWARFEvaluatorFactory.h
  lldb/include/lldb/Expression/DWARFExpression.h
  lldb/include/lldb/Target/Process.h
  lldb/include/lldb/lldb-forward.h
  lldb/include/lldb/lldb-private-interfaces.h
  lldb/source/Core/Module.cpp
  lldb/source/Core/PluginManager.cpp
  lldb/source/Core/Value.cpp
  lldb/source/Core/ValueObject.cpp
  lldb/source/Expression/CMakeLists.txt
  lldb/source/Expression/DWARFEvaluator.cpp
  lldb/source/Expression/DWARFEvaluatorFactory.cpp
  lldb/source/Expression/DWARFExpression.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Plugins/CMakeLists.txt
  lldb/source/Plugins/DWARFEvaluator/CMakeLists.txt
  lldb/source/Plugins/DWARFEvaluator/wasm/CMakeLists.txt
  lldb/source/Plugins/DWARFEvaluator/wasm/WasmDWARFEvaluator.cpp
  lldb/source/Plugins/DWARFEvaluator/wasm/WasmDWARFEvaluator.h
  lldb/source/Plugins/DWARFEvaluator/wasm/WasmDWARFEvaluatorFactory.cpp
  lldb/source/Plugins/DWARFEvaluator/wasm/WasmDWARFEvaluatorFactory.h
  lldb/source/Plugins/Plugins.def.in
  lldb/source/Plugins/Process/CMakeLists.txt
  lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
  lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
  lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
  lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
  lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
  lldb/source/Plugins/Process/minidump/ProcessMinidump.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/ThreadWasm.cpp
  lldb/source/Plugins/Process/wasm/ThreadWasm.h
  lldb/source/Plugins/Process/wasm/UnwindWasm.cpp
  lldb/source/Plugins/Process/wasm/UnwindWasm.h
  lldb/source/Target/Platform.cpp
  lldb/source/Target/Process.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78801.262824.patch
Type: text/x-patch
Size: 202785 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200508/8fbfe333/attachment-0001.bin>


More information about the lldb-commits mailing list