diff options
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp')
-rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp | 107 |
1 files changed, 41 insertions, 66 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index 8cfe331ee16..d08b939aa95 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -518,27 +518,21 @@ GDBRemoteCommunicationClient::GetRemoteQSupported () } } -void -GDBRemoteCommunicationClient::ComputeThreadSuffixSupport() +bool +GDBRemoteCommunicationClient::GetThreadSuffixSupported () { - if (m_supports_thread_suffix != eLazyBoolCalculate) - return; - - StringExtractorGDBRemote response; - m_supports_thread_suffix = eLazyBoolNo; - if (SendPacketAndWaitForResponse("QThreadSuffixSupported", response, false) == PacketResult::Success) + if (m_supports_thread_suffix == eLazyBoolCalculate) { - if (response.IsOKResponse()) - m_supports_thread_suffix = eLazyBoolYes; + StringExtractorGDBRemote response; + m_supports_thread_suffix = eLazyBoolNo; + if (SendPacketAndWaitForResponse("QThreadSuffixSupported", response, false) == PacketResult::Success) + { + if (response.IsOKResponse()) + m_supports_thread_suffix = eLazyBoolYes; + } } + return m_supports_thread_suffix; } - -bool -GDBRemoteCommunicationClient::GetThreadSuffixSupported() -{ - return m_supports_thread_suffix == eLazyBoolYes; -} - bool GDBRemoteCommunicationClient::GetVContSupported (char flavor) { @@ -600,17 +594,26 @@ GDBRemoteCommunicationClient::GetVContSupported (char flavor) GDBRemoteCommunication::PacketResult GDBRemoteCommunicationClient::SendThreadSpecificPacketAndWaitForResponse(lldb::tid_t tid, StreamString &&payload, StringExtractorGDBRemote &response, - const Lock &lock) + bool send_async) { + Lock lock(*this, send_async); + if (!lock) + { + if (Log *log = ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_PROCESS | GDBR_LOG_PACKETS)) + log->Printf("GDBRemoteCommunicationClient::%s: Didn't get sequence mutex for %s packet.", __FUNCTION__, + payload.GetString().c_str()); + return PacketResult::ErrorNoSequenceLock; + } + if (GetThreadSuffixSupported()) payload.Printf(";thread:%4.4" PRIx64 ";", tid); else { - if (!SetCurrentThread(tid, lock)) + if (!SetCurrentThread(tid)) return PacketResult::ErrorSendFailed; } - return SendPacketAndWaitForResponse(payload.GetString(), response, lock); + return SendPacketAndWaitForResponseNoLock(payload.GetString(), response); } // Check if the target supports 'p' packet. It sends out a 'p' @@ -623,20 +626,11 @@ GDBRemoteCommunicationClient::GetpPacketSupported (lldb::tid_t tid) { if (m_supports_p == eLazyBoolCalculate) { - Lock lock(*this, false); - if (!lock) - { - Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_PROCESS | GDBR_LOG_PACKETS)); - if (log) - log->Printf("GDBRemoteCommunicationClient::%s failed to get sequence mutex", __FUNCTION__); - return false; - } - m_supports_p = eLazyBoolNo; StreamString payload; payload.PutCString("p0"); StringExtractorGDBRemote response; - if (SendThreadSpecificPacketAndWaitForResponse(tid, std::move(payload), response, lock) == + if (SendThreadSpecificPacketAndWaitForResponse(tid, std::move(payload), response, false) == PacketResult::Success && response.IsNormalResponse()) { @@ -774,7 +768,7 @@ GDBRemoteCommunicationClient::SendPacketsAndConcatenateResponses // Construct payload char sizeDescriptor[128]; snprintf(sizeDescriptor, sizeof(sizeDescriptor), "%x,%x", offset, response_size); - PacketResult result = SendPacketAndWaitForResponse(payload_prefix_str + sizeDescriptor, this_response, lock); + PacketResult result = SendPacketAndWaitForResponseNoLock(payload_prefix_str + sizeDescriptor, this_response); if (result != PacketResult::Success) return result; @@ -2769,7 +2763,7 @@ GDBRemoteCommunicationClient::KillSpawnedProcess (lldb::pid_t pid) } bool -GDBRemoteCommunicationClient::SetCurrentThread(uint64_t tid, const Lock &lock) +GDBRemoteCommunicationClient::SetCurrentThread (uint64_t tid) { if (m_curr_tid == tid) return true; @@ -2782,7 +2776,7 @@ GDBRemoteCommunicationClient::SetCurrentThread(uint64_t tid, const Lock &lock) packet_len = ::snprintf (packet, sizeof(packet), "Hg%" PRIx64, tid); assert (packet_len + 1 < (int)sizeof(packet)); StringExtractorGDBRemote response; - if (SendPacketAndWaitForResponse(llvm::StringRef(packet, packet_len), response, lock) == PacketResult::Success) + if (SendPacketAndWaitForResponse(packet, packet_len, response, false) == PacketResult::Success) { if (response.IsOKResponse()) { @@ -2943,9 +2937,9 @@ GDBRemoteCommunicationClient::GetCurrentThreadIDs (std::vector<lldb::tid_t> &thr StringExtractorGDBRemote response; PacketResult packet_result; - for (packet_result = SendPacketAndWaitForResponse("qfThreadInfo", response, lock); + for (packet_result = SendPacketAndWaitForResponseNoLock("qfThreadInfo", response); packet_result == PacketResult::Success && response.IsNormalResponse(); - packet_result = SendPacketAndWaitForResponse("qsThreadInfo", response, lock)) + packet_result = SendPacketAndWaitForResponseNoLock("qsThreadInfo", response)) { char ch = response.GetChar(); if (ch == 'l') @@ -3476,12 +3470,12 @@ GDBRemoteCommunicationClient::AvoidGPackets (ProcessGDBRemote *process) } DataBufferSP -GDBRemoteCommunicationClient::ReadRegister(lldb::tid_t tid, uint32_t reg, const Lock &lock) +GDBRemoteCommunicationClient::ReadRegister(lldb::tid_t tid, uint32_t reg) { StreamString payload; payload.Printf("p%x", reg); StringExtractorGDBRemote response; - if (SendThreadSpecificPacketAndWaitForResponse(tid, std::move(payload), response, lock) != PacketResult::Success || + if (SendThreadSpecificPacketAndWaitForResponse(tid, std::move(payload), response, false) != PacketResult::Success || !response.IsNormalResponse()) return nullptr; @@ -3491,12 +3485,12 @@ GDBRemoteCommunicationClient::ReadRegister(lldb::tid_t tid, uint32_t reg, const } DataBufferSP -GDBRemoteCommunicationClient::ReadAllRegisters(lldb::tid_t tid, const Lock &lock) +GDBRemoteCommunicationClient::ReadAllRegisters(lldb::tid_t tid) { StreamString payload; payload.PutChar('g'); StringExtractorGDBRemote response; - if (SendThreadSpecificPacketAndWaitForResponse(tid, std::move(payload), response, lock) != PacketResult::Success || + if (SendThreadSpecificPacketAndWaitForResponse(tid, std::move(payload), response, false) != PacketResult::Success || !response.IsNormalResponse()) return nullptr; @@ -3506,26 +3500,25 @@ GDBRemoteCommunicationClient::ReadAllRegisters(lldb::tid_t tid, const Lock &lock } bool -GDBRemoteCommunicationClient::WriteRegister(lldb::tid_t tid, uint32_t reg_num, llvm::ArrayRef<uint8_t> data, - const Lock &lock) +GDBRemoteCommunicationClient::WriteRegister(lldb::tid_t tid, uint32_t reg_num, llvm::ArrayRef<uint8_t> data) { StreamString payload; payload.Printf("P%x=", reg_num); payload.PutBytesAsRawHex8(data.data(), data.size(), endian::InlHostByteOrder(), endian::InlHostByteOrder()); StringExtractorGDBRemote response; - return SendThreadSpecificPacketAndWaitForResponse(tid, std::move(payload), response, lock) == + return SendThreadSpecificPacketAndWaitForResponse(tid, std::move(payload), response, false) == PacketResult::Success && response.IsOKResponse(); } bool -GDBRemoteCommunicationClient::WriteAllRegisters(lldb::tid_t tid, llvm::ArrayRef<uint8_t> data, const Lock &lock) +GDBRemoteCommunicationClient::WriteAllRegisters(lldb::tid_t tid, llvm::ArrayRef<uint8_t> data) { StreamString payload; payload.PutChar('G'); payload.PutBytesAsRawHex8(data.data(), data.size(), endian::InlHostByteOrder(), endian::InlHostByteOrder()); StringExtractorGDBRemote response; - return SendThreadSpecificPacketAndWaitForResponse(tid, std::move(payload), response, lock) == + return SendThreadSpecificPacketAndWaitForResponse(tid, std::move(payload), response, false) == PacketResult::Success && response.IsOKResponse(); } @@ -3536,21 +3529,12 @@ GDBRemoteCommunicationClient::SaveRegisterState (lldb::tid_t tid, uint32_t &save save_id = 0; // Set to invalid save ID if (m_supports_QSaveRegisterState == eLazyBoolNo) return false; - - Lock lock(*this, false); - if (!lock) - { - Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_PROCESS | GDBR_LOG_PACKETS)); - if (log) - log->Printf("GDBRemoteCommunicationClient::%s failed to get sequence mutex", __FUNCTION__); - return false; - } - + m_supports_QSaveRegisterState = eLazyBoolYes; StreamString payload; payload.PutCString("QSaveRegisterState"); StringExtractorGDBRemote response; - if (SendThreadSpecificPacketAndWaitForResponse(tid, std::move(payload), response, lock) != PacketResult::Success) + if (SendThreadSpecificPacketAndWaitForResponse(tid, std::move(payload), response, false) != PacketResult::Success) return false; if (response.IsUnsupportedResponse()) @@ -3573,19 +3557,10 @@ GDBRemoteCommunicationClient::RestoreRegisterState (lldb::tid_t tid, uint32_t sa if (m_supports_QSaveRegisterState == eLazyBoolNo) return false; - Lock lock(*this, false); - if (!lock) - { - Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_PROCESS | GDBR_LOG_PACKETS)); - if (log) - log->Printf("GDBRemoteCommunicationClient::%s failed to get sequence mutex", __FUNCTION__); - return false; - } - StreamString payload; payload.Printf("QRestoreRegisterState:%u", save_id); StringExtractorGDBRemote response; - if (SendThreadSpecificPacketAndWaitForResponse(tid, std::move(payload), response, lock) != PacketResult::Success) + if (SendThreadSpecificPacketAndWaitForResponse(tid, std::move(payload), response, false) != PacketResult::Success) return false; if (response.IsOKResponse()) @@ -3812,7 +3787,7 @@ GDBRemoteCommunicationClient::ServeSymbolLookups(lldb_private::Process *process) StreamString packet; packet.PutCString ("qSymbol::"); StringExtractorGDBRemote response; - while (SendPacketAndWaitForResponse(packet.GetString(), response, lock) == PacketResult::Success) + while (SendPacketAndWaitForResponseNoLock(packet.GetString(), response) == PacketResult::Success) { if (response.IsOKResponse()) { |