1*0b57cec5SDimitry Andric //===-- SBPlatform.cpp ------------------------------------------*- C++ -*-===// 2*0b57cec5SDimitry Andric // 3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*0b57cec5SDimitry Andric // 7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 8*0b57cec5SDimitry Andric 9*0b57cec5SDimitry Andric #include "lldb/API/SBPlatform.h" 10*0b57cec5SDimitry Andric #include "SBReproducerPrivate.h" 11*0b57cec5SDimitry Andric #include "lldb/API/SBError.h" 12*0b57cec5SDimitry Andric #include "lldb/API/SBFileSpec.h" 13*0b57cec5SDimitry Andric #include "lldb/API/SBLaunchInfo.h" 14*0b57cec5SDimitry Andric #include "lldb/API/SBUnixSignals.h" 15*0b57cec5SDimitry Andric #include "lldb/Host/File.h" 16*0b57cec5SDimitry Andric #include "lldb/Target/Platform.h" 17*0b57cec5SDimitry Andric #include "lldb/Target/Target.h" 18*0b57cec5SDimitry Andric #include "lldb/Utility/ArchSpec.h" 19*0b57cec5SDimitry Andric #include "lldb/Utility/Args.h" 20*0b57cec5SDimitry Andric #include "lldb/Utility/Status.h" 21*0b57cec5SDimitry Andric 22*0b57cec5SDimitry Andric #include "llvm/Support/FileSystem.h" 23*0b57cec5SDimitry Andric 24*0b57cec5SDimitry Andric #include <functional> 25*0b57cec5SDimitry Andric 26*0b57cec5SDimitry Andric using namespace lldb; 27*0b57cec5SDimitry Andric using namespace lldb_private; 28*0b57cec5SDimitry Andric 29*0b57cec5SDimitry Andric // PlatformConnectOptions 30*0b57cec5SDimitry Andric struct PlatformConnectOptions { 31*0b57cec5SDimitry Andric PlatformConnectOptions(const char *url = nullptr) 32*0b57cec5SDimitry Andric : m_url(), m_rsync_options(), m_rsync_remote_path_prefix(), 33*0b57cec5SDimitry Andric m_rsync_enabled(false), m_rsync_omit_hostname_from_remote_path(false), 34*0b57cec5SDimitry Andric m_local_cache_directory() { 35*0b57cec5SDimitry Andric if (url && url[0]) 36*0b57cec5SDimitry Andric m_url = url; 37*0b57cec5SDimitry Andric } 38*0b57cec5SDimitry Andric 39*0b57cec5SDimitry Andric ~PlatformConnectOptions() {} 40*0b57cec5SDimitry Andric 41*0b57cec5SDimitry Andric std::string m_url; 42*0b57cec5SDimitry Andric std::string m_rsync_options; 43*0b57cec5SDimitry Andric std::string m_rsync_remote_path_prefix; 44*0b57cec5SDimitry Andric bool m_rsync_enabled; 45*0b57cec5SDimitry Andric bool m_rsync_omit_hostname_from_remote_path; 46*0b57cec5SDimitry Andric ConstString m_local_cache_directory; 47*0b57cec5SDimitry Andric }; 48*0b57cec5SDimitry Andric 49*0b57cec5SDimitry Andric // PlatformShellCommand 50*0b57cec5SDimitry Andric struct PlatformShellCommand { 51*0b57cec5SDimitry Andric PlatformShellCommand(const char *shell_command = nullptr) 52*0b57cec5SDimitry Andric : m_command(), m_working_dir(), m_status(0), m_signo(0) { 53*0b57cec5SDimitry Andric if (shell_command && shell_command[0]) 54*0b57cec5SDimitry Andric m_command = shell_command; 55*0b57cec5SDimitry Andric } 56*0b57cec5SDimitry Andric 57*0b57cec5SDimitry Andric ~PlatformShellCommand() {} 58*0b57cec5SDimitry Andric 59*0b57cec5SDimitry Andric std::string m_command; 60*0b57cec5SDimitry Andric std::string m_working_dir; 61*0b57cec5SDimitry Andric std::string m_output; 62*0b57cec5SDimitry Andric int m_status; 63*0b57cec5SDimitry Andric int m_signo; 64*0b57cec5SDimitry Andric Timeout<std::ratio<1>> m_timeout = llvm::None; 65*0b57cec5SDimitry Andric }; 66*0b57cec5SDimitry Andric // SBPlatformConnectOptions 67*0b57cec5SDimitry Andric SBPlatformConnectOptions::SBPlatformConnectOptions(const char *url) 68*0b57cec5SDimitry Andric : m_opaque_ptr(new PlatformConnectOptions(url)) { 69*0b57cec5SDimitry Andric LLDB_RECORD_CONSTRUCTOR(SBPlatformConnectOptions, (const char *), url); 70*0b57cec5SDimitry Andric } 71*0b57cec5SDimitry Andric 72*0b57cec5SDimitry Andric SBPlatformConnectOptions::SBPlatformConnectOptions( 73*0b57cec5SDimitry Andric const SBPlatformConnectOptions &rhs) 74*0b57cec5SDimitry Andric : m_opaque_ptr(new PlatformConnectOptions()) { 75*0b57cec5SDimitry Andric LLDB_RECORD_CONSTRUCTOR(SBPlatformConnectOptions, 76*0b57cec5SDimitry Andric (const lldb::SBPlatformConnectOptions &), rhs); 77*0b57cec5SDimitry Andric 78*0b57cec5SDimitry Andric *m_opaque_ptr = *rhs.m_opaque_ptr; 79*0b57cec5SDimitry Andric } 80*0b57cec5SDimitry Andric 81*0b57cec5SDimitry Andric SBPlatformConnectOptions::~SBPlatformConnectOptions() { delete m_opaque_ptr; } 82*0b57cec5SDimitry Andric 83*0b57cec5SDimitry Andric void SBPlatformConnectOptions::operator=(const SBPlatformConnectOptions &rhs) { 84*0b57cec5SDimitry Andric LLDB_RECORD_METHOD( 85*0b57cec5SDimitry Andric void, 86*0b57cec5SDimitry Andric SBPlatformConnectOptions, operator=,( 87*0b57cec5SDimitry Andric const lldb::SBPlatformConnectOptions &), 88*0b57cec5SDimitry Andric rhs); 89*0b57cec5SDimitry Andric 90*0b57cec5SDimitry Andric *m_opaque_ptr = *rhs.m_opaque_ptr; 91*0b57cec5SDimitry Andric } 92*0b57cec5SDimitry Andric 93*0b57cec5SDimitry Andric const char *SBPlatformConnectOptions::GetURL() { 94*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatformConnectOptions, GetURL); 95*0b57cec5SDimitry Andric 96*0b57cec5SDimitry Andric if (m_opaque_ptr->m_url.empty()) 97*0b57cec5SDimitry Andric return nullptr; 98*0b57cec5SDimitry Andric return m_opaque_ptr->m_url.c_str(); 99*0b57cec5SDimitry Andric } 100*0b57cec5SDimitry Andric 101*0b57cec5SDimitry Andric void SBPlatformConnectOptions::SetURL(const char *url) { 102*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(void, SBPlatformConnectOptions, SetURL, (const char *), 103*0b57cec5SDimitry Andric url); 104*0b57cec5SDimitry Andric 105*0b57cec5SDimitry Andric if (url && url[0]) 106*0b57cec5SDimitry Andric m_opaque_ptr->m_url = url; 107*0b57cec5SDimitry Andric else 108*0b57cec5SDimitry Andric m_opaque_ptr->m_url.clear(); 109*0b57cec5SDimitry Andric } 110*0b57cec5SDimitry Andric 111*0b57cec5SDimitry Andric bool SBPlatformConnectOptions::GetRsyncEnabled() { 112*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(bool, SBPlatformConnectOptions, GetRsyncEnabled); 113*0b57cec5SDimitry Andric 114*0b57cec5SDimitry Andric return m_opaque_ptr->m_rsync_enabled; 115*0b57cec5SDimitry Andric } 116*0b57cec5SDimitry Andric 117*0b57cec5SDimitry Andric void SBPlatformConnectOptions::EnableRsync( 118*0b57cec5SDimitry Andric const char *options, const char *remote_path_prefix, 119*0b57cec5SDimitry Andric bool omit_hostname_from_remote_path) { 120*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(void, SBPlatformConnectOptions, EnableRsync, 121*0b57cec5SDimitry Andric (const char *, const char *, bool), options, 122*0b57cec5SDimitry Andric remote_path_prefix, omit_hostname_from_remote_path); 123*0b57cec5SDimitry Andric 124*0b57cec5SDimitry Andric m_opaque_ptr->m_rsync_enabled = true; 125*0b57cec5SDimitry Andric m_opaque_ptr->m_rsync_omit_hostname_from_remote_path = 126*0b57cec5SDimitry Andric omit_hostname_from_remote_path; 127*0b57cec5SDimitry Andric if (remote_path_prefix && remote_path_prefix[0]) 128*0b57cec5SDimitry Andric m_opaque_ptr->m_rsync_remote_path_prefix = remote_path_prefix; 129*0b57cec5SDimitry Andric else 130*0b57cec5SDimitry Andric m_opaque_ptr->m_rsync_remote_path_prefix.clear(); 131*0b57cec5SDimitry Andric 132*0b57cec5SDimitry Andric if (options && options[0]) 133*0b57cec5SDimitry Andric m_opaque_ptr->m_rsync_options = options; 134*0b57cec5SDimitry Andric else 135*0b57cec5SDimitry Andric m_opaque_ptr->m_rsync_options.clear(); 136*0b57cec5SDimitry Andric } 137*0b57cec5SDimitry Andric 138*0b57cec5SDimitry Andric void SBPlatformConnectOptions::DisableRsync() { 139*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(void, SBPlatformConnectOptions, DisableRsync); 140*0b57cec5SDimitry Andric 141*0b57cec5SDimitry Andric m_opaque_ptr->m_rsync_enabled = false; 142*0b57cec5SDimitry Andric } 143*0b57cec5SDimitry Andric 144*0b57cec5SDimitry Andric const char *SBPlatformConnectOptions::GetLocalCacheDirectory() { 145*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatformConnectOptions, 146*0b57cec5SDimitry Andric GetLocalCacheDirectory); 147*0b57cec5SDimitry Andric 148*0b57cec5SDimitry Andric return m_opaque_ptr->m_local_cache_directory.GetCString(); 149*0b57cec5SDimitry Andric } 150*0b57cec5SDimitry Andric 151*0b57cec5SDimitry Andric void SBPlatformConnectOptions::SetLocalCacheDirectory(const char *path) { 152*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(void, SBPlatformConnectOptions, SetLocalCacheDirectory, 153*0b57cec5SDimitry Andric (const char *), path); 154*0b57cec5SDimitry Andric 155*0b57cec5SDimitry Andric if (path && path[0]) 156*0b57cec5SDimitry Andric m_opaque_ptr->m_local_cache_directory.SetCString(path); 157*0b57cec5SDimitry Andric else 158*0b57cec5SDimitry Andric m_opaque_ptr->m_local_cache_directory = ConstString(); 159*0b57cec5SDimitry Andric } 160*0b57cec5SDimitry Andric 161*0b57cec5SDimitry Andric // SBPlatformShellCommand 162*0b57cec5SDimitry Andric SBPlatformShellCommand::SBPlatformShellCommand(const char *shell_command) 163*0b57cec5SDimitry Andric : m_opaque_ptr(new PlatformShellCommand(shell_command)) { 164*0b57cec5SDimitry Andric LLDB_RECORD_CONSTRUCTOR(SBPlatformShellCommand, (const char *), 165*0b57cec5SDimitry Andric shell_command); 166*0b57cec5SDimitry Andric } 167*0b57cec5SDimitry Andric 168*0b57cec5SDimitry Andric SBPlatformShellCommand::SBPlatformShellCommand( 169*0b57cec5SDimitry Andric const SBPlatformShellCommand &rhs) 170*0b57cec5SDimitry Andric : m_opaque_ptr(new PlatformShellCommand()) { 171*0b57cec5SDimitry Andric LLDB_RECORD_CONSTRUCTOR(SBPlatformShellCommand, 172*0b57cec5SDimitry Andric (const lldb::SBPlatformShellCommand &), rhs); 173*0b57cec5SDimitry Andric 174*0b57cec5SDimitry Andric *m_opaque_ptr = *rhs.m_opaque_ptr; 175*0b57cec5SDimitry Andric } 176*0b57cec5SDimitry Andric 177*0b57cec5SDimitry Andric SBPlatformShellCommand::~SBPlatformShellCommand() { delete m_opaque_ptr; } 178*0b57cec5SDimitry Andric 179*0b57cec5SDimitry Andric void SBPlatformShellCommand::Clear() { 180*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(void, SBPlatformShellCommand, Clear); 181*0b57cec5SDimitry Andric 182*0b57cec5SDimitry Andric m_opaque_ptr->m_output = std::string(); 183*0b57cec5SDimitry Andric m_opaque_ptr->m_status = 0; 184*0b57cec5SDimitry Andric m_opaque_ptr->m_signo = 0; 185*0b57cec5SDimitry Andric } 186*0b57cec5SDimitry Andric 187*0b57cec5SDimitry Andric const char *SBPlatformShellCommand::GetCommand() { 188*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatformShellCommand, GetCommand); 189*0b57cec5SDimitry Andric 190*0b57cec5SDimitry Andric if (m_opaque_ptr->m_command.empty()) 191*0b57cec5SDimitry Andric return nullptr; 192*0b57cec5SDimitry Andric return m_opaque_ptr->m_command.c_str(); 193*0b57cec5SDimitry Andric } 194*0b57cec5SDimitry Andric 195*0b57cec5SDimitry Andric void SBPlatformShellCommand::SetCommand(const char *shell_command) { 196*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(void, SBPlatformShellCommand, SetCommand, (const char *), 197*0b57cec5SDimitry Andric shell_command); 198*0b57cec5SDimitry Andric 199*0b57cec5SDimitry Andric if (shell_command && shell_command[0]) 200*0b57cec5SDimitry Andric m_opaque_ptr->m_command = shell_command; 201*0b57cec5SDimitry Andric else 202*0b57cec5SDimitry Andric m_opaque_ptr->m_command.clear(); 203*0b57cec5SDimitry Andric } 204*0b57cec5SDimitry Andric 205*0b57cec5SDimitry Andric const char *SBPlatformShellCommand::GetWorkingDirectory() { 206*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatformShellCommand, 207*0b57cec5SDimitry Andric GetWorkingDirectory); 208*0b57cec5SDimitry Andric 209*0b57cec5SDimitry Andric if (m_opaque_ptr->m_working_dir.empty()) 210*0b57cec5SDimitry Andric return nullptr; 211*0b57cec5SDimitry Andric return m_opaque_ptr->m_working_dir.c_str(); 212*0b57cec5SDimitry Andric } 213*0b57cec5SDimitry Andric 214*0b57cec5SDimitry Andric void SBPlatformShellCommand::SetWorkingDirectory(const char *path) { 215*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(void, SBPlatformShellCommand, SetWorkingDirectory, 216*0b57cec5SDimitry Andric (const char *), path); 217*0b57cec5SDimitry Andric 218*0b57cec5SDimitry Andric if (path && path[0]) 219*0b57cec5SDimitry Andric m_opaque_ptr->m_working_dir = path; 220*0b57cec5SDimitry Andric else 221*0b57cec5SDimitry Andric m_opaque_ptr->m_working_dir.clear(); 222*0b57cec5SDimitry Andric } 223*0b57cec5SDimitry Andric 224*0b57cec5SDimitry Andric uint32_t SBPlatformShellCommand::GetTimeoutSeconds() { 225*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBPlatformShellCommand, 226*0b57cec5SDimitry Andric GetTimeoutSeconds); 227*0b57cec5SDimitry Andric 228*0b57cec5SDimitry Andric if (m_opaque_ptr->m_timeout) 229*0b57cec5SDimitry Andric return m_opaque_ptr->m_timeout->count(); 230*0b57cec5SDimitry Andric return UINT32_MAX; 231*0b57cec5SDimitry Andric } 232*0b57cec5SDimitry Andric 233*0b57cec5SDimitry Andric void SBPlatformShellCommand::SetTimeoutSeconds(uint32_t sec) { 234*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(void, SBPlatformShellCommand, SetTimeoutSeconds, 235*0b57cec5SDimitry Andric (uint32_t), sec); 236*0b57cec5SDimitry Andric 237*0b57cec5SDimitry Andric if (sec == UINT32_MAX) 238*0b57cec5SDimitry Andric m_opaque_ptr->m_timeout = llvm::None; 239*0b57cec5SDimitry Andric else 240*0b57cec5SDimitry Andric m_opaque_ptr->m_timeout = std::chrono::seconds(sec); 241*0b57cec5SDimitry Andric } 242*0b57cec5SDimitry Andric 243*0b57cec5SDimitry Andric int SBPlatformShellCommand::GetSignal() { 244*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(int, SBPlatformShellCommand, GetSignal); 245*0b57cec5SDimitry Andric 246*0b57cec5SDimitry Andric return m_opaque_ptr->m_signo; 247*0b57cec5SDimitry Andric } 248*0b57cec5SDimitry Andric 249*0b57cec5SDimitry Andric int SBPlatformShellCommand::GetStatus() { 250*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(int, SBPlatformShellCommand, GetStatus); 251*0b57cec5SDimitry Andric 252*0b57cec5SDimitry Andric return m_opaque_ptr->m_status; 253*0b57cec5SDimitry Andric } 254*0b57cec5SDimitry Andric 255*0b57cec5SDimitry Andric const char *SBPlatformShellCommand::GetOutput() { 256*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatformShellCommand, GetOutput); 257*0b57cec5SDimitry Andric 258*0b57cec5SDimitry Andric if (m_opaque_ptr->m_output.empty()) 259*0b57cec5SDimitry Andric return nullptr; 260*0b57cec5SDimitry Andric return m_opaque_ptr->m_output.c_str(); 261*0b57cec5SDimitry Andric } 262*0b57cec5SDimitry Andric 263*0b57cec5SDimitry Andric // SBPlatform 264*0b57cec5SDimitry Andric SBPlatform::SBPlatform() : m_opaque_sp() { 265*0b57cec5SDimitry Andric LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBPlatform); 266*0b57cec5SDimitry Andric } 267*0b57cec5SDimitry Andric 268*0b57cec5SDimitry Andric SBPlatform::SBPlatform(const char *platform_name) : m_opaque_sp() { 269*0b57cec5SDimitry Andric LLDB_RECORD_CONSTRUCTOR(SBPlatform, (const char *), platform_name); 270*0b57cec5SDimitry Andric 271*0b57cec5SDimitry Andric Status error; 272*0b57cec5SDimitry Andric if (platform_name && platform_name[0]) 273*0b57cec5SDimitry Andric m_opaque_sp = Platform::Create(ConstString(platform_name), error); 274*0b57cec5SDimitry Andric } 275*0b57cec5SDimitry Andric 276*0b57cec5SDimitry Andric SBPlatform::~SBPlatform() {} 277*0b57cec5SDimitry Andric 278*0b57cec5SDimitry Andric bool SBPlatform::IsValid() const { 279*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBPlatform, IsValid); 280*0b57cec5SDimitry Andric return this->operator bool(); 281*0b57cec5SDimitry Andric } 282*0b57cec5SDimitry Andric SBPlatform::operator bool() const { 283*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBPlatform, operator bool); 284*0b57cec5SDimitry Andric 285*0b57cec5SDimitry Andric return m_opaque_sp.get() != nullptr; 286*0b57cec5SDimitry Andric } 287*0b57cec5SDimitry Andric 288*0b57cec5SDimitry Andric void SBPlatform::Clear() { 289*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(void, SBPlatform, Clear); 290*0b57cec5SDimitry Andric 291*0b57cec5SDimitry Andric m_opaque_sp.reset(); 292*0b57cec5SDimitry Andric } 293*0b57cec5SDimitry Andric 294*0b57cec5SDimitry Andric const char *SBPlatform::GetName() { 295*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatform, GetName); 296*0b57cec5SDimitry Andric 297*0b57cec5SDimitry Andric PlatformSP platform_sp(GetSP()); 298*0b57cec5SDimitry Andric if (platform_sp) 299*0b57cec5SDimitry Andric return platform_sp->GetName().GetCString(); 300*0b57cec5SDimitry Andric return nullptr; 301*0b57cec5SDimitry Andric } 302*0b57cec5SDimitry Andric 303*0b57cec5SDimitry Andric lldb::PlatformSP SBPlatform::GetSP() const { return m_opaque_sp; } 304*0b57cec5SDimitry Andric 305*0b57cec5SDimitry Andric void SBPlatform::SetSP(const lldb::PlatformSP &platform_sp) { 306*0b57cec5SDimitry Andric m_opaque_sp = platform_sp; 307*0b57cec5SDimitry Andric } 308*0b57cec5SDimitry Andric 309*0b57cec5SDimitry Andric const char *SBPlatform::GetWorkingDirectory() { 310*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatform, GetWorkingDirectory); 311*0b57cec5SDimitry Andric 312*0b57cec5SDimitry Andric PlatformSP platform_sp(GetSP()); 313*0b57cec5SDimitry Andric if (platform_sp) 314*0b57cec5SDimitry Andric return platform_sp->GetWorkingDirectory().GetCString(); 315*0b57cec5SDimitry Andric return nullptr; 316*0b57cec5SDimitry Andric } 317*0b57cec5SDimitry Andric 318*0b57cec5SDimitry Andric bool SBPlatform::SetWorkingDirectory(const char *path) { 319*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(bool, SBPlatform, SetWorkingDirectory, (const char *), 320*0b57cec5SDimitry Andric path); 321*0b57cec5SDimitry Andric 322*0b57cec5SDimitry Andric PlatformSP platform_sp(GetSP()); 323*0b57cec5SDimitry Andric if (platform_sp) { 324*0b57cec5SDimitry Andric if (path) 325*0b57cec5SDimitry Andric platform_sp->SetWorkingDirectory(FileSpec(path)); 326*0b57cec5SDimitry Andric else 327*0b57cec5SDimitry Andric platform_sp->SetWorkingDirectory(FileSpec()); 328*0b57cec5SDimitry Andric return true; 329*0b57cec5SDimitry Andric } 330*0b57cec5SDimitry Andric return false; 331*0b57cec5SDimitry Andric } 332*0b57cec5SDimitry Andric 333*0b57cec5SDimitry Andric SBError SBPlatform::ConnectRemote(SBPlatformConnectOptions &connect_options) { 334*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, ConnectRemote, 335*0b57cec5SDimitry Andric (lldb::SBPlatformConnectOptions &), connect_options); 336*0b57cec5SDimitry Andric 337*0b57cec5SDimitry Andric SBError sb_error; 338*0b57cec5SDimitry Andric PlatformSP platform_sp(GetSP()); 339*0b57cec5SDimitry Andric if (platform_sp && connect_options.GetURL()) { 340*0b57cec5SDimitry Andric Args args; 341*0b57cec5SDimitry Andric args.AppendArgument( 342*0b57cec5SDimitry Andric llvm::StringRef::withNullAsEmpty(connect_options.GetURL())); 343*0b57cec5SDimitry Andric sb_error.ref() = platform_sp->ConnectRemote(args); 344*0b57cec5SDimitry Andric } else { 345*0b57cec5SDimitry Andric sb_error.SetErrorString("invalid platform"); 346*0b57cec5SDimitry Andric } 347*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_error); 348*0b57cec5SDimitry Andric } 349*0b57cec5SDimitry Andric 350*0b57cec5SDimitry Andric void SBPlatform::DisconnectRemote() { 351*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(void, SBPlatform, DisconnectRemote); 352*0b57cec5SDimitry Andric 353*0b57cec5SDimitry Andric PlatformSP platform_sp(GetSP()); 354*0b57cec5SDimitry Andric if (platform_sp) 355*0b57cec5SDimitry Andric platform_sp->DisconnectRemote(); 356*0b57cec5SDimitry Andric } 357*0b57cec5SDimitry Andric 358*0b57cec5SDimitry Andric bool SBPlatform::IsConnected() { 359*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(bool, SBPlatform, IsConnected); 360*0b57cec5SDimitry Andric 361*0b57cec5SDimitry Andric PlatformSP platform_sp(GetSP()); 362*0b57cec5SDimitry Andric if (platform_sp) 363*0b57cec5SDimitry Andric return platform_sp->IsConnected(); 364*0b57cec5SDimitry Andric return false; 365*0b57cec5SDimitry Andric } 366*0b57cec5SDimitry Andric 367*0b57cec5SDimitry Andric const char *SBPlatform::GetTriple() { 368*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatform, GetTriple); 369*0b57cec5SDimitry Andric 370*0b57cec5SDimitry Andric PlatformSP platform_sp(GetSP()); 371*0b57cec5SDimitry Andric if (platform_sp) { 372*0b57cec5SDimitry Andric ArchSpec arch(platform_sp->GetSystemArchitecture()); 373*0b57cec5SDimitry Andric if (arch.IsValid()) { 374*0b57cec5SDimitry Andric // Const-ify the string so we don't need to worry about the lifetime of 375*0b57cec5SDimitry Andric // the string 376*0b57cec5SDimitry Andric return ConstString(arch.GetTriple().getTriple().c_str()).GetCString(); 377*0b57cec5SDimitry Andric } 378*0b57cec5SDimitry Andric } 379*0b57cec5SDimitry Andric return nullptr; 380*0b57cec5SDimitry Andric } 381*0b57cec5SDimitry Andric 382*0b57cec5SDimitry Andric const char *SBPlatform::GetOSBuild() { 383*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatform, GetOSBuild); 384*0b57cec5SDimitry Andric 385*0b57cec5SDimitry Andric PlatformSP platform_sp(GetSP()); 386*0b57cec5SDimitry Andric if (platform_sp) { 387*0b57cec5SDimitry Andric std::string s; 388*0b57cec5SDimitry Andric if (platform_sp->GetOSBuildString(s)) { 389*0b57cec5SDimitry Andric if (!s.empty()) { 390*0b57cec5SDimitry Andric // Const-ify the string so we don't need to worry about the lifetime of 391*0b57cec5SDimitry Andric // the string 392*0b57cec5SDimitry Andric return ConstString(s.c_str()).GetCString(); 393*0b57cec5SDimitry Andric } 394*0b57cec5SDimitry Andric } 395*0b57cec5SDimitry Andric } 396*0b57cec5SDimitry Andric return nullptr; 397*0b57cec5SDimitry Andric } 398*0b57cec5SDimitry Andric 399*0b57cec5SDimitry Andric const char *SBPlatform::GetOSDescription() { 400*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatform, GetOSDescription); 401*0b57cec5SDimitry Andric 402*0b57cec5SDimitry Andric PlatformSP platform_sp(GetSP()); 403*0b57cec5SDimitry Andric if (platform_sp) { 404*0b57cec5SDimitry Andric std::string s; 405*0b57cec5SDimitry Andric if (platform_sp->GetOSKernelDescription(s)) { 406*0b57cec5SDimitry Andric if (!s.empty()) { 407*0b57cec5SDimitry Andric // Const-ify the string so we don't need to worry about the lifetime of 408*0b57cec5SDimitry Andric // the string 409*0b57cec5SDimitry Andric return ConstString(s.c_str()).GetCString(); 410*0b57cec5SDimitry Andric } 411*0b57cec5SDimitry Andric } 412*0b57cec5SDimitry Andric } 413*0b57cec5SDimitry Andric return nullptr; 414*0b57cec5SDimitry Andric } 415*0b57cec5SDimitry Andric 416*0b57cec5SDimitry Andric const char *SBPlatform::GetHostname() { 417*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatform, GetHostname); 418*0b57cec5SDimitry Andric 419*0b57cec5SDimitry Andric PlatformSP platform_sp(GetSP()); 420*0b57cec5SDimitry Andric if (platform_sp) 421*0b57cec5SDimitry Andric return platform_sp->GetHostname(); 422*0b57cec5SDimitry Andric return nullptr; 423*0b57cec5SDimitry Andric } 424*0b57cec5SDimitry Andric 425*0b57cec5SDimitry Andric uint32_t SBPlatform::GetOSMajorVersion() { 426*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBPlatform, GetOSMajorVersion); 427*0b57cec5SDimitry Andric 428*0b57cec5SDimitry Andric llvm::VersionTuple version; 429*0b57cec5SDimitry Andric if (PlatformSP platform_sp = GetSP()) 430*0b57cec5SDimitry Andric version = platform_sp->GetOSVersion(); 431*0b57cec5SDimitry Andric return version.empty() ? UINT32_MAX : version.getMajor(); 432*0b57cec5SDimitry Andric } 433*0b57cec5SDimitry Andric 434*0b57cec5SDimitry Andric uint32_t SBPlatform::GetOSMinorVersion() { 435*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBPlatform, GetOSMinorVersion); 436*0b57cec5SDimitry Andric 437*0b57cec5SDimitry Andric llvm::VersionTuple version; 438*0b57cec5SDimitry Andric if (PlatformSP platform_sp = GetSP()) 439*0b57cec5SDimitry Andric version = platform_sp->GetOSVersion(); 440*0b57cec5SDimitry Andric return version.getMinor().getValueOr(UINT32_MAX); 441*0b57cec5SDimitry Andric } 442*0b57cec5SDimitry Andric 443*0b57cec5SDimitry Andric uint32_t SBPlatform::GetOSUpdateVersion() { 444*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBPlatform, GetOSUpdateVersion); 445*0b57cec5SDimitry Andric 446*0b57cec5SDimitry Andric llvm::VersionTuple version; 447*0b57cec5SDimitry Andric if (PlatformSP platform_sp = GetSP()) 448*0b57cec5SDimitry Andric version = platform_sp->GetOSVersion(); 449*0b57cec5SDimitry Andric return version.getSubminor().getValueOr(UINT32_MAX); 450*0b57cec5SDimitry Andric } 451*0b57cec5SDimitry Andric 452*0b57cec5SDimitry Andric SBError SBPlatform::Get(SBFileSpec &src, SBFileSpec &dst) { 453*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, Get, 454*0b57cec5SDimitry Andric (lldb::SBFileSpec &, lldb::SBFileSpec &), src, dst); 455*0b57cec5SDimitry Andric 456*0b57cec5SDimitry Andric SBError sb_error; 457*0b57cec5SDimitry Andric PlatformSP platform_sp(GetSP()); 458*0b57cec5SDimitry Andric if (platform_sp) { 459*0b57cec5SDimitry Andric sb_error.ref() = platform_sp->GetFile(src.ref(), dst.ref()); 460*0b57cec5SDimitry Andric } else { 461*0b57cec5SDimitry Andric sb_error.SetErrorString("invalid platform"); 462*0b57cec5SDimitry Andric } 463*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_error); 464*0b57cec5SDimitry Andric } 465*0b57cec5SDimitry Andric 466*0b57cec5SDimitry Andric SBError SBPlatform::Put(SBFileSpec &src, SBFileSpec &dst) { 467*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, Put, 468*0b57cec5SDimitry Andric (lldb::SBFileSpec &, lldb::SBFileSpec &), src, dst); 469*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT( 470*0b57cec5SDimitry Andric ExecuteConnected([&](const lldb::PlatformSP &platform_sp) { 471*0b57cec5SDimitry Andric if (src.Exists()) { 472*0b57cec5SDimitry Andric uint32_t permissions = 473*0b57cec5SDimitry Andric FileSystem::Instance().GetPermissions(src.ref()); 474*0b57cec5SDimitry Andric if (permissions == 0) { 475*0b57cec5SDimitry Andric if (FileSystem::Instance().IsDirectory(src.ref())) 476*0b57cec5SDimitry Andric permissions = eFilePermissionsDirectoryDefault; 477*0b57cec5SDimitry Andric else 478*0b57cec5SDimitry Andric permissions = eFilePermissionsFileDefault; 479*0b57cec5SDimitry Andric } 480*0b57cec5SDimitry Andric 481*0b57cec5SDimitry Andric return platform_sp->PutFile(src.ref(), dst.ref(), permissions); 482*0b57cec5SDimitry Andric } 483*0b57cec5SDimitry Andric 484*0b57cec5SDimitry Andric Status error; 485*0b57cec5SDimitry Andric error.SetErrorStringWithFormat("'src' argument doesn't exist: '%s'", 486*0b57cec5SDimitry Andric src.ref().GetPath().c_str()); 487*0b57cec5SDimitry Andric return error; 488*0b57cec5SDimitry Andric })); 489*0b57cec5SDimitry Andric } 490*0b57cec5SDimitry Andric 491*0b57cec5SDimitry Andric SBError SBPlatform::Install(SBFileSpec &src, SBFileSpec &dst) { 492*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, Install, 493*0b57cec5SDimitry Andric (lldb::SBFileSpec &, lldb::SBFileSpec &), src, dst); 494*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT( 495*0b57cec5SDimitry Andric ExecuteConnected([&](const lldb::PlatformSP &platform_sp) { 496*0b57cec5SDimitry Andric if (src.Exists()) 497*0b57cec5SDimitry Andric return platform_sp->Install(src.ref(), dst.ref()); 498*0b57cec5SDimitry Andric 499*0b57cec5SDimitry Andric Status error; 500*0b57cec5SDimitry Andric error.SetErrorStringWithFormat("'src' argument doesn't exist: '%s'", 501*0b57cec5SDimitry Andric src.ref().GetPath().c_str()); 502*0b57cec5SDimitry Andric return error; 503*0b57cec5SDimitry Andric })); 504*0b57cec5SDimitry Andric } 505*0b57cec5SDimitry Andric 506*0b57cec5SDimitry Andric SBError SBPlatform::Run(SBPlatformShellCommand &shell_command) { 507*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, Run, 508*0b57cec5SDimitry Andric (lldb::SBPlatformShellCommand &), shell_command); 509*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(ExecuteConnected([&](const lldb::PlatformSP 510*0b57cec5SDimitry Andric &platform_sp) { 511*0b57cec5SDimitry Andric const char *command = shell_command.GetCommand(); 512*0b57cec5SDimitry Andric if (!command) 513*0b57cec5SDimitry Andric return Status("invalid shell command (empty)"); 514*0b57cec5SDimitry Andric 515*0b57cec5SDimitry Andric const char *working_dir = shell_command.GetWorkingDirectory(); 516*0b57cec5SDimitry Andric if (working_dir == nullptr) { 517*0b57cec5SDimitry Andric working_dir = platform_sp->GetWorkingDirectory().GetCString(); 518*0b57cec5SDimitry Andric if (working_dir) 519*0b57cec5SDimitry Andric shell_command.SetWorkingDirectory(working_dir); 520*0b57cec5SDimitry Andric } 521*0b57cec5SDimitry Andric return platform_sp->RunShellCommand(command, FileSpec(working_dir), 522*0b57cec5SDimitry Andric &shell_command.m_opaque_ptr->m_status, 523*0b57cec5SDimitry Andric &shell_command.m_opaque_ptr->m_signo, 524*0b57cec5SDimitry Andric &shell_command.m_opaque_ptr->m_output, 525*0b57cec5SDimitry Andric shell_command.m_opaque_ptr->m_timeout); 526*0b57cec5SDimitry Andric })); 527*0b57cec5SDimitry Andric } 528*0b57cec5SDimitry Andric 529*0b57cec5SDimitry Andric SBError SBPlatform::Launch(SBLaunchInfo &launch_info) { 530*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, Launch, (lldb::SBLaunchInfo &), 531*0b57cec5SDimitry Andric launch_info); 532*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT( 533*0b57cec5SDimitry Andric ExecuteConnected([&](const lldb::PlatformSP &platform_sp) { 534*0b57cec5SDimitry Andric ProcessLaunchInfo info = launch_info.ref(); 535*0b57cec5SDimitry Andric Status error = platform_sp->LaunchProcess(info); 536*0b57cec5SDimitry Andric launch_info.set_ref(info); 537*0b57cec5SDimitry Andric return error; 538*0b57cec5SDimitry Andric })); 539*0b57cec5SDimitry Andric } 540*0b57cec5SDimitry Andric 541*0b57cec5SDimitry Andric SBError SBPlatform::Kill(const lldb::pid_t pid) { 542*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, Kill, (const lldb::pid_t), pid); 543*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT( 544*0b57cec5SDimitry Andric ExecuteConnected([&](const lldb::PlatformSP &platform_sp) { 545*0b57cec5SDimitry Andric return platform_sp->KillProcess(pid); 546*0b57cec5SDimitry Andric })); 547*0b57cec5SDimitry Andric } 548*0b57cec5SDimitry Andric 549*0b57cec5SDimitry Andric SBError SBPlatform::ExecuteConnected( 550*0b57cec5SDimitry Andric const std::function<Status(const lldb::PlatformSP &)> &func) { 551*0b57cec5SDimitry Andric SBError sb_error; 552*0b57cec5SDimitry Andric const auto platform_sp(GetSP()); 553*0b57cec5SDimitry Andric if (platform_sp) { 554*0b57cec5SDimitry Andric if (platform_sp->IsConnected()) 555*0b57cec5SDimitry Andric sb_error.ref() = func(platform_sp); 556*0b57cec5SDimitry Andric else 557*0b57cec5SDimitry Andric sb_error.SetErrorString("not connected"); 558*0b57cec5SDimitry Andric } else 559*0b57cec5SDimitry Andric sb_error.SetErrorString("invalid platform"); 560*0b57cec5SDimitry Andric 561*0b57cec5SDimitry Andric return sb_error; 562*0b57cec5SDimitry Andric } 563*0b57cec5SDimitry Andric 564*0b57cec5SDimitry Andric SBError SBPlatform::MakeDirectory(const char *path, uint32_t file_permissions) { 565*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, MakeDirectory, 566*0b57cec5SDimitry Andric (const char *, uint32_t), path, file_permissions); 567*0b57cec5SDimitry Andric 568*0b57cec5SDimitry Andric SBError sb_error; 569*0b57cec5SDimitry Andric PlatformSP platform_sp(GetSP()); 570*0b57cec5SDimitry Andric if (platform_sp) { 571*0b57cec5SDimitry Andric sb_error.ref() = 572*0b57cec5SDimitry Andric platform_sp->MakeDirectory(FileSpec(path), file_permissions); 573*0b57cec5SDimitry Andric } else { 574*0b57cec5SDimitry Andric sb_error.SetErrorString("invalid platform"); 575*0b57cec5SDimitry Andric } 576*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_error); 577*0b57cec5SDimitry Andric } 578*0b57cec5SDimitry Andric 579*0b57cec5SDimitry Andric uint32_t SBPlatform::GetFilePermissions(const char *path) { 580*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(uint32_t, SBPlatform, GetFilePermissions, (const char *), 581*0b57cec5SDimitry Andric path); 582*0b57cec5SDimitry Andric 583*0b57cec5SDimitry Andric PlatformSP platform_sp(GetSP()); 584*0b57cec5SDimitry Andric if (platform_sp) { 585*0b57cec5SDimitry Andric uint32_t file_permissions = 0; 586*0b57cec5SDimitry Andric platform_sp->GetFilePermissions(FileSpec(path), file_permissions); 587*0b57cec5SDimitry Andric return file_permissions; 588*0b57cec5SDimitry Andric } 589*0b57cec5SDimitry Andric return 0; 590*0b57cec5SDimitry Andric } 591*0b57cec5SDimitry Andric 592*0b57cec5SDimitry Andric SBError SBPlatform::SetFilePermissions(const char *path, 593*0b57cec5SDimitry Andric uint32_t file_permissions) { 594*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, SetFilePermissions, 595*0b57cec5SDimitry Andric (const char *, uint32_t), path, file_permissions); 596*0b57cec5SDimitry Andric 597*0b57cec5SDimitry Andric SBError sb_error; 598*0b57cec5SDimitry Andric PlatformSP platform_sp(GetSP()); 599*0b57cec5SDimitry Andric if (platform_sp) { 600*0b57cec5SDimitry Andric sb_error.ref() = 601*0b57cec5SDimitry Andric platform_sp->SetFilePermissions(FileSpec(path), file_permissions); 602*0b57cec5SDimitry Andric } else { 603*0b57cec5SDimitry Andric sb_error.SetErrorString("invalid platform"); 604*0b57cec5SDimitry Andric } 605*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_error); 606*0b57cec5SDimitry Andric } 607*0b57cec5SDimitry Andric 608*0b57cec5SDimitry Andric SBUnixSignals SBPlatform::GetUnixSignals() const { 609*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBUnixSignals, SBPlatform, 610*0b57cec5SDimitry Andric GetUnixSignals); 611*0b57cec5SDimitry Andric 612*0b57cec5SDimitry Andric if (auto platform_sp = GetSP()) 613*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(SBUnixSignals{platform_sp}); 614*0b57cec5SDimitry Andric 615*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(SBUnixSignals()); 616*0b57cec5SDimitry Andric } 617*0b57cec5SDimitry Andric 618*0b57cec5SDimitry Andric namespace lldb_private { 619*0b57cec5SDimitry Andric namespace repro { 620*0b57cec5SDimitry Andric 621*0b57cec5SDimitry Andric template <> 622*0b57cec5SDimitry Andric void RegisterMethods<SBPlatformConnectOptions>(Registry &R) { 623*0b57cec5SDimitry Andric LLDB_REGISTER_CONSTRUCTOR(SBPlatformConnectOptions, (const char *)); 624*0b57cec5SDimitry Andric LLDB_REGISTER_CONSTRUCTOR(SBPlatformConnectOptions, 625*0b57cec5SDimitry Andric (const lldb::SBPlatformConnectOptions &)); 626*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD( 627*0b57cec5SDimitry Andric void, 628*0b57cec5SDimitry Andric SBPlatformConnectOptions, operator=,( 629*0b57cec5SDimitry Andric const lldb::SBPlatformConnectOptions &)); 630*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(const char *, SBPlatformConnectOptions, GetURL, ()); 631*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(void, SBPlatformConnectOptions, SetURL, 632*0b57cec5SDimitry Andric (const char *)); 633*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(bool, SBPlatformConnectOptions, GetRsyncEnabled, ()); 634*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(void, SBPlatformConnectOptions, EnableRsync, 635*0b57cec5SDimitry Andric (const char *, const char *, bool)); 636*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(void, SBPlatformConnectOptions, DisableRsync, ()); 637*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(const char *, SBPlatformConnectOptions, 638*0b57cec5SDimitry Andric GetLocalCacheDirectory, ()); 639*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(void, SBPlatformConnectOptions, SetLocalCacheDirectory, 640*0b57cec5SDimitry Andric (const char *)); 641*0b57cec5SDimitry Andric } 642*0b57cec5SDimitry Andric 643*0b57cec5SDimitry Andric template <> 644*0b57cec5SDimitry Andric void RegisterMethods<SBPlatformShellCommand>(Registry &R) { 645*0b57cec5SDimitry Andric LLDB_REGISTER_CONSTRUCTOR(SBPlatformShellCommand, (const char *)); 646*0b57cec5SDimitry Andric LLDB_REGISTER_CONSTRUCTOR(SBPlatformShellCommand, 647*0b57cec5SDimitry Andric (const lldb::SBPlatformShellCommand &)); 648*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, Clear, ()); 649*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(const char *, SBPlatformShellCommand, GetCommand, ()); 650*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, SetCommand, 651*0b57cec5SDimitry Andric (const char *)); 652*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(const char *, SBPlatformShellCommand, 653*0b57cec5SDimitry Andric GetWorkingDirectory, ()); 654*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, SetWorkingDirectory, 655*0b57cec5SDimitry Andric (const char *)); 656*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(uint32_t, SBPlatformShellCommand, GetTimeoutSeconds, 657*0b57cec5SDimitry Andric ()); 658*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, SetTimeoutSeconds, 659*0b57cec5SDimitry Andric (uint32_t)); 660*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(int, SBPlatformShellCommand, GetSignal, ()); 661*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(int, SBPlatformShellCommand, GetStatus, ()); 662*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(const char *, SBPlatformShellCommand, GetOutput, ()); 663*0b57cec5SDimitry Andric } 664*0b57cec5SDimitry Andric 665*0b57cec5SDimitry Andric template <> 666*0b57cec5SDimitry Andric void RegisterMethods<SBPlatform>(Registry &R) { 667*0b57cec5SDimitry Andric LLDB_REGISTER_CONSTRUCTOR(SBPlatform, ()); 668*0b57cec5SDimitry Andric LLDB_REGISTER_CONSTRUCTOR(SBPlatform, (const char *)); 669*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(bool, SBPlatform, IsValid, ()); 670*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(bool, SBPlatform, operator bool, ()); 671*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(void, SBPlatform, Clear, ()); 672*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(const char *, SBPlatform, GetName, ()); 673*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(const char *, SBPlatform, GetWorkingDirectory, ()); 674*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(bool, SBPlatform, SetWorkingDirectory, (const char *)); 675*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, ConnectRemote, 676*0b57cec5SDimitry Andric (lldb::SBPlatformConnectOptions &)); 677*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(void, SBPlatform, DisconnectRemote, ()); 678*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(bool, SBPlatform, IsConnected, ()); 679*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(const char *, SBPlatform, GetTriple, ()); 680*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(const char *, SBPlatform, GetOSBuild, ()); 681*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(const char *, SBPlatform, GetOSDescription, ()); 682*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(const char *, SBPlatform, GetHostname, ()); 683*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(uint32_t, SBPlatform, GetOSMajorVersion, ()); 684*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(uint32_t, SBPlatform, GetOSMinorVersion, ()); 685*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(uint32_t, SBPlatform, GetOSUpdateVersion, ()); 686*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, Get, 687*0b57cec5SDimitry Andric (lldb::SBFileSpec &, lldb::SBFileSpec &)); 688*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, Put, 689*0b57cec5SDimitry Andric (lldb::SBFileSpec &, lldb::SBFileSpec &)); 690*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, Install, 691*0b57cec5SDimitry Andric (lldb::SBFileSpec &, lldb::SBFileSpec &)); 692*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, Run, 693*0b57cec5SDimitry Andric (lldb::SBPlatformShellCommand &)); 694*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, Launch, 695*0b57cec5SDimitry Andric (lldb::SBLaunchInfo &)); 696*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, Kill, (const lldb::pid_t)); 697*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, MakeDirectory, 698*0b57cec5SDimitry Andric (const char *, uint32_t)); 699*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(uint32_t, SBPlatform, GetFilePermissions, 700*0b57cec5SDimitry Andric (const char *)); 701*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, SetFilePermissions, 702*0b57cec5SDimitry Andric (const char *, uint32_t)); 703*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(lldb::SBUnixSignals, SBPlatform, GetUnixSignals, 704*0b57cec5SDimitry Andric ()); 705*0b57cec5SDimitry Andric } 706*0b57cec5SDimitry Andric 707*0b57cec5SDimitry Andric } 708*0b57cec5SDimitry Andric } 709