llvm-project/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.h
Jonas Devlieghere 0aaf480be9
[lldb] Cleanup MacOSX platform headers (NFC)
While working on dde487e54782 I noticed that the MacOSX platforms were
in need of some love. This patch cleans up the headers:

 - Move platforms into the lldb_private namespace.
 - Remove lldb_private:: prefixes to improve readability.
 - Fix header includes and use forward declarations (iwyu).
 - Fix formatting
2022-03-14 22:01:05 -07:00

127 lines
4.2 KiB
C++

//===-- PlatformRemoteDarwinDevice.h -------------------------------------*- C++
//-*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SOURCE_PLUGINS_PLATFORM_MACOSX_PLATFORMREMOTEDARWINDEVICE_H
#define LLDB_SOURCE_PLUGINS_PLATFORM_MACOSX_PLATFORMREMOTEDARWINDEVICE_H
#include "PlatformDarwin.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/XcodeSDK.h"
#include "lldb/lldb-forward.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/VersionTuple.h"
#include <mutex>
#include <string>
#include <vector>
namespace lldb_private {
class FileSpecList;
class ModuleSpec;
class Process;
class Stream;
class Target;
class UUID;
class PlatformRemoteDarwinDevice : public PlatformDarwin {
public:
PlatformRemoteDarwinDevice();
~PlatformRemoteDarwinDevice() override;
// Platform functions
Status
ResolveExecutable(const ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
const FileSpecList *module_search_paths_ptr) override;
void GetStatus(Stream &strm) override;
virtual Status GetSymbolFile(const FileSpec &platform_file,
const UUID *uuid_ptr, FileSpec &local_file);
Status GetSharedModule(const ModuleSpec &module_spec, Process *process,
lldb::ModuleSP &module_sp,
const FileSpecList *module_search_paths_ptr,
llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules,
bool *did_create_ptr) override;
void
AddClangModuleCompilationOptions(Target *target,
std::vector<std::string> &options) override {
return PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(
target, options, XcodeSDK::Type::iPhoneOS);
}
protected:
struct SDKDirectoryInfo {
SDKDirectoryInfo(const FileSpec &sdk_dir_spec);
FileSpec directory;
ConstString build;
llvm::VersionTuple version;
bool user_cached;
};
typedef std::vector<SDKDirectoryInfo> SDKDirectoryInfoCollection;
std::mutex m_sdk_dir_mutex;
SDKDirectoryInfoCollection m_sdk_directory_infos;
std::string m_device_support_directory;
std::string m_device_support_directory_for_os_version;
std::string m_build_update;
uint32_t m_last_module_sdk_idx = UINT32_MAX;
uint32_t m_connected_module_sdk_idx = UINT32_MAX;
bool UpdateSDKDirectoryInfosIfNeeded();
const char *GetDeviceSupportDirectory();
const char *GetDeviceSupportDirectoryForOSVersion();
const SDKDirectoryInfo *GetSDKDirectoryForLatestOSVersion();
const SDKDirectoryInfo *GetSDKDirectoryForCurrentOSVersion();
static FileSystem::EnumerateDirectoryResult
GetContainedFilesIntoVectorOfStringsCallback(void *baton,
llvm::sys::fs::file_type ft,
llvm::StringRef path);
uint32_t FindFileInAllSDKs(const char *platform_file_path,
FileSpecList &file_list);
bool GetFileInSDK(const char *platform_file_path, uint32_t sdk_idx,
FileSpec &local_file);
uint32_t FindFileInAllSDKs(const FileSpec &platform_file,
FileSpecList &file_list);
uint32_t GetConnectedSDKIndex();
// Get index of SDK in SDKDirectoryInfoCollection by its pointer and return
// UINT32_MAX if that SDK not found.
uint32_t GetSDKIndexBySDKDirectoryInfo(const SDKDirectoryInfo *sdk_info);
virtual llvm::StringRef GetDeviceSupportDirectoryName() = 0;
virtual llvm::StringRef GetPlatformName() = 0;
private:
PlatformRemoteDarwinDevice(const PlatformRemoteDarwinDevice &) = delete;
const PlatformRemoteDarwinDevice &
operator=(const PlatformRemoteDarwinDevice &) = delete;
};
} // namespace lldb_private
#endif // LLDB_SOURCE_PLUGINS_PLATFORM_MACOSX_PLATFORMREMOTEDARWINDEVICE_H