summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Host/OptionParser.h3
-rw-r--r--lldb/source/Host/common/OptionParser.cpp4
-rw-r--r--lldb/source/Interpreter/Args.cpp9
3 files changed, 11 insertions, 5 deletions
diff --git a/lldb/include/lldb/Host/OptionParser.h b/lldb/include/lldb/Host/OptionParser.h
index 5aa7db5d34b..175a1973c7a 100644
--- a/lldb/include/lldb/Host/OptionParser.h
+++ b/lldb/include/lldb/Host/OptionParser.h
@@ -11,6 +11,7 @@
#define liblldb_OptionParser_h_
#include <string>
+#include "lldb/Host/Mutex.h"
struct option;
@@ -38,7 +39,7 @@ public:
eOptionalArgument
};
- static void Prepare();
+ static void Prepare(Mutex::Locker &locker);
static void EnableError(bool error);
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