#include "GDBRemoteCommunicationServerCommon.h"
#include <cerrno>
#ifdef __APPLE__
#include <TargetConditionals.h>
#endif
#include <chrono>
#include <cstring>
#include <optional>
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Host/Config.h"
#include "lldb/Host/File.h"
#include "lldb/Host/FileAction.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/SafeMachO.h"
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Target/Platform.h"
#include "lldb/Utility/Endian.h"
#include "lldb/Utility/GDBRemote.h"
#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/StructuredData.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/JSON.h"
#include "llvm/TargetParser/Triple.h"
#include "ProcessGDBRemoteLog.h"
#include "lldb/Utility/StringExtractorGDBRemote.h"
#ifdef __ANDROID__
#include "lldb/Host/android/HostInfoAndroid.h"
#include "lldb/Host/common/ZipFileResolver.h"
#endif
usingnamespacelldb;
usingnamespacelldb_private::process_gdb_remote;
usingnamespacelldb_private;
#ifdef __ANDROID__
const static uint32_t g_default_packet_timeout_sec = 20;
#else
const static uint32_t g_default_packet_timeout_sec = …;
#endif
GDBRemoteCommunicationServerCommon::GDBRemoteCommunicationServerCommon()
: … { … }
GDBRemoteCommunicationServerCommon::~GDBRemoteCommunicationServerCommon() =
default;
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_qHostInfo(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_qProcessInfoPID(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_qfProcessInfo(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_qsProcessInfo(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_qUserName(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_qGroupName(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_qSpeedTest(
StringExtractorGDBRemote &packet) { … }
static GDBErrno system_errno_to_gdb(int err) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_vFile_Open(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_vFile_Close(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_vFile_pRead(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_vFile_pWrite(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_vFile_Size(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_vFile_Mode(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_vFile_Exists(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_vFile_symlink(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_vFile_unlink(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_qPlatform_shell(
StringExtractorGDBRemote &packet) { … }
template <typename T, typename U>
static void fill_clamp(T &dest, U src, typename T::value_type fallback) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_vFile_FStat(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_vFile_Stat(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_vFile_MD5(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_qPlatform_mkdir(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_qPlatform_chmod(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_qSupported(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_QSetDetachOnError(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_QStartNoAckMode(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_QSetSTDIN(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_QSetSTDOUT(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_QSetSTDERR(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_qLaunchSuccess(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_QEnvironment(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_QEnvironmentHexEncoded(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_QLaunchArch(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_A(StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_qEcho(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_qModuleInfo(
StringExtractorGDBRemote &packet) { … }
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_jModulesInfo(
StringExtractorGDBRemote &packet) { … }
void GDBRemoteCommunicationServerCommon::CreateProcessInfoResponse(
const ProcessInstanceInfo &proc_info, StreamString &response) { … }
void GDBRemoteCommunicationServerCommon::
CreateProcessInfoResponse_DebugServerStyle(
const ProcessInstanceInfo &proc_info, StreamString &response) { … }
FileSpec GDBRemoteCommunicationServerCommon::FindModuleFile(
const std::string &module_path, const ArchSpec &arch) { … }
ModuleSpec
GDBRemoteCommunicationServerCommon::GetModuleInfo(llvm::StringRef module_path,
llvm::StringRef triple) { … }
std::vector<std::string> GDBRemoteCommunicationServerCommon::HandleFeatures(
const llvm::ArrayRef<llvm::StringRef> client_features) { … }