Add ability to attach/detach to multi-threaded inferiors on Linux.
All running threads will be detected and stopped on attach and all threads get resumed on detach.
llvm-svn: 183049
diff --git a/lldb/source/Host/linux/Host.cpp b/lldb/source/Host/linux/Host.cpp
index 0ed07fb..47b4550 100644
--- a/lldb/source/Host/linux/Host.cpp
+++ b/lldb/source/Host/linux/Host.cpp
@@ -295,6 +295,37 @@
return process_infos.GetSize();
}
+bool
+Host::FindProcessThreads (const lldb::pid_t pid, TidMap &tids_to_attach)
+{
+ bool tids_changed = false;
+ static const char procdir[] = "/proc/";
+ static const char taskdir[] = "/task/";
+ std::string process_task_dir = procdir + std::to_string(pid) + taskdir;
+ DIR *dirproc = opendir (process_task_dir.c_str());
+
+ if (dirproc)
+ {
+ struct dirent *direntry = NULL;
+ while ((direntry = readdir (dirproc)) != NULL)
+ {
+ if (direntry->d_type != DT_DIR || !IsDirNumeric (direntry->d_name))
+ continue;
+
+ lldb::tid_t tid = atoi(direntry->d_name);
+ TidMap::iterator it = tids_to_attach.find(tid);
+ if (it == tids_to_attach.end())
+ {
+ tids_to_attach.insert(TidPair(tid, false));
+ tids_changed = true;
+ }
+ }
+ closedir (dirproc);
+ }
+
+ return tids_changed;
+}
+
static bool
GetELFProcessCPUType (const char *exe_path, ProcessInstanceInfo &process_info)
{