summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2015-05-21 08:32:18 +0000
committerPavel Labath <labath@google.com>2015-05-21 08:32:18 +0000
commit39036ac31d1571372a58ceb0044f9867ec3f499e (patch)
tree5d8ae94a0ad97e2554870a32871caf87d30d7d0a /lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
parent7a228ff4397195c5128f08763da36c3939e2cabb (diff)
downloadbcm5719-llvm-39036ac31d1571372a58ceb0044f9867ec3f499e.tar.gz
bcm5719-llvm-39036ac31d1571372a58ceb0044f9867ec3f499e.zip
[NativeProcessLinux] Fix handling of SIGSTOP
Summary: Previously, NPL tried to reinject SIGSTOP into the inferior in an attempt to get the process to start in the group-stop state. This was: a) wrong (reinjection should be controlled by "process handle" lldb setting) b) racy (it should use Resume for transparent resuming instead of RequestResume) c) broken (llgs crashed on inferior SIGSTOP) With this change, SIGSTOP is handled just like any other signal delivered to the inferior: we stop all threads and report signal reception to lldb. SIGSTOP reinjection does not behave the same way as it would outside the debugger, but simulating this is a hard problem and is not normally necessary. Test Plan: I have added a test which verifies we get SIGSTOP reports and we do not crash. Reviewers: ovyalov, chaoren Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D9852 llvm-svn: 237880
Diffstat (limited to 'lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp')
-rw-r--r--lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp34
1 files changed, 9 insertions, 25 deletions
diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
index f1ddac19e9b..048819c904f 100644
--- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -2266,9 +2266,16 @@ NativeProcessLinux::MonitorCallback(lldb::pid_t pid,
if (err.GetError() == EINVAL)
{
// This is a group stop reception for this tid.
+ // We can reach here if we reinject SIGSTOP, SIGSTP, SIGTTIN or SIGTTOU into the
+ // tracee, triggering the group-stop mechanism. Normally receiving these would stop
+ // the process, pending a SIGCONT. Simulating this state in a debugger is hard and is
+ // generally not needed (one use case is debugging background task being managed by a
+ // shell). For general use, it is sufficient to stop the process in a signal-delivery
+ // stop which happens before the group stop. This done by MonitorSignal and works
+ // correctly for all signals.
if (log)
- log->Printf ("NativeProcessLinux::%s received a group stop for pid %" PRIu64 " tid %" PRIu64, __FUNCTION__, GetID (), pid);
- ThreadDidStop(pid, false);
+ log->Printf("NativeProcessLinux::%s received a group stop for pid %" PRIu64 " tid %" PRIu64 ". Transparent handling of group stops not supported, resuming the thread.", __FUNCTION__, GetID (), pid);
+ Resume(pid, signal);
}
else
{
@@ -2776,29 +2783,6 @@ NativeProcessLinux::MonitorSignal(const siginfo_t *info, lldb::pid_t pid, bool e
switch (signo)
{
- case SIGSTOP:
- {
- std::static_pointer_cast<NativeThreadLinux> (thread_sp)->SetStoppedBySignal (signo);
- if (log)
- {
- if (is_from_llgs)
- log->Printf ("NativeProcessLinux::%s pid = %" PRIu64 " tid %" PRIu64 " received SIGSTOP from llgs, most likely an interrupt", __FUNCTION__, GetID (), pid);
- else
- log->Printf ("NativeProcessLinux::%s pid = %" PRIu64 " tid %" PRIu64 " received SIGSTOP from outside of debugger", __FUNCTION__, GetID (), pid);
- }
-
- // Resume this thread to get the group-stop mechanism to fire off the true group stops.
- // This thread will get stopped again as part of the group-stop completion.
- ResumeThread(pid,
- [=](lldb::tid_t tid_to_resume, bool supress_signal)
- {
- std::static_pointer_cast<NativeThreadLinux> (thread_sp)->SetRunning ();
- // Pass this signal number on to the inferior to handle.
- return Resume (tid_to_resume, (supress_signal) ? LLDB_INVALID_SIGNAL_NUMBER : signo);
- },
- true);
- }
- break;
case SIGSEGV:
case SIGILL:
case SIGFPE:
OpenPOWER on IntegriCloud