@@ -768,19 +768,13 @@ GetJSONThreadsInfo(NativeProcessProtocol &process, bool abridged) {
768768
769769GDBRemoteCommunication::PacketResult
770770GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread (
771- lldb::tid_t tid) {
771+ NativeProcessProtocol &process, lldb::tid_t tid) {
772772 Log *log = GetLog (LLDBLog::Process | LLDBLog::Thread);
773773
774- // Ensure we have a debugged process.
775- if (!m_current_process ||
776- (m_current_process->GetID () == LLDB_INVALID_PROCESS_ID ))
777- return SendErrorResponse (50 );
778-
779- LLDB_LOG (log, " preparing packet for pid {0} tid {1}" ,
780- m_current_process->GetID (), tid);
774+ LLDB_LOG (log, " preparing packet for pid {0} tid {1}" , process.GetID (), tid);
781775
782776 // Ensure we can get info on the given thread.
783- NativeThreadProtocol *thread = m_current_process-> GetThreadByID (tid);
777+ NativeThreadProtocol *thread = process. GetThreadByID (tid);
784778 if (!thread)
785779 return SendErrorResponse (51 );
786780
@@ -803,7 +797,7 @@ GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread(
803797 LLDB_LOG (
804798 log,
805799 " pid {0}, tid {1}, got signal signo = {2}, reason = {3}, exc_type = {4}" ,
806- m_current_process-> GetID (), tid, signum, int (tid_stop_info.reason ),
800+ process. GetID (), tid, signum, int (tid_stop_info.reason ),
807801 tid_stop_info.details .exception .type );
808802
809803 // Print the signal number.
@@ -813,7 +807,7 @@ GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread(
813807 response.PutCString (" thread:" );
814808 if (bool (m_extensions_supported &
815809 NativeProcessProtocol::Extension::multiprocess))
816- response.Format (" p{0:x-}." , m_current_process-> GetID ());
810+ response.Format (" p{0:x-}." , process. GetID ());
817811 response.Format (" {0:x-};" , tid);
818812
819813 // Include the thread name if there is one.
@@ -845,9 +839,9 @@ GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread(
845839
846840 uint32_t thread_index = 0 ;
847841 NativeThreadProtocol *listed_thread;
848- for (listed_thread = m_current_process-> GetThreadAtIndex (thread_index);
849- listed_thread; ++thread_index,
850- listed_thread = m_current_process-> GetThreadAtIndex (thread_index)) {
842+ for (listed_thread = process. GetThreadAtIndex (thread_index); listed_thread ;
843+ ++thread_index,
844+ listed_thread = process. GetThreadAtIndex (thread_index)) {
851845 if (thread_index > 0 )
852846 response.PutChar (' ,' );
853847 response.Printf (" %" PRIx64, listed_thread->GetID ());
@@ -872,15 +866,15 @@ GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread(
872866 } else {
873867 LLDB_LOG_ERROR (log, threads_info.takeError (),
874868 " failed to prepare a jstopinfo field for pid {1}: {0}" ,
875- m_current_process-> GetID ());
869+ process. GetID ());
876870 }
877871 }
878872
879873 uint32_t i = 0 ;
880874 response.PutCString (" thread-pcs" );
881875 char delimiter = ' :' ;
882876 for (NativeThreadProtocol *thread;
883- (thread = m_current_process-> GetThreadAtIndex (i)) != nullptr ; ++i) {
877+ (thread = process. GetThreadAtIndex (i)) != nullptr ; ++i) {
884878 NativeRegisterContext& reg_ctx = thread->GetRegisterContext ();
885879
886880 uint32_t reg_to_read = reg_ctx.ConvertRegisterKindToRegisterNumber (
@@ -1718,7 +1712,7 @@ GDBRemoteCommunicationServerLLGS::SendStopReasonForState(
17181712 // Make sure we set the current thread so g and p packets return the data
17191713 // the gdb will expect.
17201714 SetCurrentThreadID (tid);
1721- return SendStopReplyPacketForThread (tid);
1715+ return SendStopReplyPacketForThread (*m_current_process, tid);
17221716 }
17231717
17241718 case eStateInvalid:
@@ -3331,6 +3325,10 @@ GDBRemoteCommunicationServerLLGS::Handle_qThreadStopInfo(
33313325 StringExtractorGDBRemote &packet) {
33323326 Log *log = GetLog (LLDBLog::Thread);
33333327
3328+ if (!m_current_process ||
3329+ (m_current_process->GetID () == LLDB_INVALID_PROCESS_ID ))
3330+ return SendErrorResponse (50 );
3331+
33343332 packet.SetFilePos (strlen (" qThreadStopInfo" ));
33353333 const lldb::tid_t tid = packet.GetHexMaxU64 (false , LLDB_INVALID_THREAD_ID );
33363334 if (tid == LLDB_INVALID_THREAD_ID ) {
@@ -3340,7 +3338,7 @@ GDBRemoteCommunicationServerLLGS::Handle_qThreadStopInfo(
33403338 __FUNCTION__, packet.GetStringRef ().data ());
33413339 return SendErrorResponse (0x15 );
33423340 }
3343- return SendStopReplyPacketForThread (tid);
3341+ return SendStopReplyPacketForThread (*m_current_process, tid);
33443342}
33453343
33463344GDBRemoteCommunication::PacketResult
0 commit comments