diff options
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote')
8 files changed, 36 insertions, 38 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index 7442f48..6e47e5b 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -956,7 +956,7 @@ llvm::VersionTuple GDBRemoteCommunicationClient::GetMacCatalystVersion() { return m_maccatalyst_version; } -llvm::Optional<std::string> GDBRemoteCommunicationClient::GetOSBuildString() { +std::optional<std::string> GDBRemoteCommunicationClient::GetOSBuildString() { if (GetHostInfo()) { if (!m_os_build.empty()) return m_os_build; @@ -964,7 +964,7 @@ llvm::Optional<std::string> GDBRemoteCommunicationClient::GetOSBuildString() { return std::nullopt; } -llvm::Optional<std::string> +std::optional<std::string> GDBRemoteCommunicationClient::GetOSKernelDescription() { if (GetHostInfo()) { if (!m_os_kernel.empty()) @@ -2688,10 +2688,8 @@ bool GDBRemoteCommunicationClient::KillSpawnedProcess(lldb::pid_t pid) { return false; } -llvm::Optional<PidTid> -GDBRemoteCommunicationClient::SendSetCurrentThreadPacket(uint64_t tid, - uint64_t pid, - char op) { +std::optional<PidTid> GDBRemoteCommunicationClient::SendSetCurrentThreadPacket( + uint64_t tid, uint64_t pid, char op) { lldb_private::StreamString packet; packet.PutChar('H'); packet.PutChar(op); @@ -2729,7 +2727,7 @@ bool GDBRemoteCommunicationClient::SetCurrentThread(uint64_t tid, (m_curr_pid == pid || LLDB_INVALID_PROCESS_ID == pid)) return true; - llvm::Optional<PidTid> ret = SendSetCurrentThreadPacket(tid, pid, 'g'); + std::optional<PidTid> ret = SendSetCurrentThreadPacket(tid, pid, 'g'); if (ret) { if (ret->pid != LLDB_INVALID_PROCESS_ID) m_curr_pid = ret->pid; @@ -2744,7 +2742,7 @@ bool GDBRemoteCommunicationClient::SetCurrentThreadForRun(uint64_t tid, (m_curr_pid_run == pid || LLDB_INVALID_PROCESS_ID == pid)) return true; - llvm::Optional<PidTid> ret = SendSetCurrentThreadPacket(tid, pid, 'c'); + std::optional<PidTid> ret = SendSetCurrentThreadPacket(tid, pid, 'c'); if (ret) { if (ret->pid != LLDB_INVALID_PROCESS_ID) m_curr_pid_run = ret->pid; @@ -3088,7 +3086,7 @@ bool GDBRemoteCommunicationClient::CloseFile(lldb::user_id_t fd, return false; } -llvm::Optional<GDBRemoteFStatData> +std::optional<GDBRemoteFStatData> GDBRemoteCommunicationClient::FStat(lldb::user_id_t fd) { lldb_private::StreamString stream; stream.Printf("vFile:fstat:%" PRIx64, fd); @@ -3112,13 +3110,13 @@ GDBRemoteCommunicationClient::FStat(lldb::user_id_t fd) { return std::nullopt; } -llvm::Optional<GDBRemoteFStatData> +std::optional<GDBRemoteFStatData> GDBRemoteCommunicationClient::Stat(const lldb_private::FileSpec &file_spec) { Status error; lldb::user_id_t fd = OpenFile(file_spec, File::eOpenOptionReadOnly, 0, error); if (fd == UINT64_MAX) return std::nullopt; - llvm::Optional<GDBRemoteFStatData> st = FStat(fd); + std::optional<GDBRemoteFStatData> st = FStat(fd); CloseFile(fd, error); return st; } @@ -3146,7 +3144,7 @@ lldb::user_id_t GDBRemoteCommunicationClient::GetFileSize( } // Fallback to fstat. - llvm::Optional<GDBRemoteFStatData> st = Stat(file_spec); + std::optional<GDBRemoteFStatData> st = Stat(file_spec); return st ? st->gdb_st_size : UINT64_MAX; } @@ -3217,7 +3215,7 @@ GDBRemoteCommunicationClient::GetFilePermissions(const FileSpec &file_spec, } // Fallback to fstat. - if (llvm::Optional<GDBRemoteFStatData> st = Stat(file_spec)) { + if (std::optional<GDBRemoteFStatData> st = Stat(file_spec)) { file_permissions = st->gdb_st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); return Status(); } @@ -3720,7 +3718,7 @@ GDBRemoteCommunicationClient::SendTraceGetBinaryData( escaped_packet.GetData()); } -llvm::Optional<QOffsets> GDBRemoteCommunicationClient::GetQOffsets() { +std::optional<QOffsets> GDBRemoteCommunicationClient::GetQOffsets() { StringExtractorGDBRemote response; if (SendPacketAndWaitForResponse("qOffsets", response) != PacketResult::Success) @@ -3826,7 +3824,7 @@ bool GDBRemoteCommunicationClient::GetModuleInfo( return true; } -static llvm::Optional<ModuleSpec> +static std::optional<ModuleSpec> ParseModuleSpec(StructuredData::Dictionary *dict) { ModuleSpec result; if (!dict) @@ -3859,7 +3857,7 @@ ParseModuleSpec(StructuredData::Dictionary *dict) { return result; } -llvm::Optional<std::vector<ModuleSpec>> +std::optional<std::vector<ModuleSpec>> GDBRemoteCommunicationClient::GetModulesInfo( llvm::ArrayRef<FileSpec> module_file_specs, const llvm::Triple &triple) { namespace json = llvm::json; @@ -3906,7 +3904,7 @@ GDBRemoteCommunicationClient::GetModulesInfo( std::vector<ModuleSpec> result; for (size_t i = 0; i < response_array->GetSize(); ++i) { - if (llvm::Optional<ModuleSpec> module_spec = ParseModuleSpec( + if (std::optional<ModuleSpec> module_spec = ParseModuleSpec( response_array->GetItemAtIndex(i)->GetAsDictionary())) result.push_back(*module_spec); } diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h index c48852b..d3b03446 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h @@ -236,9 +236,9 @@ public: llvm::VersionTuple GetMacCatalystVersion(); - llvm::Optional<std::string> GetOSBuildString(); + std::optional<std::string> GetOSBuildString(); - llvm::Optional<std::string> GetOSKernelDescription(); + std::optional<std::string> GetOSKernelDescription(); ArchSpec GetSystemArchitecture(); @@ -300,8 +300,8 @@ public: // and response times. bool SendSpeedTestPacket(uint32_t send_size, uint32_t recv_size); - llvm::Optional<PidTid> - SendSetCurrentThreadPacket(uint64_t tid, uint64_t pid, char op); + std::optional<PidTid> SendSetCurrentThreadPacket(uint64_t tid, uint64_t pid, + char op); bool SetCurrentThread(uint64_t tid, lldb::pid_t pid = LLDB_INVALID_PROCESS_ID); @@ -352,11 +352,11 @@ public: bool CloseFile(lldb::user_id_t fd, Status &error); - llvm::Optional<GDBRemoteFStatData> FStat(lldb::user_id_t fd); + std::optional<GDBRemoteFStatData> FStat(lldb::user_id_t fd); // NB: this is just a convenience wrapper over open() + fstat(). It does not // work if the file cannot be opened. - llvm::Optional<GDBRemoteFStatData> Stat(const FileSpec &file_spec); + std::optional<GDBRemoteFStatData> Stat(const FileSpec &file_spec); lldb::user_id_t GetFileSize(const FileSpec &file_spec); @@ -445,12 +445,12 @@ public: /// Use qOffsets to query the offset used when relocating the target /// executable. If successful, the returned structure will contain at least /// one value in the offsets field. - llvm::Optional<QOffsets> GetQOffsets(); + std::optional<QOffsets> GetQOffsets(); bool GetModuleInfo(const FileSpec &module_file_spec, const ArchSpec &arch_spec, ModuleSpec &module_spec); - llvm::Optional<std::vector<ModuleSpec>> + std::optional<std::vector<ModuleSpec>> GetModulesInfo(llvm::ArrayRef<FileSpec> module_file_specs, const llvm::Triple &triple); diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp index c038ff7..f712406 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp @@ -267,12 +267,12 @@ GDBRemoteCommunicationServerCommon::Handle_qHostInfo( } #endif - if (llvm::Optional<std::string> s = HostInfo::GetOSBuildString()) { + if (std::optional<std::string> s = HostInfo::GetOSBuildString()) { response.PutCString("os_build:"); response.PutStringAsRawHex8(*s); response.PutChar(';'); } - if (llvm::Optional<std::string> s = HostInfo::GetOSKernelDescription()) { + if (std::optional<std::string> s = HostInfo::GetOSKernelDescription()) { response.PutCString("os_kernel:"); response.PutStringAsRawHex8(*s); response.PutChar(';'); @@ -433,7 +433,7 @@ GDBRemoteCommunicationServerCommon::Handle_qUserName( packet.SetFilePos(::strlen("qUserName:")); uint32_t uid = packet.GetU32(UINT32_MAX); if (uid != UINT32_MAX) { - if (llvm::Optional<llvm::StringRef> name = + if (std::optional<llvm::StringRef> name = HostInfo::GetUserIDResolver().GetUserName(uid)) { StreamString response; response.PutStringAsRawHex8(*name); @@ -453,7 +453,7 @@ GDBRemoteCommunicationServerCommon::Handle_qGroupName( packet.SetFilePos(::strlen("qGroupName:")); uint32_t gid = packet.GetU32(UINT32_MAX); if (gid != UINT32_MAX) { - if (llvm::Optional<llvm::StringRef> name = + if (std::optional<llvm::StringRef> name = HostInfo::GetUserIDResolver().GetGroupName(gid)) { StreamString response; response.PutStringAsRawHex8(*name); diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp index 03a2e73..30d6d78 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -639,7 +639,7 @@ static void WriteRegisterValueInHexFixedWidth( } } -static llvm::Optional<json::Object> +static std::optional<json::Object> GetRegistersAsJSON(NativeThreadProtocol &thread) { Log *log = GetLog(LLDBLog::Thread); @@ -753,7 +753,7 @@ GetJSONThreadsInfo(NativeProcessProtocol &process, bool abridged) { json::Object thread_obj; if (!abridged) { - if (llvm::Optional<json::Object> registers = GetRegistersAsJSON(thread)) + if (std::optional<json::Object> registers = GetRegistersAsJSON(thread)) thread_obj.try_emplace("registers", std::move(*registers)); } @@ -4279,7 +4279,7 @@ std::string lldb_private::process_gdb_remote::LLGSArgToURL(llvm::StringRef url_arg, bool reverse_connect) { // Try parsing the argument as URL. - if (llvm::Optional<URI> url = URI::Parse(url_arg)) { + if (std::optional<URI> url = URI::Parse(url_arg)) { if (reverse_connect) return url_arg.str(); diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp index e4187ef..bdb6480 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp @@ -159,7 +159,7 @@ GDBRemoteCommunicationServerPlatform::~GDBRemoteCommunicationServerPlatform() = Status GDBRemoteCommunicationServerPlatform::LaunchGDBServer( const lldb_private::Args &args, std::string hostname, lldb::pid_t &pid, - llvm::Optional<uint16_t> &port, std::string &socket_name) { + std::optional<uint16_t> &port, std::string &socket_name) { if (!port) { llvm::Expected<uint16_t> available_port = m_port_map.GetNextAvailablePort(); if (available_port) @@ -198,7 +198,7 @@ Status GDBRemoteCommunicationServerPlatform::LaunchGDBServer( uint16_t *port_ptr = &*port; if (m_socket_protocol == Socket::ProtocolTcp) { std::string platform_uri = GetConnection()->GetURI(); - llvm::Optional<URI> parsed_uri = URI::Parse(platform_uri); + std::optional<URI> parsed_uri = URI::Parse(platform_uri); url << '[' << parsed_uri->hostname.str() << "]:" << *port; } else { socket_name = GetDomainSocketPath("gdbserver").GetPath(); @@ -237,7 +237,7 @@ GDBRemoteCommunicationServerPlatform::Handle_qLaunchGDBServer( packet.SetFilePos(::strlen("qLaunchGDBServer;")); llvm::StringRef name; llvm::StringRef value; - llvm::Optional<uint16_t> port; + std::optional<uint16_t> port; while (packet.GetNameColonValue(name, value)) { if (name.equals("host")) hostname = std::string(value); diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h index 397d733..97805f2 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h @@ -91,7 +91,7 @@ public: // Set port if you want to use a specific port number. // Otherwise port will be set to the port that was chosen for you. Status LaunchGDBServer(const lldb_private::Args &args, std::string hostname, - lldb::pid_t &pid, llvm::Optional<uint16_t> &port, + lldb::pid_t &pid, std::optional<uint16_t> &port, std::string &socket_name); void SetPendingGdbServer(lldb::pid_t pid, uint16_t port, diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 3c8fb93..2f3a81f 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -1033,7 +1033,7 @@ void ProcessGDBRemote::MaybeLoadExecutableModule() { if (!module_sp) return; - llvm::Optional<QOffsets> offsets = m_gdb_comm.GetQOffsets(); + std::optional<QOffsets> offsets = m_gdb_comm.GetQOffsets(); if (!offsets) return; diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h index 4b46428..aae6432 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h @@ -254,7 +254,7 @@ protected: GDBRemoteCommunicationClient m_gdb_comm; std::atomic<lldb::pid_t> m_debugserver_pid; - llvm::Optional<StringExtractorGDBRemote> m_last_stop_packet; + std::optional<StringExtractorGDBRemote> m_last_stop_packet; std::recursive_mutex m_last_stop_packet_mutex; GDBRemoteDynamicRegisterInfoSP m_register_info_sp; |