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