1 //===-- PlatformAndroid.h ---------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef liblldb_PlatformAndroid_h_
11 #define liblldb_PlatformAndroid_h_
12 
13 // C Includes
14 // C++ Includes
15 #include <memory>
16 #include <string>
17 
18 // Other libraries and framework includes
19 // Project includes
20 #include "Plugins/Platform/Linux/PlatformLinux.h"
21 
22 #include "AdbClient.h"
23 
24 namespace lldb_private {
25 namespace platform_android {
26 
27 class PlatformAndroid : public platform_linux::PlatformLinux {
28 public:
29   PlatformAndroid(bool is_host);
30 
31   ~PlatformAndroid() override;
32 
33   static void Initialize();
34 
35   static void Terminate();
36 
37   //------------------------------------------------------------
38   // lldb_private::PluginInterface functions
39   //------------------------------------------------------------
40   static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch);
41 
42   static ConstString GetPluginNameStatic(bool is_host);
43 
44   static const char *GetPluginDescriptionStatic(bool is_host);
45 
46   ConstString GetPluginName() override;
47 
48   uint32_t GetPluginVersion() override { return 1; }
49 
50   //------------------------------------------------------------
51   // lldb_private::Platform functions
52   //------------------------------------------------------------
53 
54   Status ConnectRemote(Args &args) override;
55 
56   Status GetFile(const FileSpec &source, const FileSpec &destination) override;
57 
58   Status PutFile(const FileSpec &source, const FileSpec &destination,
59                  uint32_t uid = UINT32_MAX, uint32_t gid = UINT32_MAX) override;
60 
61   uint32_t GetSdkVersion();
62 
63   bool GetRemoteOSVersion() override;
64 
65   Status DisconnectRemote() override;
66 
67   uint32_t GetDefaultMemoryCacheLineSize() override;
68 
69 protected:
70   const char *GetCacheHostname() override;
71 
72   Status DownloadModuleSlice(const FileSpec &src_file_spec,
73                              const uint64_t src_offset, const uint64_t src_size,
74                              const FileSpec &dst_file_spec) override;
75 
76   Status DownloadSymbolFile(const lldb::ModuleSP &module_sp,
77                             const FileSpec &dst_file_spec) override;
78 
79   llvm::StringRef
80   GetLibdlFunctionDeclarations(lldb_private::Process *process) override;
81 
82 private:
83   AdbClient::SyncService *GetSyncService(Status &error);
84 
85   std::unique_ptr<AdbClient::SyncService> m_adb_sync_svc;
86   std::string m_device_id;
87   uint32_t m_sdk_version;
88 
89   DISALLOW_COPY_AND_ASSIGN(PlatformAndroid);
90 };
91 
92 } // namespace platofor_android
93 } // namespace lldb_private
94 
95 #endif // liblldb_PlatformAndroid_h_
96