<div dir="ltr">For the record, this change was a combined effort by:<div>Shawn Best and Todd Fiala</div><div><br></div><div>Shawn did all the hard work.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Wed, Jul 16, 2014 at 12:03 PM, Todd Fiala <span dir="ltr"><<a href="mailto:todd.fiala@gmail.com" target="_blank">todd.fiala@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: tfiala<br>
Date: Wed Jul 16 14:03:16 2014<br>
New Revision: 213183<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=213183&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=213183&view=rev</a><br>
Log:<br>
Add Host::MAX_THREAD_NAME_LENGTH constant.<br>
<br>
This value gets set to a max uint32_t value when there is no known limit; otherwise,<br>
it is set to a value appropriate for the platform.  For the moment, only<br>
Linux, FreeBSD and NetBSD set it to 16.  All other platforms set it to<br>
the max uint32_t value.<br>
<br>
Modifies the Process private state thread names to fit within a 16-character limit<br>
when the max thread name length is <= 16.  These guarantee that the thread names<br>
can be distinguished within the first 16 characters.  Prior to this change, those<br>
threads had names in the final dotted name segment that were not distinguishable<br>
within the first 16 characters.<br>
<br>
Modified:<br>
    lldb/trunk/include/lldb/Host/Host.h<br>
    lldb/trunk/source/Host/common/Host.cpp<br>
    lldb/trunk/source/Target/Process.cpp<br>
<br>
Modified: lldb/trunk/include/lldb/Host/Host.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=213183&r1=213182&r2=213183&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=213183&r1=213182&r2=213183&view=diff</a><br>

==============================================================================<br>
--- lldb/trunk/include/lldb/Host/Host.h (original)<br>
+++ lldb/trunk/include/lldb/Host/Host.h Wed Jul 16 14:03:16 2014<br>
@@ -32,6 +32,10 @@ namespace lldb_private {<br>
 class Host<br>
 {<br>
 public:<br>
+<br>
+    /// A value of std::numeric_limits<uint32_t>::max() is used if there is no practical limit.<br>
+    static const uint32_t MAX_THREAD_NAME_LENGTH;<br>
+<br>
     typedef bool (*MonitorChildProcessCallback) (void *callback_baton,<br>
                                                  lldb::pid_t pid,<br>
                                                  bool exited,<br>
<br>
Modified: lldb/trunk/source/Host/common/Host.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=213183&r1=213182&r2=213183&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=213183&r1=213182&r2=213183&view=diff</a><br>

==============================================================================<br>
--- lldb/trunk/source/Host/common/Host.cpp (original)<br>
+++ lldb/trunk/source/Host/common/Host.cpp Wed Jul 16 14:03:16 2014<br>
@@ -49,6 +49,9 @@<br>
 #include <pthread_np.h><br>
 #endif<br>
<br>
+// C++ includes<br>
+#include <limits><br>
+<br>
 #include "lldb/Host/Host.h"<br>
 #include "lldb/Core/ArchSpec.h"<br>
 #include "lldb/Core/ConstString.h"<br>
@@ -87,6 +90,12 @@ extern "C"<br>
 using namespace lldb;<br>
 using namespace lldb_private;<br>
<br>
+// Define maximum thread name length<br>
+#if defined (__linux__) || defined (__FreeBSD__) || defined (__FreeBSD_kernel__) || defined (__NetBSD__)<br>
+uint32_t const Host::MAX_THREAD_NAME_LENGTH = 16;<br>
+#else<br>
+uint32_t const Host::MAX_THREAD_NAME_LENGTH = std::numeric_limits<uint32_t>::max ();<br>
+#endif<br>
<br>
 #if !defined (__APPLE__) && !defined (_WIN32)<br>
 struct MonitorInfo<br>
<br>
Modified: lldb/trunk/source/Target/Process.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=213183&r1=213182&r2=213183&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=213183&r1=213182&r2=213183&view=diff</a><br>

==============================================================================<br>
--- lldb/trunk/source/Target/Process.cpp (original)<br>
+++ lldb/trunk/source/Target/Process.cpp Wed Jul 16 14:03:16 2014<br>
@@ -3657,11 +3657,23 @@ Process::StartPrivateStateThread (bool f<br>
     // Create a thread that watches our internal state and controls which<br>
     // events make it to clients (into the DCProcess event queue).<br>
     char thread_name[1024];<br>
-    if (already_running)<br>
-        snprintf(thread_name, sizeof(thread_name), "<lldb.process.internal-state-override(pid=%" PRIu64 ")>", GetID());<br>
+<br>
+    if (Host::MAX_THREAD_NAME_LENGTH <= 16)<br>
+    {<br>
+            // On platforms with abbreviated thread name lengths, choose thread names that fit within the limit.<br>
+            if (already_running)<br>
+                snprintf(thread_name, sizeof(thread_name), "intern-state-OV");<br>
+            else<br>
+                snprintf(thread_name, sizeof(thread_name), "intern-state");<br>
+    }<br>
     else<br>
-        snprintf(thread_name, sizeof(thread_name), "<lldb.process.internal-state(pid=%" PRIu64 ")>", GetID());<br>
-<br>
+    {<br>
+        if (already_running)<br>
+                snprintf(thread_name, sizeof(thread_name), "<lldb.process.internal-state-override(pid=%" PRIu64 ")>", GetID());<br>
+        else<br>
+                snprintf(thread_name, sizeof(thread_name), "<lldb.process.internal-state(pid=%" PRIu64 ")>", GetID());<br>
+    }<br>
+<br>
     // Create the private state thread, and start it running.<br>
     m_private_state_thread = Host::ThreadCreate (thread_name, Process::PrivateStateThread, this, NULL);<br>
     bool success = IS_VALID_LLDB_HOST_THREAD(m_private_state_thread);<br>
<br>
<br>
_______________________________________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@cs.uiuc.edu">lldb-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><table cellspacing="0" cellpadding="0" style="color:rgb(136,136,136);font-family:'Times New Roman'"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small">
<td nowrap style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px">Todd Fiala |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px"> Software Engineer |</td>
<td nowrap style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px"> <a href="mailto:tfiala@google.com" style="color:rgb(17,85,204)" target="_blank"><span style="background-color:rgb(255,255,204);color:rgb(34,34,34);background-repeat:initial initial">tfiala@google.com</span></a> |</td>
<td nowrap style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px"><font color="#1155cc"> <a>650-943-3180</a></font></td></tr></tbody></table><br></div>
</div>