#include "PlatformRemoteGDBServer.h"
#include "lldb/Host/Config.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/PosixApi.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/ProcessInfo.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/UriParser.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Support/FormatAdapters.h"
#include "Plugins/Process/Utility/GDBRemoteSignals.h"
#include "Plugins/Process/gdb-remote/ProcessGDBRemote.h"
#include <mutex>
#include <optional>
usingnamespacelldb;
usingnamespacelldb_private;
usingnamespacelldb_private::platform_gdb_server;
LLDB_PLUGIN_DEFINE_ADV(PlatformRemoteGDBServer, PlatformGDB)
static bool g_initialized = …;
static std::mutex g_signal_string_mutex;
static llvm::StringSet<> g_signal_string_storage;
void PlatformRemoteGDBServer::Initialize() { … }
void PlatformRemoteGDBServer::Terminate() { … }
PlatformSP PlatformRemoteGDBServer::CreateInstance(bool force,
const ArchSpec *arch) { … }
llvm::StringRef PlatformRemoteGDBServer::GetDescriptionStatic() { … }
llvm::StringRef PlatformRemoteGDBServer::GetDescription() { … }
bool PlatformRemoteGDBServer::GetModuleSpec(const FileSpec &module_file_spec,
const ArchSpec &arch,
ModuleSpec &module_spec) { … }
Status PlatformRemoteGDBServer::GetFileWithUUID(const FileSpec &platform_file,
const UUID *uuid_ptr,
FileSpec &local_file) { … }
PlatformRemoteGDBServer::PlatformRemoteGDBServer()
: … { … }
PlatformRemoteGDBServer::~PlatformRemoteGDBServer() = default;
size_t PlatformRemoteGDBServer::GetSoftwareBreakpointTrapOpcode(
Target &target, BreakpointSite *bp_site) { … }
bool PlatformRemoteGDBServer::GetRemoteOSVersion() { … }
std::optional<std::string> PlatformRemoteGDBServer::GetRemoteOSBuildString() { … }
std::optional<std::string>
PlatformRemoteGDBServer::GetRemoteOSKernelDescription() { … }
ArchSpec PlatformRemoteGDBServer::GetRemoteSystemArchitecture() { … }
FileSpec PlatformRemoteGDBServer::GetRemoteWorkingDirectory() { … }
bool PlatformRemoteGDBServer::SetRemoteWorkingDirectory(
const FileSpec &working_dir) { … }
bool PlatformRemoteGDBServer::IsConnected() const { … }
Status PlatformRemoteGDBServer::ConnectRemote(Args &args) { … }
Status PlatformRemoteGDBServer::DisconnectRemote() { … }
const char *PlatformRemoteGDBServer::GetHostname() { … }
std::optional<std::string>
PlatformRemoteGDBServer::DoGetUserName(UserIDResolver::id_t uid) { … }
std::optional<std::string>
PlatformRemoteGDBServer::DoGetGroupName(UserIDResolver::id_t gid) { … }
uint32_t PlatformRemoteGDBServer::FindProcesses(
const ProcessInstanceInfoMatch &match_info,
ProcessInstanceInfoList &process_infos) { … }
bool PlatformRemoteGDBServer::GetProcessInfo(
lldb::pid_t pid, ProcessInstanceInfo &process_info) { … }
Status PlatformRemoteGDBServer::LaunchProcess(ProcessLaunchInfo &launch_info) { … }
Status PlatformRemoteGDBServer::KillProcess(const lldb::pid_t pid) { … }
lldb::ProcessSP
PlatformRemoteGDBServer::DebugProcess(ProcessLaunchInfo &launch_info,
Debugger &debugger, Target &target,
Status &error) { … }
bool PlatformRemoteGDBServer::LaunchGDBServer(lldb::pid_t &pid,
std::string &connect_url) { … }
bool PlatformRemoteGDBServer::KillSpawnedProcess(lldb::pid_t pid) { … }
lldb::ProcessSP PlatformRemoteGDBServer::Attach(
ProcessAttachInfo &attach_info, Debugger &debugger,
Target *target,
Status &error) { … }
Status PlatformRemoteGDBServer::MakeDirectory(const FileSpec &file_spec,
uint32_t mode) { … }
Status PlatformRemoteGDBServer::GetFilePermissions(const FileSpec &file_spec,
uint32_t &file_permissions) { … }
Status PlatformRemoteGDBServer::SetFilePermissions(const FileSpec &file_spec,
uint32_t file_permissions) { … }
lldb::user_id_t PlatformRemoteGDBServer::OpenFile(const FileSpec &file_spec,
File::OpenOptions flags,
uint32_t mode,
Status &error) { … }
bool PlatformRemoteGDBServer::CloseFile(lldb::user_id_t fd, Status &error) { … }
lldb::user_id_t
PlatformRemoteGDBServer::GetFileSize(const FileSpec &file_spec) { … }
void PlatformRemoteGDBServer::AutoCompleteDiskFileOrDirectory(
CompletionRequest &request, bool only_dir) { … }
uint64_t PlatformRemoteGDBServer::ReadFile(lldb::user_id_t fd, uint64_t offset,
void *dst, uint64_t dst_len,
Status &error) { … }
uint64_t PlatformRemoteGDBServer::WriteFile(lldb::user_id_t fd, uint64_t offset,
const void *src, uint64_t src_len,
Status &error) { … }
Status PlatformRemoteGDBServer::PutFile(const FileSpec &source,
const FileSpec &destination,
uint32_t uid, uint32_t gid) { … }
Status PlatformRemoteGDBServer::CreateSymlink(
const FileSpec &src,
const FileSpec &dst)
{ … }
Status PlatformRemoteGDBServer::Unlink(const FileSpec &file_spec) { … }
bool PlatformRemoteGDBServer::GetFileExists(const FileSpec &file_spec) { … }
Status PlatformRemoteGDBServer::RunShellCommand(
llvm::StringRef shell, llvm::StringRef command,
const FileSpec &
working_dir,
int *status_ptr,
int *signo_ptr,
std::string
*command_output,
const Timeout<std::micro> &timeout) { … }
llvm::ErrorOr<llvm::MD5::MD5Result>
PlatformRemoteGDBServer::CalculateMD5(const FileSpec &file_spec) { … }
void PlatformRemoteGDBServer::CalculateTrapHandlerSymbolNames() { … }
const UnixSignalsSP &PlatformRemoteGDBServer::GetRemoteUnixSignals() { … }
std::string PlatformRemoteGDBServer::MakeGdbServerUrl(
const std::string &platform_scheme, const std::string &platform_hostname,
uint16_t port, const char *socket_name) { … }
std::string PlatformRemoteGDBServer::MakeUrl(const char *scheme,
const char *hostname,
uint16_t port, const char *path) { … }
size_t PlatformRemoteGDBServer::ConnectToWaitingProcesses(Debugger &debugger,
Status &error) { … }
size_t PlatformRemoteGDBServer::GetPendingGdbServerList(
std::vector<std::string> &connection_urls) { … }