llvm/lldb/source/Target/Platform.cpp

//===-- Platform.cpp ------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#include <algorithm>
#include <csignal>
#include <fstream>
#include <memory>
#include <optional>
#include <vector>

#include "lldb/Breakpoint/BreakpointIDList.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Host/FileCache.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/OptionValueFileSpec.h"
#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Interpreter/Property.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Target/ModuleCache.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/UnixSignals.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/StructuredData.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"

// Define these constants from POSIX mman.h rather than include the file so
// that they will be correct even when compiled on Linux.
#define MAP_PRIVATE
#define MAP_ANON

usingnamespacelldb;
usingnamespacelldb_private;

// Use a singleton function for g_local_platform_sp to avoid init constructors
// since LLDB is often part of a shared library
static PlatformSP &GetHostPlatformSP() {}

const char *Platform::GetHostPlatformName() {}

namespace {

#define LLDB_PROPERTIES_platform
#include "TargetProperties.inc"

enum {};

} // namespace

llvm::StringRef PlatformProperties::GetSettingName() {}

PlatformProperties::PlatformProperties() {}

bool PlatformProperties::GetUseModuleCache() const {}

bool PlatformProperties::SetUseModuleCache(bool use_module_cache) {}

FileSpec PlatformProperties::GetModuleCacheDirectory() const {}

bool PlatformProperties::SetModuleCacheDirectory(const FileSpec &dir_spec) {}

void PlatformProperties::SetDefaultModuleCacheDirectory(
    const FileSpec &dir_spec) {}

/// Get the native host platform plug-in.
///
/// There should only be one of these for each host that LLDB runs
/// upon that should be statically compiled in and registered using
/// preprocessor macros or other similar build mechanisms.
///
/// This platform will be used as the default platform when launching
/// or attaching to processes unless another platform is specified.
PlatformSP Platform::GetHostPlatform() {}

void Platform::Initialize() {}

void Platform::Terminate() {}

PlatformProperties &Platform::GetGlobalPlatformProperties() {}

void Platform::SetHostPlatform(const lldb::PlatformSP &platform_sp) {}

Status Platform::GetFileWithUUID(const FileSpec &platform_file,
                                 const UUID *uuid_ptr, FileSpec &local_file) {}

FileSpecList
Platform::LocateExecutableScriptingResources(Target *target, Module &module,
                                             Stream &feedback_stream) {}

Status Platform::GetSharedModule(
    const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
    const FileSpecList *module_search_paths_ptr,
    llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules, bool *did_create_ptr) {}

bool Platform::GetModuleSpec(const FileSpec &module_file_spec,
                             const ArchSpec &arch, ModuleSpec &module_spec) {}

PlatformSP Platform::Create(llvm::StringRef name) {}

ArchSpec Platform::GetAugmentedArchSpec(Platform *platform, llvm::StringRef triple) {}

/// Default Constructor
Platform::Platform(bool is_host)
    :{}

Platform::~Platform() = default;

void Platform::GetStatus(Stream &strm) {}

llvm::VersionTuple Platform::GetOSVersion(Process *process) {}

std::optional<std::string> Platform::GetOSBuildString() {}

std::optional<std::string> Platform::GetOSKernelDescription() {}

void Platform::AddClangModuleCompilationOptions(
    Target *target, std::vector<std::string> &options) {}

FileSpec Platform::GetWorkingDirectory() {}

struct RecurseCopyBaton {};

static FileSystem::EnumerateDirectoryResult
RecurseCopy_Callback(void *baton, llvm::sys::fs::file_type ft,
                     llvm::StringRef path) {}

Status Platform::Install(const FileSpec &src, const FileSpec &dst) {}

bool Platform::SetWorkingDirectory(const FileSpec &file_spec) {}

Status Platform::MakeDirectory(const FileSpec &file_spec,
                               uint32_t permissions) {}

Status Platform::GetFilePermissions(const FileSpec &file_spec,
                                    uint32_t &file_permissions) {}

Status Platform::SetFilePermissions(const FileSpec &file_spec,
                                    uint32_t file_permissions) {}

user_id_t Platform::OpenFile(const FileSpec &file_spec,
                                   File::OpenOptions flags, uint32_t mode,
                                   Status &error) {}

bool Platform::CloseFile(user_id_t fd, Status &error) {}

user_id_t Platform::GetFileSize(const FileSpec &file_spec) {}

uint64_t Platform::ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst,
                            uint64_t dst_len, Status &error) {}

uint64_t Platform::WriteFile(lldb::user_id_t fd, uint64_t offset,
                             const void *src, uint64_t src_len, Status &error) {}

UserIDResolver &Platform::GetUserIDResolver() {}

const char *Platform::GetHostname() {}

ConstString Platform::GetFullNameForDylib(ConstString basename) {}

bool Platform::SetRemoteWorkingDirectory(const FileSpec &working_dir) {}

bool Platform::SetOSVersion(llvm::VersionTuple version) {}

Status
Platform::ResolveExecutable(const ModuleSpec &module_spec,
                            lldb::ModuleSP &exe_module_sp,
                            const FileSpecList *module_search_paths_ptr) {}

Status Platform::ResolveSymbolFile(Target &target, const ModuleSpec &sym_spec,
                                   FileSpec &sym_file) {}

bool Platform::ResolveRemotePath(const FileSpec &platform_path,
                                 FileSpec &resolved_platform_path) {}

const ArchSpec &Platform::GetSystemArchitecture() {}

ArchSpec Platform::GetAugmentedArchSpec(llvm::StringRef triple) {}

Status Platform::ConnectRemote(Args &args) {}

Status Platform::DisconnectRemote() {}

bool Platform::GetProcessInfo(lldb::pid_t pid,
                              ProcessInstanceInfo &process_info) {}

uint32_t Platform::FindProcesses(const ProcessInstanceInfoMatch &match_info,
                                 ProcessInstanceInfoList &process_infos) {}

ProcessInstanceInfoList Platform::GetAllProcesses() {}

Status Platform::LaunchProcess(ProcessLaunchInfo &launch_info) {}

Status Platform::ShellExpandArguments(ProcessLaunchInfo &launch_info) {}

Status Platform::KillProcess(const lldb::pid_t pid) {}

lldb::ProcessSP Platform::DebugProcess(ProcessLaunchInfo &launch_info,
                                       Debugger &debugger, Target &target,
                                       Status &error) {}

std::vector<ArchSpec>
Platform::CreateArchList(llvm::ArrayRef<llvm::Triple::ArchType> archs,
                         llvm::Triple::OSType os) {}

/// Lets a platform answer if it is compatible with a given
/// architecture and the target triple contained within.
bool Platform::IsCompatibleArchitecture(const ArchSpec &arch,
                                        const ArchSpec &process_host_arch,
                                        ArchSpec::MatchType match,
                                        ArchSpec *compatible_arch_ptr) {}

Status Platform::PutFile(const FileSpec &source, const FileSpec &destination,
                         uint32_t uid, uint32_t gid) {}

Status Platform::GetFile(const FileSpec &source, const FileSpec &destination) {}

Status
Platform::CreateSymlink(const FileSpec &src, // The name of the link is in src
                        const FileSpec &dst) // The symlink points to dst
{}

bool Platform::GetFileExists(const lldb_private::FileSpec &file_spec) {}

Status Platform::Unlink(const FileSpec &path) {}

MmapArgList Platform::GetMmapArgumentList(const ArchSpec &arch, addr_t addr,
                                          addr_t length, unsigned prot,
                                          unsigned flags, addr_t fd,
                                          addr_t offset) {}

lldb_private::Status Platform::RunShellCommand(
    llvm::StringRef command,
    const FileSpec &
        working_dir, // Pass empty FileSpec to use the current working directory
    int *status_ptr, // Pass nullptr if you don't want the process exit status
    int *signo_ptr, // Pass nullptr if you don't want the signal that caused the
                    // process to exit
    std::string
        *command_output, // Pass nullptr if you don't want the command output
    const Timeout<std::micro> &timeout) {}

lldb_private::Status Platform::RunShellCommand(
    llvm::StringRef shell,   // Pass empty if you want to use the default
                             // shell interpreter
    llvm::StringRef command, // Shouldn't be empty
    const FileSpec &
        working_dir, // Pass empty FileSpec to use the current working directory
    int *status_ptr, // Pass nullptr if you don't want the process exit status
    int *signo_ptr, // Pass nullptr if you don't want the signal that caused the
                    // process to exit
    std::string
        *command_output, // Pass nullptr if you don't want the command output
    const Timeout<std::micro> &timeout) {}

llvm::ErrorOr<llvm::MD5::MD5Result>
Platform::CalculateMD5(const FileSpec &file_spec) {}

void Platform::SetLocalCacheDirectory(const char *local) {}

const char *Platform::GetLocalCacheDirectory() {}

static constexpr OptionDefinition g_rsync_option_table[] =;

static constexpr OptionDefinition g_ssh_option_table[] =;

static constexpr OptionDefinition g_caching_option_table[] =;

llvm::ArrayRef<OptionDefinition> OptionGroupPlatformRSync::GetDefinitions() {}

void OptionGroupPlatformRSync::OptionParsingStarting(
    ExecutionContext *execution_context) {}

lldb_private::Status
OptionGroupPlatformRSync::SetOptionValue(uint32_t option_idx,
                                         llvm::StringRef option_arg,
                                         ExecutionContext *execution_context) {}

lldb::BreakpointSP
Platform::SetThreadCreationBreakpoint(lldb_private::Target &target) {}

llvm::ArrayRef<OptionDefinition> OptionGroupPlatformSSH::GetDefinitions() {}

void OptionGroupPlatformSSH::OptionParsingStarting(
    ExecutionContext *execution_context) {}

lldb_private::Status
OptionGroupPlatformSSH::SetOptionValue(uint32_t option_idx,
                                       llvm::StringRef option_arg,
                                       ExecutionContext *execution_context) {}

llvm::ArrayRef<OptionDefinition> OptionGroupPlatformCaching::GetDefinitions() {}

void OptionGroupPlatformCaching::OptionParsingStarting(
    ExecutionContext *execution_context) {}

lldb_private::Status OptionGroupPlatformCaching::SetOptionValue(
    uint32_t option_idx, llvm::StringRef option_arg,
    ExecutionContext *execution_context) {}

Environment Platform::GetEnvironment() {}

const std::vector<ConstString> &Platform::GetTrapHandlerSymbolNames() {}

Status
Platform::GetCachedExecutable(ModuleSpec &module_spec,
                              lldb::ModuleSP &module_sp,
                              const FileSpecList *module_search_paths_ptr) {}

Status Platform::GetRemoteSharedModule(const ModuleSpec &module_spec,
                                       Process *process,
                                       lldb::ModuleSP &module_sp,
                                       const ModuleResolver &module_resolver,
                                       bool *did_create_ptr) {}

void Platform::CallLocateModuleCallbackIfSet(const ModuleSpec &module_spec,
                                             lldb::ModuleSP &module_sp,
                                             FileSpec &symbol_file_spec,
                                             bool *did_create_ptr) {}

bool Platform::GetCachedSharedModule(const ModuleSpec &module_spec,
                                     lldb::ModuleSP &module_sp,
                                     bool *did_create_ptr) {}

Status Platform::DownloadModuleSlice(const FileSpec &src_file_spec,
                                     const uint64_t src_offset,
                                     const uint64_t src_size,
                                     const FileSpec &dst_file_spec) {}

Status Platform::DownloadSymbolFile(const lldb::ModuleSP &module_sp,
                                    const FileSpec &dst_file_spec) {}

FileSpec Platform::GetModuleCacheRoot() {}

const char *Platform::GetCacheHostname() {}

const UnixSignalsSP &Platform::GetRemoteUnixSignals() {}

UnixSignalsSP Platform::GetUnixSignals() {}

uint32_t Platform::LoadImage(lldb_private::Process *process,
                             const lldb_private::FileSpec &local_file,
                             const lldb_private::FileSpec &remote_file,
                             lldb_private::Status &error) {}

uint32_t Platform::DoLoadImage(lldb_private::Process *process,
                               const lldb_private::FileSpec &remote_file,
                               const std::vector<std::string> *paths,
                               lldb_private::Status &error,
                               lldb_private::FileSpec *loaded_image) {}

uint32_t Platform::LoadImageUsingPaths(lldb_private::Process *process,
                               const lldb_private::FileSpec &remote_filename,
                               const std::vector<std::string> &paths,
                               lldb_private::Status &error,
                               lldb_private::FileSpec *loaded_path)
{}

Status Platform::UnloadImage(lldb_private::Process *process,
                             uint32_t image_token) {}

lldb::ProcessSP Platform::ConnectProcess(llvm::StringRef connect_url,
                                         llvm::StringRef plugin_name,
                                         Debugger &debugger, Target *target,
                                         Status &error) {}

lldb::ProcessSP Platform::ConnectProcessSynchronous(
    llvm::StringRef connect_url, llvm::StringRef plugin_name,
    Debugger &debugger, Stream &stream, Target *target, Status &error) {}

lldb::ProcessSP Platform::DoConnectProcess(llvm::StringRef connect_url,
                                           llvm::StringRef plugin_name,
                                           Debugger &debugger, Stream *stream,
                                           Target *target, Status &error) {}

size_t Platform::ConnectToWaitingProcesses(lldb_private::Debugger &debugger,
                                           lldb_private::Status &error) {}

size_t Platform::GetSoftwareBreakpointTrapOpcode(Target &target,
                                                 BreakpointSite *bp_site) {}

CompilerType Platform::GetSiginfoType(const llvm::Triple& triple) {}

Args Platform::GetExtraStartupCommands() {}

void Platform::SetLocateModuleCallback(LocateModuleCallback callback) {}

Platform::LocateModuleCallback Platform::GetLocateModuleCallback() const {}

PlatformSP PlatformList::GetOrCreate(llvm::StringRef name) {}

PlatformSP PlatformList::GetOrCreate(const ArchSpec &arch,
                                     const ArchSpec &process_host_arch,
                                     ArchSpec *platform_arch_ptr,
                                     Status &error) {}

PlatformSP PlatformList::GetOrCreate(const ArchSpec &arch,
                                     const ArchSpec &process_host_arch,
                                     ArchSpec *platform_arch_ptr) {}

PlatformSP PlatformList::GetOrCreate(llvm::ArrayRef<ArchSpec> archs,
                                     const ArchSpec &process_host_arch,
                                     std::vector<PlatformSP> &candidates) {}

PlatformSP PlatformList::Create(llvm::StringRef name) {}

bool PlatformList::LoadPlatformBinaryAndSetup(Process *process,
                                              lldb::addr_t addr, bool notify) {}