Index: base/threading/thread.cc |
diff --git a/base/threading/thread.cc b/base/threading/thread.cc |
index aca4ddbaa02a11c37ef02b39b5e4c3da829f404e..f0337750356915623c2a65b77d1437c51bb4eab2 100644 |
--- a/base/threading/thread.cc |
+++ b/base/threading/thread.cc |
@@ -5,6 +5,7 @@ |
#include "base/threading/thread.h" |
#include "base/bind.h" |
+#include "base/debug/alias.h" |
#include "base/lazy_instance.h" |
#include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
#include "base/threading/thread_id_name_manager.h" |
@@ -172,6 +173,19 @@ bool Thread::GetThreadWasQuitProperly() { |
void Thread::ThreadMain() { |
{ |
+#if defined(OS_MACOSX) |
+ // Store the thread name on the stack to debug <http://crbug.com/274705>. |
+ // End with a byte sequence of <EOT><BEL><NUL> to make it easier to grep in |
+ // the minidump stack dump. |
+ const size_t kThreadNameSize = 50; |
+ char thread_name[kThreadNameSize]; |
+ strncpy(thread_name, name_.c_str(), kThreadNameSize); |
+ thread_name[kThreadNameSize - 1] = '\0'; |
+ thread_name[kThreadNameSize - 2] = '\7'; |
+ thread_name[kThreadNameSize - 3] = '\3'; |
+ base::debug::Alias(thread_name); |
+#endif |
+ |
// The message loop for this thread. |
// Allocated on the heap to centralize any leak reports at this line. |
scoped_ptr<MessageLoop> message_loop( |
@@ -217,6 +231,10 @@ void Thread::ThreadMain() { |
// We can't receive messages anymore. |
message_loop_ = NULL; |
+ |
+#if defined(OS_MACOSX) |
+ base::debug::Alias(thread_name); |
+#endif |
} |
} |