[Lldb-commits] [lldb] r205337 - Implement ProcessMonitor::Kill for Linux
Ed Maste
emaste at freebsd.org
Tue Apr 1 11:14:06 PDT 2014
Author: emaste
Date: Tue Apr 1 13:14:06 2014
New Revision: 205337
URL: http://llvm.org/viewvc/llvm-project?rev=205337&view=rev
Log:
Implement ProcessMonitor::Kill for Linux
On FreeBSD ptrace(PT_KILL) is used to terminate the traced process
(as if PT_CONTINUE had been used with SIGKILL as the signal to be
delivered), and is the desired behaviour for ProcessPOSIX::DoDestroy.
On Linux, after ptrace(PTRACE_KILL) the traced process still exists
and can be interrogated. It is only upon resume that it exits as though
it received SIGKILL.
As the Linux PTRACE_KILL behaviour is not used by LLDB, rename
BringProcessIntoLimbo to Kill, and change the implementation to simply
call kill() instead of using ptrace.
Thanks to Todd F for testing (Ubuntu 12.04, gcc 4.8.2).
Sponsored by: DARPA, AFRL
Differential Revision: http://llvm-reviews.chandlerc.com/D3159
Modified:
lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp
lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h
lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp?rev=205337&r1=205336&r2=205337&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp Tue Apr 1 13:14:06 2014
@@ -904,31 +904,6 @@ EventMessageOperation::Execute(ProcessMo
}
//------------------------------------------------------------------------------
-/// @class KillOperation
-/// @brief Implements ProcessMonitor::BringProcessIntoLimbo.
-class KillOperation : public Operation
-{
-public:
- KillOperation(bool &result) : m_result(result) { }
-
- void Execute(ProcessMonitor *monitor);
-
-private:
- bool &m_result;
-};
-
-void
-KillOperation::Execute(ProcessMonitor *monitor)
-{
- lldb::pid_t pid = monitor->GetPID();
-
- if (PTRACE(PTRACE_KILL, pid, NULL, NULL, 0))
- m_result = false;
- else
- m_result = true;
-}
-
-//------------------------------------------------------------------------------
/// @class DetachOperation
/// @brief Implements ProcessMonitor::Detach.
class DetachOperation : public Operation
@@ -2229,12 +2204,9 @@ ProcessMonitor::SingleStep(lldb::tid_t t
}
bool
-ProcessMonitor::BringProcessIntoLimbo()
+ProcessMonitor::Kill()
{
- bool result;
- KillOperation op(result);
- DoOperation(&op);
- return result;
+ return kill(GetPID(), SIGKILL) == 0;
}
bool
Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h?rev=205337&r1=205336&r2=205337&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h (original)
+++ lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h Tue Apr 1 13:14:06 2014
@@ -172,11 +172,9 @@ public:
bool
SingleStep(lldb::tid_t tid, uint32_t signo);
- /// Sends the inferior process a PTRACE_KILL signal. The inferior will
- /// still exists and can be interrogated. Once resumed it will exit as
- /// though it received a SIGKILL.
+ /// Terminate the traced process.
bool
- BringProcessIntoLimbo();
+ Kill();
lldb_private::Error
Detach(lldb::tid_t tid);
Modified: lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp?rev=205337&r1=205336&r2=205337&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp Tue Apr 1 13:14:06 2014
@@ -339,11 +339,7 @@ ProcessPOSIX::DoDestroy()
{
assert(m_monitor);
m_exit_now = true;
-#ifdef __linux__
- if ((m_monitor == NULL || kill(m_monitor->GetPID(), SIGKILL)) && error.Success())
-#else
if (!m_monitor->Kill())
-#endif
{
error.SetErrorToErrno();
return error;
More information about the lldb-commits
mailing list