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 GetPluginNameStatic(bool is_host)33 static llvm::StringRef GetPluginNameStatic(bool is_host) { 34 return is_host ? Platform::GetHostPlatformName() : "remote-android"; 35 } 36 37 static llvm::StringRef GetPluginDescriptionStatic(bool is_host); 38 GetPluginName()39 llvm::StringRef GetPluginName() override { 40 return GetPluginNameStatic(IsHost()); 41 } 42 43 // lldb_private::Platform functions 44 45 Status ConnectRemote(Args &args) override; 46 47 Status GetFile(const FileSpec &source, const FileSpec &destination) override; 48 49 Status PutFile(const FileSpec &source, const FileSpec &destination, 50 uint32_t uid = UINT32_MAX, uint32_t gid = UINT32_MAX) override; 51 52 uint32_t GetSdkVersion(); 53 54 bool GetRemoteOSVersion() override; 55 56 Status DisconnectRemote() override; 57 58 uint32_t GetDefaultMemoryCacheLineSize() override; 59 60 protected: 61 const char *GetCacheHostname() override; 62 63 Status DownloadModuleSlice(const FileSpec &src_file_spec, 64 const uint64_t src_offset, const uint64_t src_size, 65 const FileSpec &dst_file_spec) override; 66 67 Status DownloadSymbolFile(const lldb::ModuleSP &module_sp, 68 const FileSpec &dst_file_spec) override; 69 70 llvm::StringRef 71 GetLibdlFunctionDeclarations(lldb_private::Process *process) override; 72 73 private: 74 AdbClient::SyncService *GetSyncService(Status &error); 75 76 std::unique_ptr<AdbClient::SyncService> m_adb_sync_svc; 77 std::string m_device_id; 78 uint32_t m_sdk_version; 79 }; 80 81 } // namespace platofor_android 82 } // namespace lldb_private 83 84 #endif // LLDB_SOURCE_PLUGINS_PLATFORM_ANDROID_PLATFORMANDROID_H 85