summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/tools/lldb/source/Interpreter/Args.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/tools/lldb/source/Interpreter/Args.cpp')
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/Args.cpp47
1 files changed, 40 insertions, 7 deletions
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/Args.cpp b/contrib/llvm/tools/lldb/source/Interpreter/Args.cpp
index 2258c26..81e6b0a 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/Args.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/Args.cpp
@@ -371,7 +371,7 @@ char **
Args::GetArgumentVector()
{
if (!m_argv.empty())
- return (char **)&m_argv[0];
+ return const_cast<char **>(&m_argv[0]);
return nullptr;
}
@@ -379,7 +379,7 @@ const char **
Args::GetConstArgumentVector() const
{
if (!m_argv.empty())
- return (const char **)&m_argv[0];
+ return const_cast<const char **>(&m_argv[0]);
return nullptr;
}
@@ -575,7 +575,8 @@ Args::ParseOptions (Options &options)
}
}
}
- OptionParser::Prepare();
+ Mutex::Locker options_locker(NULL);
+ OptionParser::Prepare(options_locker);
int val;
while (1)
{
@@ -719,7 +720,7 @@ Args::StringToAddress (const ExecutionContext *exe_ctx, const char *s, lldb::add
else
{
// Since the compiler can't handle things like "main + 12" we should
- // try to do this for now. The compliler doesn't like adding offsets
+ // try to do this for now. The compiler doesn't like adding offsets
// to function pointer types.
static RegularExpression g_symbol_plus_offset_regex("^(.*)([-\\+])[[:space:]]*(0x[0-9A-Fa-f]+|[0-9]+)[[:space:]]*$");
RegularExpression::Match regex_match(3);
@@ -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;
@@ -1387,7 +1390,7 @@ Args::ParseArgsForCompletion
int long_options_index = -1;
val = OptionParser::Parse (dummy_vec.size() - 1,
- (char *const *) &dummy_vec.front(),
+ const_cast<char *const *>(&dummy_vec.front()),
sstr.GetData(),
long_options,
&long_options_index);
@@ -1668,3 +1671,33 @@ Args::ExpandEscapedCharacters (const char *src, std::string &dst)
}
}
+std::string
+Args::EscapeLLDBCommandArgument (const std::string& arg, char quote_char)
+{
+ const char* chars_to_escape = nullptr;
+ switch (quote_char)
+ {
+ case '\0':
+ chars_to_escape = " \t\\'\"`";
+ break;
+ case '\'':
+ chars_to_escape = "";
+ break;
+ case '"':
+ chars_to_escape = "$\"`\\";
+ break;
+ default:
+ assert(false && "Unhandled quote character");
+ }
+
+ std::string res;
+ res.reserve(arg.size());
+ for (char c : arg)
+ {
+ if (::strchr(chars_to_escape, c))
+ res.push_back('\\');
+ res.push_back(c);
+ }
+ return res;
+}
+
OpenPOWER on IntegriCloud