labath created this revision.
labath added reviewers: chaoren, ovyalov.
labath added a subscriber: lldb-commits.
Handle_k was printing an error when killing a process because
KillSpawnedProcess was expecting to
be asynchronously notified of the process death, which no longer works, since
we don't wait for
the process on a separate thread. However, the whole usage of
KillSpawnedProcess is dubious here,
since it tries to be nice and terminate the process first with SIGTERM, which
will not have the
intended effect on a ptraced process. I replace this code with a call to
NativeProcessProtocol::Kill, which does not suffer from these problems.
http://reviews.llvm.org/D11520
Files:
source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
===================================================================
--- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -1142,26 +1142,21 @@
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerLLGS::Handle_k (StringExtractorGDBRemote &packet)
{
- // shutdown all spawned processes
- std::set<lldb::pid_t> spawned_pids_copy;
+ Log *log (GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
- // copy pids
- {
- Mutex::Locker locker (m_spawned_pids_mutex);
- spawned_pids_copy.insert (m_spawned_pids.begin (), m_spawned_pids.end
());
- }
+ StopSTDIOForwarding();
- // nuke the spawned processes
- for (auto it = spawned_pids_copy.begin (); it != spawned_pids_copy.end ();
++it)
+ if (! m_debugged_process_sp)
{
- lldb::pid_t spawned_pid = *it;
- if (!KillSpawnedProcess (spawned_pid))
- {
- fprintf (stderr, "%s: failed to kill spawned pid %" PRIu64 ",
ignoring.\n", __FUNCTION__, spawned_pid);
- }
+ if (log)
+ log->Printf("GDBRemoteCommunicationServerLLGS::%s No debugged
process found.", __FUNCTION__);
+ return PacketResult::Success;
}
- StopSTDIOForwarding();
+ Error error = m_debugged_process_sp->Kill();
+ if (error.Fail() && log)
+ log->Printf("GDBRemoteCommunicationServerLLGS::%s Failed to kill
debugged process %" PRIu64 ".",
+ __FUNCTION__, m_debugged_process_sp->GetID());
// No OK response for kill packet.
// return SendOKResponse ();
Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
===================================================================
--- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -1142,26 +1142,21 @@
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerLLGS::Handle_k (StringExtractorGDBRemote &packet)
{
- // shutdown all spawned processes
- std::set<lldb::pid_t> spawned_pids_copy;
+ Log *log (GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
- // copy pids
- {
- Mutex::Locker locker (m_spawned_pids_mutex);
- spawned_pids_copy.insert (m_spawned_pids.begin (), m_spawned_pids.end ());
- }
+ StopSTDIOForwarding();
- // nuke the spawned processes
- for (auto it = spawned_pids_copy.begin (); it != spawned_pids_copy.end (); ++it)
+ if (! m_debugged_process_sp)
{
- lldb::pid_t spawned_pid = *it;
- if (!KillSpawnedProcess (spawned_pid))
- {
- fprintf (stderr, "%s: failed to kill spawned pid %" PRIu64 ", ignoring.\n", __FUNCTION__, spawned_pid);
- }
+ if (log)
+ log->Printf("GDBRemoteCommunicationServerLLGS::%s No debugged process found.", __FUNCTION__);
+ return PacketResult::Success;
}
- StopSTDIOForwarding();
+ Error error = m_debugged_process_sp->Kill();
+ if (error.Fail() && log)
+ log->Printf("GDBRemoteCommunicationServerLLGS::%s Failed to kill debugged process %" PRIu64 ".",
+ __FUNCTION__, m_debugged_process_sp->GetID());
// No OK response for kill packet.
// return SendOKResponse ();
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits