LLDB mainline
ProcessWasm.h
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLDB_SOURCE_PLUGINS_PROCESS_WASM_PROCESSWASM_H
10#define LLDB_SOURCE_PLUGINS_PROCESS_WASM_PROCESSWASM_H
11
15
16namespace lldb_private {
17namespace wasm {
18
19/// ProcessWasm provides the access to the Wasm program state
20/// retrieved from the Wasm engine.
22public:
23 ProcessWasm(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp);
24 ~ProcessWasm() override = default;
25
27 lldb::ListenerSP listener_sp,
28 const FileSpec *crash_file_path,
29 bool can_connect);
30
31 static void Initialize();
32 static void DebuggerInitialize(Debugger &debugger);
33 static void Terminate();
34
35 static llvm::StringRef GetPluginNameStatic();
36 static llvm::StringRef GetPluginDescriptionStatic();
37
38 llvm::StringRef GetPluginName() override;
39
40 size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
41 Status &error) override;
42
43 bool CanDebug(lldb::TargetSP target_sp,
44 bool plugin_specified_by_name) override;
45
46 /// Retrieve the current call stack from the WebAssembly remote process.
47 llvm::Expected<std::vector<lldb::addr_t>> GetWasmCallStack(lldb::tid_t tid);
48
49 /// Query the value of a WebAssembly variable from the WebAssembly
50 /// remote process.
51 llvm::Expected<lldb::DataBufferSP>
52 GetWasmVariable(WasmVirtualRegisterKinds kind, int frame_index, int index);
53
54protected:
55 std::shared_ptr<process_gdb_remote::ThreadGDBRemote>
56 CreateThread(lldb::tid_t tid) override;
57
58private:
59 friend class UnwindWasm;
60 friend class ThreadWasm;
61
62 /// Read a WebAssembly global by its index in the global index space of the
63 /// module it belongs to. The index space is per module, so an index only
64 /// names a global together with the module it is an index into.
65 size_t ReadGlobal(uint32_t module_id, uint32_t index, void *buf, size_t size,
66 Status &error);
67
69
71 const ProcessWasm &operator=(const ProcessWasm &) = delete;
72};
73
74} // namespace wasm
75} // namespace lldb_private
76
77#endif
static llvm::raw_ostream & error(Stream &strm)
A file utility class.
Definition FileSpec.h:57
friend class Debugger
Definition Process.h:361
An error handling class.
Definition Status.h:118
lldb::DynamicRegisterInfoSP & GetRegisterInfo()
Definition ProcessWasm.h:68
size_t ReadGlobal(uint32_t module_id, uint32_t index, void *buf, size_t size, Status &error)
Read a WebAssembly global by its index in the global index space of the module it belongs to.
const ProcessWasm & operator=(const ProcessWasm &)=delete
llvm::StringRef GetPluginName() override
std::shared_ptr< process_gdb_remote::ThreadGDBRemote > CreateThread(lldb::tid_t tid) override
ProcessWasm(const ProcessWasm &)
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() override=default
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.
std::shared_ptr< lldb_private::DynamicRegisterInfo > DynamicRegisterInfoSP
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::Listener > ListenerSP
uint64_t addr_t
Definition lldb-types.h:80
std::shared_ptr< lldb_private::Target > TargetSP
uint64_t tid_t
Definition lldb-types.h:84