mgorny created this revision.
mgorny added reviewers: labath, emaste, krytarowski, jingham.
Herald added a subscriber: arichardson.
Herald added a project: All.
mgorny requested review of this revision.
Refactor GDBRemoteCommunicationServerLLGS::SendStopReasonForState()
to accept process as an argument rather than hardcoding
m_current_process, in order to make it work correctly for multiprocess
scenarios.
Sponsored by: The FreeBSD Foundation
https://reviews.llvm.org/D127497
Files:
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
@@ -116,7 +116,8 @@
PacketResult SendStopReplyPacketForThread(NativeProcessProtocol &process,
lldb::tid_t tid);
- PacketResult SendStopReasonForState(lldb::StateType process_state);
+ PacketResult SendStopReasonForState(NativeProcessProtocol &process,
+ lldb::StateType process_state);
PacketResult Handle_k(StringExtractorGDBRemote &packet);
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -993,7 +993,8 @@
Log *log = GetLog(LLDBLog::Process);
LLDB_LOGF(log, "GDBRemoteCommunicationServerLLGS::%s called", __FUNCTION__);
- PacketResult result = SendStopReasonForState(StateType::eStateExited);
+ PacketResult result =
+ SendStopReasonForState(*process, StateType::eStateExited);
if (result != PacketResult::Success) {
LLDB_LOGF(log,
"GDBRemoteCommunicationServerLLGS::%s failed to send stop "
@@ -1025,7 +1026,8 @@
break;
default:
// In all other cases, send the stop reason.
- PacketResult result = SendStopReasonForState(StateType::eStateStopped);
+ PacketResult result =
+ SendStopReasonForState(*process, StateType::eStateStopped);
if (result != PacketResult::Success) {
LLDB_LOGF(log,
"GDBRemoteCommunicationServerLLGS::%s failed to send stop "
@@ -1696,12 +1698,13 @@
if (!m_current_process)
return SendErrorResponse(02);
- return SendStopReasonForState(m_current_process->GetState());
+ return SendStopReasonForState(*m_current_process,
+ m_current_process->GetState());
}
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerLLGS::SendStopReasonForState(
- lldb::StateType process_state) {
+ NativeProcessProtocol &process, lldb::StateType process_state) {
Log *log = GetLog(LLDBLog::Process);
switch (process_state) {
@@ -1717,22 +1720,21 @@
case eStateSuspended:
case eStateStopped:
case eStateCrashed: {
- assert(m_current_process != nullptr);
- lldb::tid_t tid = m_current_process->GetCurrentThreadID();
+ lldb::tid_t tid = process.GetCurrentThreadID();
// Make sure we set the current thread so g and p packets return the data
// the gdb will expect.
SetCurrentThreadID(tid);
- return SendStopReplyPacketForThread(*m_current_process, tid);
+ return SendStopReplyPacketForThread(process, tid);
}
case eStateInvalid:
case eStateUnloaded:
case eStateExited:
- return SendWResponse(m_current_process);
+ return SendWResponse(&process);
default:
LLDB_LOG(log, "pid {0}, current state reporting not handled: {1}",
- m_current_process->GetID(), process_state);
+ process.GetID(), process_state);
break;
}
@@ -3182,7 +3184,9 @@
}
// Notify we attached by sending a stop packet.
- return SendStopReasonForState(m_current_process->GetState());
+ assert(m_current_process);
+ return SendStopReasonForState(*m_current_process,
+ m_current_process->GetState());
}
GDBRemoteCommunication::PacketResult
@@ -3212,7 +3216,9 @@
}
// Notify we attached by sending a stop packet.
- return SendStopReasonForState(m_current_process->GetState());
+ assert(m_current_process);
+ return SendStopReasonForState(*m_current_process,
+ m_current_process->GetState());
}
GDBRemoteCommunication::PacketResult
@@ -3248,7 +3254,9 @@
}
// Notify we attached by sending a stop packet.
- return SendStopReasonForState(m_current_process->GetState());
+ assert(m_current_process);
+ return SendStopReasonForState(*m_current_process,
+ m_current_process->GetState());
}
GDBRemoteCommunication::PacketResult
@@ -3276,8 +3284,11 @@
m_process_launch_info.GetExecutableFile().SetFile(
m_process_launch_info.GetArguments()[0].ref(), FileSpec::Style::native);
m_process_launch_error = LaunchProcess();
- if (m_process_launch_error.Success())
- return SendStopReasonForState(m_current_process->GetState());
+ if (m_process_launch_error.Success()) {
+ assert(m_current_process);
+ return SendStopReasonForState(*m_current_process,
+ m_current_process->GetState());
+ }
LLDB_LOG(log, "failed to launch exe: {0}", m_process_launch_error);
}
return SendErrorResponse(8);
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits