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 LLDB_SOURCE_PLUGINS_PLATFORM_POSIX_PLATFORMPOSIX_H
10 #define LLDB_SOURCE_PLUGINS_PLATFORM_POSIX_PLATFORMPOSIX_H
11 
12 #include <map>
13 #include <memory>
14 
15 #include "lldb/Interpreter/Options.h"
16 #include "lldb/Target/RemoteAwarePlatform.h"
17 
18 class PlatformPOSIX : public lldb_private::RemoteAwarePlatform {
19 public:
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::ProcessSP Attach(lldb_private::ProcessAttachInfo &attach_info,
41                          lldb_private::Debugger &debugger,
42                          lldb_private::Target *target, // Can be nullptr, if
43                                                        // nullptr create a new
44                                                        // target, else use
45                                                        // existing one
46                          lldb_private::Status &error) override;
47 
48   lldb::ProcessSP DebugProcess(lldb_private::ProcessLaunchInfo &launch_info,
49                                lldb_private::Debugger &debugger,
50                                lldb_private::Target *target, // Can be nullptr,
51                                                              // if nullptr
52                                                              // create a new
53                                                              // target, else use
54                                                              // existing one
55                                lldb_private::Status &error) override;
56 
57   std::string GetPlatformSpecificConnectionInformation() override;
58 
59   void CalculateTrapHandlerSymbolNames() override;
60 
61   lldb_private::Status ConnectRemote(lldb_private::Args &args) override;
62 
63   lldb_private::Status DisconnectRemote() override;
64 
65   uint32_t DoLoadImage(lldb_private::Process *process,
66                        const lldb_private::FileSpec &remote_file,
67                        const std::vector<std::string> *paths,
68                        lldb_private::Status &error,
69                        lldb_private::FileSpec *loaded_image) override;
70 
71   lldb_private::Status UnloadImage(lldb_private::Process *process,
72                                    uint32_t image_token) override;
73 
74   size_t ConnectToWaitingProcesses(lldb_private::Debugger &debugger,
75                                    lldb_private::Status &error) override;
76 
77   lldb_private::ConstString GetFullNameForDylib(lldb_private::ConstString basename) override;
78 
79 protected:
80   std::unique_ptr<lldb_private::OptionGroupPlatformRSync>
81       m_option_group_platform_rsync;
82   std::unique_ptr<lldb_private::OptionGroupPlatformSSH>
83       m_option_group_platform_ssh;
84   std::unique_ptr<lldb_private::OptionGroupPlatformCaching>
85       m_option_group_platform_caching;
86 
87   std::map<lldb_private::CommandInterpreter *,
88            std::unique_ptr<lldb_private::OptionGroupOptions>>
89       m_options;
90 
91   lldb_private::Status
92   EvaluateLibdlExpression(lldb_private::Process *process, const char *expr_cstr,
93                           llvm::StringRef expr_prefix,
94                           lldb::ValueObjectSP &result_valobj_sp);
95 
96   std::unique_ptr<lldb_private::UtilityFunction>
97   MakeLoadImageUtilityFunction(lldb_private::ExecutionContext &exe_ctx,
98                                lldb_private::Status &error);
99 
100   virtual
101   llvm::StringRef GetLibdlFunctionDeclarations(lldb_private::Process *process);
102 
103 private:
104   PlatformPOSIX(const PlatformPOSIX &) = delete;
105   const PlatformPOSIX &operator=(const PlatformPOSIX &) = delete;
106 };
107 
108 #endif // LLDB_SOURCE_PLUGINS_PLATFORM_POSIX_PLATFORMPOSIX_H
109