[Lldb-commits] [lldb] r213183 - Add Host::MAX_THREAD_NAME_LENGTH constant.
Todd Fiala
tfiala at google.com
Wed Jul 16 12:14:18 PDT 2014
For the record, this change was a combined effort by:
Shawn Best and Todd Fiala
Shawn did all the hard work.
On Wed, Jul 16, 2014 at 12:03 PM, Todd Fiala <todd.fiala at gmail.com> wrote:
> Author: tfiala
> Date: Wed Jul 16 14:03:16 2014
> New Revision: 213183
>
> URL: http://llvm.org/viewvc/llvm-project?rev=213183&view=rev
> Log:
> Add Host::MAX_THREAD_NAME_LENGTH constant.
>
> This value gets set to a max uint32_t value when there is no known limit;
> otherwise,
> it is set to a value appropriate for the platform. For the moment, only
> Linux, FreeBSD and NetBSD set it to 16. All other platforms set it to
> the max uint32_t value.
>
> Modifies the Process private state thread names to fit within a
> 16-character limit
> when the max thread name length is <= 16. These guarantee that the thread
> names
> can be distinguished within the first 16 characters. Prior to this
> change, those
> threads had names in the final dotted name segment that were not
> distinguishable
> within the first 16 characters.
>
> Modified:
> lldb/trunk/include/lldb/Host/Host.h
> lldb/trunk/source/Host/common/Host.cpp
> lldb/trunk/source/Target/Process.cpp
>
> Modified: lldb/trunk/include/lldb/Host/Host.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=213183&r1=213182&r2=213183&view=diff
>
> ==============================================================================
> --- lldb/trunk/include/lldb/Host/Host.h (original)
> +++ lldb/trunk/include/lldb/Host/Host.h Wed Jul 16 14:03:16 2014
> @@ -32,6 +32,10 @@ namespace lldb_private {
> class Host
> {
> public:
> +
> + /// A value of std::numeric_limits<uint32_t>::max() is used if there
> is no practical limit.
> + static const uint32_t MAX_THREAD_NAME_LENGTH;
> +
> typedef bool (*MonitorChildProcessCallback) (void *callback_baton,
> lldb::pid_t pid,
> bool exited,
>
> Modified: lldb/trunk/source/Host/common/Host.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=213183&r1=213182&r2=213183&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Host/common/Host.cpp (original)
> +++ lldb/trunk/source/Host/common/Host.cpp Wed Jul 16 14:03:16 2014
> @@ -49,6 +49,9 @@
> #include <pthread_np.h>
> #endif
>
> +// C++ includes
> +#include <limits>
> +
> #include "lldb/Host/Host.h"
> #include "lldb/Core/ArchSpec.h"
> #include "lldb/Core/ConstString.h"
> @@ -87,6 +90,12 @@ extern "C"
> using namespace lldb;
> using namespace lldb_private;
>
> +// Define maximum thread name length
> +#if defined (__linux__) || defined (__FreeBSD__) || defined
> (__FreeBSD_kernel__) || defined (__NetBSD__)
> +uint32_t const Host::MAX_THREAD_NAME_LENGTH = 16;
> +#else
> +uint32_t const Host::MAX_THREAD_NAME_LENGTH =
> std::numeric_limits<uint32_t>::max ();
> +#endif
>
> #if !defined (__APPLE__) && !defined (_WIN32)
> struct MonitorInfo
>
> Modified: lldb/trunk/source/Target/Process.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=213183&r1=213182&r2=213183&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Target/Process.cpp (original)
> +++ lldb/trunk/source/Target/Process.cpp Wed Jul 16 14:03:16 2014
> @@ -3657,11 +3657,23 @@ Process::StartPrivateStateThread (bool f
> // Create a thread that watches our internal state and controls which
> // events make it to clients (into the DCProcess event queue).
> char thread_name[1024];
> - if (already_running)
> - snprintf(thread_name, sizeof(thread_name),
> "<lldb.process.internal-state-override(pid=%" PRIu64 ")>", GetID());
> +
> + if (Host::MAX_THREAD_NAME_LENGTH <= 16)
> + {
> + // On platforms with abbreviated thread name lengths, choose
> thread names that fit within the limit.
> + if (already_running)
> + snprintf(thread_name, sizeof(thread_name),
> "intern-state-OV");
> + else
> + snprintf(thread_name, sizeof(thread_name),
> "intern-state");
> + }
> else
> - snprintf(thread_name, sizeof(thread_name),
> "<lldb.process.internal-state(pid=%" PRIu64 ")>", GetID());
> -
> + {
> + if (already_running)
> + snprintf(thread_name, sizeof(thread_name),
> "<lldb.process.internal-state-override(pid=%" PRIu64 ")>", GetID());
> + else
> + snprintf(thread_name, sizeof(thread_name),
> "<lldb.process.internal-state(pid=%" PRIu64 ")>", GetID());
> + }
> +
> // Create the private state thread, and start it running.
> m_private_state_thread = Host::ThreadCreate (thread_name,
> Process::PrivateStateThread, this, NULL);
> bool success = IS_VALID_LLDB_HOST_THREAD(m_private_state_thread);
>
>
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits
>
--
Todd Fiala | Software Engineer | tfiala at google.com | 650-943-3180
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20140716/79891b9c/attachment.html>
More information about the lldb-commits
mailing list