Allow ThreadLauncher::LaunchThread() to specify a minimum stack byte size when launching threads.
This defaults to zero, which means to use the system default.
NOTE: Windows will need to implement this.
<rdar://problem/18644448>
llvm-svn: 219821
diff --git a/lldb/source/Host/common/ThreadLauncher.cpp b/lldb/source/Host/common/ThreadLauncher.cpp
index 350d449..d9fe21e 100644
--- a/lldb/source/Host/common/ThreadLauncher.cpp
+++ b/lldb/source/Host/common/ThreadLauncher.cpp
@@ -22,7 +22,7 @@
using namespace lldb_private;
HostThread
-ThreadLauncher::LaunchThread(llvm::StringRef name, lldb::thread_func_t thread_function, lldb::thread_arg_t thread_arg, Error *error_ptr)
+ThreadLauncher::LaunchThread(llvm::StringRef name, lldb::thread_func_t thread_function, lldb::thread_arg_t thread_arg, Error *error_ptr, size_t min_stack_byte_size)
{
Error error;
if (error_ptr)
@@ -36,7 +36,32 @@
if (thread == (lldb::thread_t)(-1L))
error.SetError(::GetLastError(), eErrorTypeWin32);
#else
- int err = ::pthread_create(&thread, NULL, HostNativeThread::ThreadCreateTrampoline, info_ptr);
+
+ pthread_attr_t *thread_attr_ptr = NULL;
+ pthread_attr_t thread_attr;
+ bool destroy_attr = false;
+ if (min_stack_byte_size > 0)
+ {
+ if (::pthread_attr_init (&thread_attr) == 0)
+ {
+ destroy_attr = true;
+ size_t default_min_stack_byte_size = 0;
+ if (::pthread_attr_getstacksize(&thread_attr, &default_min_stack_byte_size) == 0)
+ {
+ if (default_min_stack_byte_size < min_stack_byte_size)
+ {
+ if (::pthread_attr_setstacksize (&thread_attr, min_stack_byte_size) == 0)
+ thread_attr_ptr = &thread_attr;
+ }
+ }
+
+ }
+ }
+ int err = ::pthread_create(&thread, thread_attr_ptr, HostNativeThread::ThreadCreateTrampoline, info_ptr);
+
+ if (destroy_attr)
+ ::pthread_attr_destroy(&thread_attr);
+
error.SetError(err, eErrorTypePOSIX);
#endif
if (error_ptr)