21#include "llvm/ADT/StringExtras.h"
29#define LLDB_PROPERTIES_platformwasm
30#include "PlatformWasmProperties.inc"
33#define LLDB_PROPERTIES_platformwasm
34#include "PlatformWasmPropertiesEnum.inc"
40 m_collection_sp = std::make_shared<OptionValueProperties>(
42 m_collection_sp->Initialize(g_platformwasm_properties);
45 FileSpec GetRuntimePath()
const {
46 return GetPropertyAtIndexAs<FileSpec>(ePropertyRuntimePath, {});
49 Args GetRuntimeArgs()
const {
51 m_collection_sp->GetPropertyAtIndexAsArgs(ePropertyRuntimeArgs, result);
55 llvm::StringRef GetPortArg()
const {
56 return GetPropertyAtIndexAs<llvm::StringRef>(ePropertyPortArg, {});
63 static PluginProperties g_settings;
68 return "Platform for debugging Wasm";
86 "Properties for the wasm platform plugin.",
93 LLDB_LOG(log,
"force = {0}, arch = ({1}, {2})", force,
95 arch ? arch->
GetTriple().getTriple() :
"<null>");
98 if (!create && arch && arch->
IsValid()) {
99 const llvm::Triple &triple = arch->
GetTriple();
100 switch (triple.getArch()) {
101 case llvm::Triple::wasm32:
102 case llvm::Triple::wasm64:
110 LLDB_LOG(log,
"create = {0}", create);
116 return {
ArchSpec(
"wasm32-unknown-unknown-wasm"),
117 ArchSpec(
"wasm64-unknown-unknown-wasm")};
132 FileSpec runtime = properties.GetRuntimePath();
137 "WebAssembly runtime does not exist: {0}", runtime.
GetPath());
155 llvm::formatv(
"{0}{1}", properties.GetPortArg(), port).str()});
163 auto exit_code = std::make_shared<std::optional<int>>();
168 "WebAssembly runtime exited: pid = {0}, signal = {1}, status = {2}",
169 pid, signal, status);
170 exit_code->emplace(status);
176 LLDB_LOG_ERROR(log, std::move(Err),
"SetUpPtyRedirection failed: {0}");
193 error = process_sp->ConnectRemote(
194 llvm::formatv(
"connect://localhost:{0}", port).str());
200 llvm::createStringError(llvm::formatv(
201 "WebAssembly runtime exited with exit code {0}", **exit_code)),
209 process_sp->SetSTDIOFileDescriptor(
static llvm::raw_ostream & error(Stream &strm)
static DynamicLoaderDarwinKernelProperties & GetGlobalProperties()
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOG_ERROR(log, error,...)
#define LLDB_PLUGIN_DEFINE(PluginName)
An architecture specification class.
bool IsValid() const
Tests if this ArchSpec is valid.
llvm::Triple & GetTriple()
Architecture triple accessor.
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
A command line argument class.
llvm::ArrayRef< const char * > GetArgumentArrayRef() const
Gets the argument as an ArrayRef.
void AppendArguments(const Args &rhs)
A class to manage flag bits.
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
bool ResolveExecutableLocation(FileSpec &file_spec)
Call into the Host to see if it can help find the file.
static FileSystem & Instance()
ValueType Clear(ValueType mask=~static_cast< ValueType >(0))
Clear one or more flags.
static Status LaunchProcess(ProcessLaunchInfo &launch_info)
Launch the process specified in launch_info.
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static lldb::OptionValuePropertiesSP GetSettingForPlatformPlugin(Debugger &debugger, llvm::StringRef setting_name)
static bool CreateSettingForPlatformPlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static bool UnregisterPlugin(ABICreateInstance create_callback)
lldb::ListenerSP GetHijackListener() const
void SetArguments(const Args &args, bool first_arg_is_executable)
lldb::ListenerSP GetListener() const
llvm::Error SetUpPtyRedirection()
PseudoTerminal & GetPTY()
void SetMonitorProcessCallback(Host::MonitorChildProcessCallback callback)
void SetLaunchInSeparateProcessGroup(bool separate)
@ invalid_fd
Invalid file descriptor value.
int GetPrimaryFileDescriptor() const
The primary file descriptor accessor.
int ReleasePrimaryFileDescriptor()
Release the primary file descriptor.
static Status FromErrorString(const char *str)
static Status static Status FromErrorStringWithFormatv(const char *format, Args &&...args)
static Status FromError(llvm::Error error)
Avoid using this in new code. Migrate APIs to llvm::Expected instead.
Status Listen(llvm::StringRef name, int backlog) override
uint16_t GetLocalPortNumber() const
const lldb::ProcessSP & CreateProcess(lldb::ListenerSP listener_sp, llvm::StringRef plugin_name, const FileSpec *crash_file, bool can_connect)
static llvm::StringRef GetPluginNameStatic()
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
std::shared_ptr< lldb_private::Platform > PlatformSP
std::shared_ptr< lldb_private::Process > ProcessSP