Set thread names on FreeBSD
Also move the logic to shorten thread names from linux/Host.cpp to a new
SetShortThreadName as both FreeBSD and Linux need the functionality.
llvm-svn: 187149
diff --git a/lldb/source/Host/linux/Host.cpp b/lldb/source/Host/linux/Host.cpp
index a756a47..cdcff1f 100644
--- a/lldb/source/Host/linux/Host.cpp
+++ b/lldb/source/Host/linux/Host.cpp
@@ -451,32 +451,7 @@
{
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);
- }
+ Host::SetShortThreadName (LLDB_INVALID_PROCESS_ID, LLDB_INVALID_THREAD_ID, thread_name, 16);
}
}