1//===-- PlatformPOSIX.h -----------------------------------------*- 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#ifndef liblldb_PlatformPOSIX_h_
10#define liblldb_PlatformPOSIX_h_
11
12#include <map>
13#include <memory>
14
15#include "lldb/Interpreter/Options.h"
16#include "lldb/Target/RemoteAwarePlatform.h"
17
18class PlatformPOSIX : public lldb_private::RemoteAwarePlatform {
19public:
20  PlatformPOSIX(bool is_host);
21
22  ~PlatformPOSIX() override;
23
24  // lldb_private::Platform functions
25
26  lldb_private::OptionGroupOptions *
27  GetConnectionOptions(lldb_private::CommandInterpreter &interpreter) override;
28
29  lldb_private::Status PutFile(const lldb_private::FileSpec &source,
30                               const lldb_private::FileSpec &destination,
31                               uint32_t uid = UINT32_MAX,
32                               uint32_t gid = UINT32_MAX) override;
33
34  lldb_private::Status
35  GetFile(const lldb_private::FileSpec &source,
36          const lldb_private::FileSpec &destination) override;
37
38  const lldb::UnixSignalsSP &GetRemoteUnixSignals() override;
39
40  lldb_private::Status ResolveExecutable(
41      const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
42      const lldb_private::FileSpecList *module_search_paths_ptr) override;
43
44  lldb::ProcessSP Attach(lldb_private::ProcessAttachInfo &attach_info,
45                         lldb_private::Debugger &debugger,
46                         lldb_private::Target *target, // Can be nullptr, if
47                                                       // nullptr create a new
48                                                       // target, else use
49                                                       // existing one
50                         lldb_private::Status &error) override;
51
52  lldb::ProcessSP DebugProcess(lldb_private::ProcessLaunchInfo &launch_info,
53                               lldb_private::Debugger &debugger,
54                               lldb_private::Target *target, // Can be nullptr,
55                                                             // if nullptr
56                                                             // create a new
57                                                             // target, else use
58                                                             // existing one
59                               lldb_private::Status &error) override;
60
61  std::string GetPlatformSpecificConnectionInformation() override;
62
63  void CalculateTrapHandlerSymbolNames() override;
64
65  lldb_private::Status ConnectRemote(lldb_private::Args &args) override;
66
67  lldb_private::Status DisconnectRemote() override;
68
69  uint32_t DoLoadImage(lldb_private::Process *process,
70                       const lldb_private::FileSpec &remote_file,
71                       const std::vector<std::string> *paths,
72                       lldb_private::Status &error,
73                       lldb_private::FileSpec *loaded_image) override;
74
75  lldb_private::Status UnloadImage(lldb_private::Process *process,
76                                   uint32_t image_token) override;
77
78  size_t ConnectToWaitingProcesses(lldb_private::Debugger &debugger,
79                                   lldb_private::Status &error) override;
80
81  lldb_private::ConstString GetFullNameForDylib(lldb_private::ConstString basename) override;
82
83protected:
84  std::unique_ptr<lldb_private::OptionGroupPlatformRSync>
85      m_option_group_platform_rsync;
86  std::unique_ptr<lldb_private::OptionGroupPlatformSSH>
87      m_option_group_platform_ssh;
88  std::unique_ptr<lldb_private::OptionGroupPlatformCaching>
89      m_option_group_platform_caching;
90
91  std::map<lldb_private::CommandInterpreter *,
92           std::unique_ptr<lldb_private::OptionGroupOptions>>
93      m_options;
94
95  lldb_private::Status
96  EvaluateLibdlExpression(lldb_private::Process *process, const char *expr_cstr,
97                          llvm::StringRef expr_prefix,
98                          lldb::ValueObjectSP &result_valobj_sp);
99
100  std::unique_ptr<lldb_private::UtilityFunction>
101  MakeLoadImageUtilityFunction(lldb_private::ExecutionContext &exe_ctx,
102                               lldb_private::Status &error);
103
104  virtual
105  llvm::StringRef GetLibdlFunctionDeclarations(lldb_private::Process *process);
106
107private:
108  DISALLOW_COPY_AND_ASSIGN(PlatformPOSIX);
109};
110
111#endif // liblldb_PlatformPOSIX_h_
112