diff options
| author | Matt Kopec <Matt.Kopec@intel.com> | 2013-01-08 16:30:18 +0000 |
|---|---|---|
| committer | Matt Kopec <Matt.Kopec@intel.com> | 2013-01-08 16:30:18 +0000 |
| commit | 650648fa57368241964a576a696bf38851771f21 (patch) | |
| tree | 80cf404e5f547f3a1b933ca56ea7e642baa7770c /lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp | |
| parent | 08e2394dfd5a258cd3b4bcec12c82799f4b6e8b4 (diff) | |
| download | bcm5719-llvm-650648fa57368241964a576a696bf38851771f21.tar.gz bcm5719-llvm-650648fa57368241964a576a696bf38851771f21.zip | |
Add initial support to trace spawned threads in a process on Linux.
llvm-svn: 171864
Diffstat (limited to 'lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp')
| -rw-r--r-- | lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp b/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp index b71f0f94469..f36a9eef732 100644 --- a/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp +++ b/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp @@ -985,6 +985,7 @@ ProcessMonitor::Launch(LaunchArgs *args) const size_t err_len = 1024; char err_str[err_len]; lldb::pid_t pid; + long ptrace_opts = 0; lldb::ThreadSP inferior; LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PROCESS)); @@ -1102,7 +1103,12 @@ ProcessMonitor::Launch(LaunchArgs *args) // Have the child raise an event on exit. This is used to keep the child in // limbo until it is destroyed. - if (PTRACE(PTRACE_SETOPTIONS, pid, NULL, (void*)PTRACE_O_TRACEEXIT) < 0) + ptrace_opts |= PTRACE_O_TRACEEXIT; + + // Have the tracer trace threads which spawn in the inferior process. + ptrace_opts |= PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK | PTRACE_O_TRACECLONE; + + if (PTRACE(PTRACE_SETOPTIONS, pid, NULL, (void*)ptrace_opts) < 0) { args->m_error.SetErrorToErrno(); goto FINISH; @@ -1282,6 +1288,17 @@ ProcessMonitor::MonitorSIGTRAP(ProcessMonitor *monitor, assert(false && "Unexpected SIGTRAP code!"); break; + case (SIGTRAP | (PTRACE_EVENT_FORK << 8)): + case (SIGTRAP | (PTRACE_EVENT_VFORK << 8)): + case (SIGTRAP | (PTRACE_EVENT_CLONE << 8)): + { + unsigned long tid = 0; + if (!monitor->GetEventMessage(pid, &tid)) + tid = -1; + message = ProcessMessage::NewThread(pid, tid); + break; + } + case (SIGTRAP | (PTRACE_EVENT_EXIT << 8)): { // The inferior process is about to exit. Maintain the process in a |

