1 //===-- PlatformAndroid.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_ANDROID_PLATFORMANDROID_H
10 #define LLDB_SOURCE_PLUGINS_PLATFORM_ANDROID_PLATFORMANDROID_H
11 
12 #include <memory>
13 #include <string>
14 
15 #include "Plugins/Platform/Linux/PlatformLinux.h"
16 
17 #include "AdbClient.h"
18 
19 namespace lldb_private {
20 namespace platform_android {
21 
22 class PlatformAndroid : public platform_linux::PlatformLinux {
23 public:
24   PlatformAndroid(bool is_host);
25 
26   static void Initialize();
27 
28   static void Terminate();
29 
30   // lldb_private::PluginInterface functions
31   static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch);
32 
33   static ConstString GetPluginNameStatic(bool is_host);
34 
35   static const char *GetPluginDescriptionStatic(bool is_host);
36 
37   ConstString GetPluginName() override;
38 
39   uint32_t GetPluginVersion() override { return 1; }
40 
41   // lldb_private::Platform functions
42 
43   Status ConnectRemote(Args &args) override;
44 
45   Status GetFile(const FileSpec &source, const FileSpec &destination) override;
46 
47   Status PutFile(const FileSpec &source, const FileSpec &destination,
48                  uint32_t uid = UINT32_MAX, uint32_t gid = UINT32_MAX) override;
49 
50   uint32_t GetSdkVersion();
51 
52   bool GetRemoteOSVersion() override;
53 
54   Status DisconnectRemote() override;
55 
56   uint32_t GetDefaultMemoryCacheLineSize() override;
57 
58 protected:
59   const char *GetCacheHostname() override;
60 
61   Status DownloadModuleSlice(const FileSpec &src_file_spec,
62                              const uint64_t src_offset, const uint64_t src_size,
63                              const FileSpec &dst_file_spec) override;
64 
65   Status DownloadSymbolFile(const lldb::ModuleSP &module_sp,
66                             const FileSpec &dst_file_spec) override;
67 
68   llvm::StringRef
69   GetLibdlFunctionDeclarations(lldb_private::Process *process) override;
70 
71 private:
72   AdbClient::SyncService *GetSyncService(Status &error);
73 
74   std::unique_ptr<AdbClient::SyncService> m_adb_sync_svc;
75   std::string m_device_id;
76   uint32_t m_sdk_version;
77 };
78 
79 } // namespace platofor_android
80 } // namespace lldb_private
81 
82 #endif // LLDB_SOURCE_PLUGINS_PLATFORM_ANDROID_PLATFORMANDROID_H
83