summaryrefslogtreecommitdiffstats
path: root/lldb/source
diff options
context:
space:
mode:
authorJim Ingham <jingham@apple.com>2015-11-05 00:38:39 +0000
committerJim Ingham <jingham@apple.com>2015-11-05 00:38:39 +0000
commitc77ce7b6263037f717369ce0ca95d51b31b72168 (patch)
tree4ec3c4941117a11ba31e0d8544ee9d5ff2871c16 /lldb/source
parentba19c6eed8818a7389ed9a8b40b4b50d174cfcc8 (diff)
downloadbcm5719-llvm-c77ce7b6263037f717369ce0ca95d51b31b72168.tar.gz
bcm5719-llvm-c77ce7b6263037f717369ce0ca95d51b31b72168.zip
LLDB needs a mutex around getopt_long_only() function calls to avoid multi-threading option parsing issues.
<rdar://problem/17052381> llvm-svn: 252111
Diffstat (limited to 'lldb/source')
-rw-r--r--lldb/source/Host/common/OptionParser.cpp4
-rw-r--r--lldb/source/Interpreter/Args.cpp9
2 files changed, 9 insertions, 4 deletions
diff --git a/lldb/source/Host/common/OptionParser.cpp b/lldb/source/Host/common/OptionParser.cpp
index a91e764bfe3..a9784592a73 100644
--- a/lldb/source/Host/common/OptionParser.cpp
+++ b/lldb/source/Host/common/OptionParser.cpp
@@ -16,8 +16,10 @@
using namespace lldb_private;
void
-OptionParser::Prepare()
+OptionParser::Prepare(Mutex::Locker &locker)
{
+ static Mutex g_mutex(Mutex::eMutexTypeNormal);
+ locker.Lock(g_mutex);
#ifdef __GLIBC__
optind = 0;
#else
diff --git a/lldb/source/Interpreter/Args.cpp b/lldb/source/Interpreter/Args.cpp
index 7c9f5c35ecb..81e6b0aa1db 100644
--- a/lldb/source/Interpreter/Args.cpp
+++ b/lldb/source/Interpreter/Args.cpp
@@ -575,7 +575,8 @@ Args::ParseOptions (Options &options)
}
}
}
- OptionParser::Prepare();
+ Mutex::Locker options_locker(NULL);
+ OptionParser::Prepare(options_locker);
int val;
while (1)
{
@@ -1189,7 +1190,8 @@ Args::ParseAliasOptions (Options &options,
}
}
- OptionParser::Prepare();
+ Mutex::Locker options_locker(NULL);
+ OptionParser::Prepare(options_locker);
int val;
while (1)
{
@@ -1366,7 +1368,8 @@ Args::ParseArgsForCompletion
}
}
- OptionParser::Prepare();
+ Mutex::Locker options_locker(NULL);
+ OptionParser::Prepare(options_locker);
OptionParser::EnableError(false);
int val;
OpenPOWER on IntegriCloud