34 static llvm::once_flag g_once_flag;
36 llvm::call_once(g_once_flag, []() {
52 return "GDB Remote protocol based WebAssembly debugging plug-in.";
63 if (crash_file_path ==
nullptr)
64 return std::make_shared<ProcessWasm>(target_sp, listener_sp);
69 bool plugin_specified_by_name) {
70 if (plugin_specified_by_name)
73 if (
Module *exe_module = target_sp->GetExecutableModulePointer()) {
74 if (
ObjectFile *exe_objfile = exe_module->GetObjectFile())
75 return exe_objfile->GetArchitecture().GetMachine() ==
85 return std::make_shared<ThreadWasm>(*
this, tid);
100 error.FromErrorStringWithFormatv(
101 "Wasm read failed for invalid address {0:x} (type = {1:x}, module = "
102 "{2:x}, offset = {3:x})",
108llvm::Expected<std::vector<lldb::addr_t>>
111 packet.
Printf(
"qWasmCallStack:");
112 packet.
Printf(
"%" PRIx64, tid);
117 return llvm::createStringError(
"failed to send qWasmCallStack");
120 return llvm::createStringError(
"failed to get response for qWasmCallStack");
123 std::make_shared<DataBufferHeap>(response.
GetStringRef().size() / 2, 0);
124 const size_t bytes = response.
GetHexBytes(data_buffer_sp->GetData(),
'\xcc');
125 if (bytes == 0 || bytes %
sizeof(uint64_t) != 0)
126 return llvm::createStringError(
"invalid response for qWasmCallStack");
133 std::vector<lldb::addr_t> call_stack_pcs;
134 while (offset < bytes)
135 call_stack_pcs.push_back(data.
GetU64(&offset));
137 return call_stack_pcs;
140llvm::Expected<lldb::DataBufferSP>
146 packet.
Printf(
"qWasmLocal:");
149 packet.
Printf(
"qWasmGlobal:");
155 return llvm::createStringError(
"not a Wasm location");
157 packet.
Printf(
"%d;%d", frame_index, index);
162 return llvm::createStringError(
"failed to send Wasm variable");
165 return llvm::createStringError(
"failed to get response for Wasm variable");
169 response.
GetHexBytes(buffer_sp->GetData(),
'\xcc');
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_PLUGIN_DEFINE(PluginName)
A subclass of DataBuffer that stores a data buffer on the heap.
A class that describes an executable image and its associated object and symbol files.
A plug-in interface definition class for object file parsers.
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error)
Read of memory from a process.
lldb::UnixSignalsSP m_unix_signals_sp
uint32_t GetAddressByteSize() const
llvm::StringRef GetString() const
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
static lldb::UnixSignalsSP Create(const ArchSpec &arch)
GDBRemoteCommunicationClient m_gdb_comm
static void DebuggerInitialize(Debugger &debugger)
ProcessGDBRemote(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp)
ProcessWasm provides the access to the Wasm program state retrieved from the Wasm engine.
llvm::StringRef GetPluginName() override
std::shared_ptr< process_gdb_remote::ThreadGDBRemote > CreateThread(lldb::tid_t tid) override
static llvm::StringRef GetPluginNameStatic()
bool CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) override
Check if a plug-in instance can debug the file in module.
static void DebuggerInitialize(Debugger &debugger)
static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const FileSpec *crash_file_path, bool can_connect)
llvm::Expected< std::vector< lldb::addr_t > > GetWasmCallStack(lldb::tid_t tid)
Retrieve the current call stack from the WebAssembly remote process.
ProcessWasm(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp)
llvm::Expected< lldb::DataBufferSP > GetWasmVariable(WasmVirtualRegisterKinds kind, int frame_index, int index)
Query the value of a WebAssembly variable from the WebAssembly remote process.
static llvm::StringRef GetPluginDescriptionStatic()
size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error) override
Read of memory from a process.
A class that represents a running process on the host machine.
@ eWasmTagNotAWasmLocation
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::Listener > ListenerSP
std::shared_ptr< lldb_private::WritableDataBuffer > WritableDataBufferSP
std::shared_ptr< lldb_private::Target > TargetSP
For the purpose of debugging, we can represent all these separated 32-bit address spaces with a singl...
uint32_t GetModuleID() const
uint32_t GetOffset() const
WasmAddressType GetType() const