diff options
author | Matt Kopec <Matt.Kopec@intel.com> | 2013-05-13 19:33:58 +0000 |
---|---|---|
committer | Matt Kopec <Matt.Kopec@intel.com> | 2013-05-13 19:33:58 +0000 |
commit | 62502c6897678b1ad222ada15e0f42184fd44749 (patch) | |
tree | d8319e5ccc37bbb0e610cbaf51a1647ba97a031a /lldb/source/Host/linux/Host.cpp | |
parent | c5c0823724e5947298bc92f901ec0962f28a8457 (diff) | |
download | bcm5719-llvm-62502c6897678b1ad222ada15e0f42184fd44749.tar.gz bcm5719-llvm-62502c6897678b1ad222ada15e0f42184fd44749.zip |
Add setting of lldb thread names on Linux.
Patch by Mike Sartain.
llvm-svn: 181722
Diffstat (limited to 'lldb/source/Host/linux/Host.cpp')
-rw-r--r-- | lldb/source/Host/linux/Host.cpp | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/lldb/source/Host/linux/Host.cpp b/lldb/source/Host/linux/Host.cpp index c173a25dfe2..d265d833bac 100644 --- a/lldb/source/Host/linux/Host.cpp +++ b/lldb/source/Host/linux/Host.cpp @@ -169,4 +169,51 @@ Host::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info) // FIXME: Parse /proc/<pid>/status to get uid, gid, euid, egid and parent_pid return true; -}
\ No newline at end of file +} + +void +Host::ThreadCreated (const char *thread_name) +{ + if (!Host::SetThreadName (LLDB_INVALID_PROCESS_ID, LLDB_INVALID_THREAD_ID, thread_name)) + { + // pthread_setname_np_func can fail if the thread name is longer than + // the supported limit on Linux. When this occurs, the error ERANGE is returned + // and SetThreadName will fail. Let's drop it down to 16 characters and try again. + char namebuf[16]; + + // Thread names are coming in like '<lldb.comm.debugger.edit>' and '<lldb.comm.debugger.editline>' + // So just chopping the end of the string off leads to a lot of similar named threads. + // Go through the thread name and search for the last dot and use that. + const char *lastdot = ::strrchr( thread_name, '.' ); + + if (lastdot && lastdot != thread_name) + thread_name = lastdot + 1; + ::strncpy (namebuf, thread_name, sizeof(namebuf)); + namebuf[ sizeof(namebuf) - 1 ] = 0; + + int namebuflen = strlen(namebuf); + if (namebuflen > 0) + { + if (namebuf[namebuflen - 1] == '(' || namebuf[namebuflen - 1] == '>') + { + // Trim off trailing '(' and '>' characters for a bit more cleanup. + namebuflen--; + namebuf[namebuflen] = 0; + } + Host::SetThreadName (LLDB_INVALID_PROCESS_ID, LLDB_INVALID_THREAD_ID, namebuf); + } + } +} + +void +Host::Backtrace (Stream &strm, uint32_t max_frames) +{ + // TODO: Is there a way to backtrace the current process on linux? +} + +size_t +Host::GetEnvironment (StringList &env) +{ + // TODO: Is there a way to the host environment for this process on linux? + return 0; +} |