diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:09:23 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:09:23 +0000 |
commit | f73363f1dd94996356cefbf24388f561891acf0b (patch) | |
tree | e3c31248bdb36eaec5fd833490d4278162dba2a0 /source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp | |
parent | 160ee69dd7ae18978f4068116777639ea98dc951 (diff) |
Notes
Diffstat (limited to 'source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp')
-rw-r--r-- | source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp | 59 |
1 files changed, 39 insertions, 20 deletions
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp index 4d4a4f8c5c7a8..4e20b56fb111b 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp +++ b/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp @@ -109,16 +109,14 @@ StateType GDBRemoteClientBase::SendContinuePacketAndWaitForResponse( const bool should_stop = ShouldStop(signals, response); response.SetFilePos(0); - // The packet we should resume with. In the future - // we should check our thread list and "do the right thing" - // for new threads that show up while we stop and run async - // packets. Setting the packet to 'c' to continue all threads - // is the right thing to do 99.99% of the time because if a - // thread was single stepping, and we sent an interrupt, we - // will notice above that we didn't stop due to an interrupt - // but stopped due to stepping and we would _not_ continue. - // This packet may get modified by the async actions (e.g. to send a - // signal). + // The packet we should resume with. In the future we should check our + // thread list and "do the right thing" for new threads that show up + // while we stop and run async packets. Setting the packet to 'c' to + // continue all threads is the right thing to do 99.99% of the time + // because if a thread was single stepping, and we sent an interrupt, we + // will notice above that we didn't stop due to an interrupt but stopped + // due to stepping and we would _not_ continue. This packet may get + // modified by the async actions (e.g. to send a signal). m_continue_packet = 'c'; cont_lock.unlock(); @@ -177,6 +175,30 @@ GDBRemoteClientBase::SendPacketAndWaitForResponse( } GDBRemoteCommunication::PacketResult +GDBRemoteClientBase::SendPacketAndReceiveResponseWithOutputSupport( + llvm::StringRef payload, StringExtractorGDBRemote &response, + bool send_async, + llvm::function_ref<void(llvm::StringRef)> output_callback) { + Lock lock(*this, send_async); + if (!lock) { + if (Log *log = + ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)) + log->Printf("GDBRemoteClientBase::%s failed to get mutex, not sending " + "packet '%.*s' (send_async=%d)", + __FUNCTION__, int(payload.size()), payload.data(), + send_async); + return PacketResult::ErrorSendFailed; + } + + PacketResult packet_result = SendPacketNoLock(payload); + if (packet_result != PacketResult::Success) + return packet_result; + + return ReadPacketWithOutputSupport(response, GetPacketTimeout(), true, + output_callback); +} + +GDBRemoteCommunication::PacketResult GDBRemoteClientBase::SendPacketAndWaitForResponseNoLock( llvm::StringRef payload, StringExtractorGDBRemote &response) { PacketResult packet_result = SendPacketNoLock(payload); @@ -239,19 +261,16 @@ bool GDBRemoteClientBase::ShouldStop(const UnixSignals &signals, if (m_async_count == 0) return true; // We were not interrupted. The process stopped on its own. - // Older debugserver stubs (before April 2016) can return two - // stop-reply packets in response to a ^C packet. - // Additionally, all debugservers still return two stop replies if - // the inferior stops due to some other reason before the remote - // stub manages to interrupt it. We need to wait for this - // additional packet to make sure the packet sequence does not get - // skewed. + // Older debugserver stubs (before April 2016) can return two stop-reply + // packets in response to a ^C packet. Additionally, all debugservers still + // return two stop replies if the inferior stops due to some other reason + // before the remote stub manages to interrupt it. We need to wait for this + // additional packet to make sure the packet sequence does not get skewed. StringExtractorGDBRemote extra_stop_reply_packet; ReadPacket(extra_stop_reply_packet, milliseconds(100), false); - // Interrupting is typically done using SIGSTOP or SIGINT, so if - // the process stops with some other signal, we definitely want to - // stop. + // Interrupting is typically done using SIGSTOP or SIGINT, so if the process + // stops with some other signal, we definitely want to stop. const uint8_t signo = response.GetHexU8(UINT8_MAX); if (signo != signals.GetSignalNumberFromName("SIGSTOP") && signo != signals.GetSignalNumberFromName("SIGINT")) |