summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Maste <emaste@freebsd.org>2014-04-01 18:14:06 +0000
committerEd Maste <emaste@freebsd.org>2014-04-01 18:14:06 +0000
commit4e0999bc22656eb8e46775114a174ba4388e8ee6 (patch)
treecc8a4d6d9963431ecaa75ee2d27ff0894e25ea12
parente407ae984620f1a13bfe19a71d35123f27460b62 (diff)
downloadbcm5719-llvm-4e0999bc22656eb8e46775114a174ba4388e8ee6.tar.gz
bcm5719-llvm-4e0999bc22656eb8e46775114a174ba4388e8ee6.zip
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 llvm-svn: 205337
-rw-r--r--lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp32
-rw-r--r--lldb/source/Plugins/Process/Linux/ProcessMonitor.h6
-rw-r--r--lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp4
3 files changed, 4 insertions, 38 deletions
diff --git a/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp b/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp
index 3dec6de7247..198a1eb595c 100644
--- a/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp
+++ b/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp
@@ -904,31 +904,6 @@ EventMessageOperation::Execute(ProcessMonitor *monitor)
}
//------------------------------------------------------------------------------
-/// @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 tid, uint32_t signo)
}
bool
-ProcessMonitor::BringProcessIntoLimbo()
+ProcessMonitor::Kill()
{
- bool result;
- KillOperation op(result);
- DoOperation(&op);
- return result;
+ return kill(GetPID(), SIGKILL) == 0;
}
bool
diff --git a/lldb/source/Plugins/Process/Linux/ProcessMonitor.h b/lldb/source/Plugins/Process/Linux/ProcessMonitor.h
index a087140f407..3e289ff1337 100644
--- a/lldb/source/Plugins/Process/Linux/ProcessMonitor.h
+++ b/lldb/source/Plugins/Process/Linux/ProcessMonitor.h
@@ -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);
diff --git a/lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp b/lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
index 571818134d4..47e11353714 100644
--- a/lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
+++ b/lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
@@ -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;
OpenPOWER on IntegriCloud