summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host/linux/Host.cpp
diff options
context:
space:
mode:
authorMatt Kopec <Matt.Kopec@intel.com>2013-05-31 22:00:07 +0000
committerMatt Kopec <Matt.Kopec@intel.com>2013-05-31 22:00:07 +0000
commit085d6cec1a5db8778998876aed46fc0cdcc222f1 (patch)
tree8f23fff6d2636f93e91e832f0d7a6f2baf9a1794 /lldb/source/Host/linux/Host.cpp
parentdeac9ac54687adddce2eb852e7fbe5f981273afb (diff)
downloadbcm5719-llvm-085d6cec1a5db8778998876aed46fc0cdcc222f1.tar.gz
bcm5719-llvm-085d6cec1a5db8778998876aed46fc0cdcc222f1.zip
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
Diffstat (limited to 'lldb/source/Host/linux/Host.cpp')
-rw-r--r--lldb/source/Host/linux/Host.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/lldb/source/Host/linux/Host.cpp b/lldb/source/Host/linux/Host.cpp
index 0ed07fb8915..47b45509956 100644
--- a/lldb/source/Host/linux/Host.cpp
+++ b/lldb/source/Host/linux/Host.cpp
@@ -295,6 +295,37 @@ Host::FindProcesses (const ProcessInstanceInfoMatch &match_info, ProcessInstance
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)
{
OpenPOWER on IntegriCloud