summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/tools/lldb/source/Interpreter
diff options
context:
space:
mode:
authoremaste <emaste@FreeBSD.org>2014-11-26 16:48:12 +0000
committeremaste <emaste@FreeBSD.org>2014-11-26 16:48:12 +0000
commit0147dda7de9580d13778ecb4c9e92b83b7a63911 (patch)
treeb16dc95f693ed59342b6141cd3fd9f59a6cd7e7e /contrib/llvm/tools/lldb/source/Interpreter
parentbfd4c39c61ae9b29542625bb12b6f7f4b1f8c727 (diff)
parent01ee1789d6aa7294e5966a97f8d29387f6f81699 (diff)
downloadFreeBSD-src-0147dda7de9580d13778ecb4c9e92b83b7a63911.zip
FreeBSD-src-0147dda7de9580d13778ecb4c9e92b83b7a63911.tar.gz
Update LLDB snapshot to upstream r216948 (git 50f7fe44)
This is approximately "LLDB 3.5" although with a little bit of skew, and will go along with the Clang 3.5 import. Sponsored by: DARPA, AFRL
Diffstat (limited to 'contrib/llvm/tools/lldb/source/Interpreter')
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/Args.cpp125
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/CommandHistory.cpp20
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/CommandInterpreter.cpp195
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/CommandObject.cpp213
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/CommandObjectRegexCommand.cpp6
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/CommandObjectScript.cpp4
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/CommandOptionValidators.cpp39
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/CommandReturnObject.cpp20
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/OptionGroupArchitecture.cpp2
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/OptionGroupBoolean.cpp3
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/OptionGroupFile.cpp6
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/OptionGroupFormat.cpp10
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/OptionGroupOutputFile.cpp10
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/OptionGroupPlatform.cpp8
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/OptionGroupString.cpp3
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/OptionGroupUInt64.cpp3
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/OptionGroupUUID.cpp2
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp26
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/OptionGroupVariable.cpp16
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/OptionGroupWatchpoint.cpp8
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/OptionValue.cpp68
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/OptionValueArch.cpp2
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/OptionValueArray.cpp7
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/OptionValueBoolean.cpp5
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/OptionValueDictionary.cpp14
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/OptionValueEnumeration.cpp2
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/OptionValueFileSpec.cpp3
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/OptionValueFormat.cpp2
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/OptionValueProperties.cpp37
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/OptionValueUUID.cpp2
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/Options.cpp77
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/Property.cpp4
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/PythonDataObjects.cpp24
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/ScriptInterpreter.cpp35
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/ScriptInterpreterPython.cpp378
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/embedded_interpreter.py4
36 files changed, 795 insertions, 588 deletions
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/Args.cpp b/contrib/llvm/tools/lldb/source/Interpreter/Args.cpp
index b6f34fd..4831eaa 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/Args.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/Args.cpp
@@ -20,6 +20,7 @@
#include "lldb/Core/StreamString.h"
#include "lldb/DataFormatters/FormatManager.h"
#include "lldb/Interpreter/Options.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Target/Process.h"
//#include "lldb/Target/RegisterContext.h"
@@ -166,7 +167,7 @@ Args::SetCommandString (const char *command)
{
static const char *k_space_separators = " \t";
static const char *k_space_separators_with_slash_and_quotes = " \t \\'\"";
- const char *arg_end = NULL;
+ const char *arg_end = nullptr;
const char *arg_pos;
for (arg_pos = command;
arg_pos && arg_pos[0];
@@ -371,7 +372,7 @@ Args::UpdateArgsAfterOptionParsing()
++argv_pos)
{
const char *argv_cstr = *argv_pos;
- if (argv_cstr == NULL)
+ if (argv_cstr == nullptr)
break;
while (args_pos != m_args.end())
@@ -407,7 +408,7 @@ Args::UpdateArgvFromArgs()
arg_sstr_collection::const_iterator pos, end = m_args.end();
for (pos = m_args.begin(); pos != end; ++pos)
m_argv.push_back(pos->c_str());
- m_argv.push_back(NULL);
+ m_argv.push_back(nullptr);
// Make sure we have enough arg quote chars in the array
if (m_args_quote_char.size() < m_args.size())
m_args_quote_char.resize (m_argv.size());
@@ -426,7 +427,7 @@ Args::GetArgumentAtIndex (size_t idx) const
{
if (idx < m_argv.size())
return m_argv[idx];
- return NULL;
+ return nullptr;
}
char
@@ -442,7 +443,7 @@ Args::GetArgumentVector()
{
if (!m_argv.empty())
return (char **)&m_argv[0];
- return NULL;
+ return nullptr;
}
const char **
@@ -450,7 +451,7 @@ Args::GetConstArgumentVector() const
{
if (!m_argv.empty())
return (const char **)&m_argv[0];
- return NULL;
+ return nullptr;
}
void
@@ -545,7 +546,7 @@ Args::ReplaceArgumentAtIndex (size_t idx, const char *arg_cstr, char quote_char)
m_args_quote_char[idx] = quote_char;
return GetArgumentAtIndex(idx);
}
- return NULL;
+ return nullptr;
}
void
@@ -621,20 +622,20 @@ Args::ParseOptions (Options &options)
StreamString sstr;
Error error;
Option *long_options = options.GetLongOptions();
- if (long_options == NULL)
+ if (long_options == nullptr)
{
error.SetErrorStringWithFormat("invalid long options");
return error;
}
- for (int i=0; long_options[i].name != NULL; ++i)
+ for (int i=0; long_options[i].definition != nullptr; ++i)
{
- if (long_options[i].flag == NULL)
+ if (long_options[i].flag == nullptr)
{
if (isprint8(long_options[i].val))
{
sstr << (char)long_options[i].val;
- switch (long_options[i].has_arg)
+ switch (long_options[i].definition->option_has_arg)
{
default:
case OptionParser::eNoArgument: break;
@@ -673,7 +674,7 @@ Args::ParseOptions (Options &options)
if (long_options_index == -1)
{
for (int i=0;
- long_options[i].name || long_options[i].has_arg || long_options[i].flag || long_options[i].val;
+ long_options[i].definition || long_options[i].flag || long_options[i].val;
++i)
{
if (long_options[i].val == val)
@@ -686,8 +687,18 @@ Args::ParseOptions (Options &options)
// Call the callback with the option
if (long_options_index >= 0)
{
- error = options.SetOptionValue(long_options_index,
- long_options[long_options_index].has_arg == OptionParser::eNoArgument ? NULL : OptionParser::GetOptionArgument());
+ const OptionDefinition *def = long_options[long_options_index].definition;
+ CommandInterpreter &interpreter = options.GetInterpreter();
+ OptionValidator *validator = def->validator;
+ if (validator && !validator->IsValid(*interpreter.GetPlatform(true), interpreter.GetExecutionContext()))
+ {
+ error.SetErrorStringWithFormat("Option \"%s\" invalid. %s", def->long_option, def->validator->LongConditionString());
+ }
+ else
+ {
+ error = options.SetOptionValue(long_options_index,
+ (def->option_has_arg == OptionParser::eNoArgument) ? nullptr : OptionParser::GetOptionArgument());
+ }
}
else
{
@@ -716,7 +727,7 @@ Args::StringToSInt32 (const char *s, int32_t fail_value, int base, bool *success
{
if (s && s[0])
{
- char *end = NULL;
+ char *end = nullptr;
const long sval = ::strtol (s, &end, base);
if (*end == '\0')
{
@@ -734,7 +745,7 @@ Args::StringToUInt32 (const char *s, uint32_t fail_value, int base, bool *succes
{
if (s && s[0])
{
- char *end = NULL;
+ char *end = nullptr;
const unsigned long uval = ::strtoul (s, &end, base);
if (*end == '\0')
{
@@ -753,7 +764,7 @@ Args::StringToSInt64 (const char *s, int64_t fail_value, int base, bool *success
{
if (s && s[0])
{
- char *end = NULL;
+ char *end = nullptr;
int64_t uval = ::strtoll (s, &end, base);
if (*end == '\0')
{
@@ -770,7 +781,7 @@ Args::StringToUInt64 (const char *s, uint64_t fail_value, int base, bool *succes
{
if (s && s[0])
{
- char *end = NULL;
+ char *end = nullptr;
uint64_t uval = ::strtoull (s, &end, base);
if (*end == '\0')
{
@@ -788,7 +799,7 @@ Args::StringToAddress (const ExecutionContext *exe_ctx, const char *s, lldb::add
bool error_set = false;
if (s && s[0])
{
- char *end = NULL;
+ char *end = nullptr;
lldb::addr_t addr = ::strtoull (s, &end, 0);
if (*end == '\0')
{
@@ -817,13 +828,13 @@ Args::StringToAddress (const ExecutionContext *exe_ctx, const char *s, lldb::add
options.SetKeepInMemory(false);
options.SetTryAllThreads(true);
- ExecutionResults expr_result = target->EvaluateExpression(s,
+ ExpressionResults expr_result = target->EvaluateExpression(s,
exe_ctx->GetFramePtr(),
valobj_sp,
options);
bool success = false;
- if (expr_result == eExecutionCompleted)
+ if (expr_result == eExpressionCompleted)
{
// Get the address to watch.
addr = valobj_sp->GetValueAsUnsigned(fail_value, &success);
@@ -923,7 +934,7 @@ Args::StripSpaces (std::string &s, bool leading, bool trailing, bool return_null
}
}
if (return_null_if_empty && s.empty())
- return NULL;
+ return nullptr;
return s.c_str();
}
@@ -964,7 +975,7 @@ Args::StringToVersion (const char *s, uint32_t &major, uint32_t &minor, uint32_t
if (s && s[0])
{
- char *pos = NULL;
+ char *pos = nullptr;
unsigned long uval32 = ::strtoul (s, &pos, 0);
if (pos == s)
return s;
@@ -991,7 +1002,7 @@ Args::StringToVersion (const char *s, uint32_t &major, uint32_t &minor, uint32_t
return pos;
}
}
- return 0;
+ return nullptr;
}
const char *
@@ -1022,7 +1033,7 @@ Args::StringToOptionEnum (const char *s, OptionEnumValueElement *enum_values, in
{
if (s && s[0])
{
- for (int i = 0; enum_values[i].string_value != NULL ; i++)
+ for (int i = 0; enum_values[i].string_value != nullptr ; i++)
{
if (strstr(enum_values[i].string_value, s) == enum_values[i].string_value)
{
@@ -1034,7 +1045,7 @@ Args::StringToOptionEnum (const char *s, OptionEnumValueElement *enum_values, in
StreamString strm;
strm.PutCString ("invalid enumeration value, valid values are: ");
- for (int i = 0; enum_values[i].string_value != NULL; i++)
+ for (int i = 0; enum_values[i].string_value != nullptr; i++)
{
strm.Printf ("%s\"%s\"",
i > 0 ? ", " : "",
@@ -1087,7 +1098,7 @@ Args::StringToFormat
{
if (isdigit (s[0]))
{
- char *format_char = NULL;
+ char *format_char = nullptr;
unsigned long byte_size = ::strtoul (s, &format_char, 0);
if (byte_size != ULONG_MAX)
*byte_size_ptr = byte_size;
@@ -1155,7 +1166,7 @@ Args::StringToGenericRegister (const char *s)
return LLDB_REGNUM_GENERIC_SP;
else if (strcmp(s, "fp") == 0)
return LLDB_REGNUM_GENERIC_FP;
- else if (strcmp(s, "ra") == 0)
+ else if (strcmp(s, "ra") == 0 || strcmp(s, "lr") == 0)
return LLDB_REGNUM_GENERIC_RA;
else if (strcmp(s, "flags") == 0)
return LLDB_REGNUM_GENERIC_FLAGS;
@@ -1222,7 +1233,7 @@ Args::FindArgumentIndexForOption (Option *long_options, int long_options_index)
char short_buffer[3];
char long_buffer[255];
::snprintf (short_buffer, sizeof (short_buffer), "-%c", long_options[long_options_index].val);
- ::snprintf (long_buffer, sizeof (long_buffer), "--%s", long_options[long_options_index].name);
+ ::snprintf (long_buffer, sizeof (long_buffer), "--%s", long_options[long_options_index].definition->long_option);
size_t end = GetArgumentCount ();
size_t idx = 0;
while (idx < end)
@@ -1241,7 +1252,7 @@ Args::FindArgumentIndexForOption (Option *long_options, int long_options_index)
bool
Args::IsPositionalArgument (const char *arg)
{
- if (arg == NULL)
+ if (arg == nullptr)
return false;
bool is_positional = true;
@@ -1271,19 +1282,19 @@ Args::ParseAliasOptions (Options &options,
int i;
Option *long_options = options.GetLongOptions();
- if (long_options == NULL)
+ if (long_options == nullptr)
{
result.AppendError ("invalid long options");
result.SetStatus (eReturnStatusFailed);
return;
}
- for (i = 0; long_options[i].name != NULL; ++i)
+ for (i = 0; long_options[i].definition != nullptr; ++i)
{
- if (long_options[i].flag == NULL)
+ if (long_options[i].flag == nullptr)
{
sstr << (char) long_options[i].val;
- switch (long_options[i].has_arg)
+ switch (long_options[i].definition->option_has_arg)
{
default:
case OptionParser::eNoArgument:
@@ -1322,13 +1333,13 @@ Args::ParseAliasOptions (Options &options,
if (val == 0)
continue;
- ((Options *) &options)->OptionSeen (val);
+ options.OptionSeen (val);
// Look up the long option index
if (long_options_index == -1)
{
for (int j = 0;
- long_options[j].name || long_options[j].has_arg || long_options[j].flag || long_options[j].val;
+ long_options[j].definition || long_options[j].flag || long_options[j].val;
++j)
{
if (long_options[j].val == val)
@@ -1344,8 +1355,10 @@ Args::ParseAliasOptions (Options &options,
{
StreamString option_str;
option_str.Printf ("-%c", val);
+ const OptionDefinition *def = long_options[long_options_index].definition;
+ int has_arg = (def == nullptr) ? OptionParser::eNoArgument : def->option_has_arg;
- switch (long_options[long_options_index].has_arg)
+ switch (has_arg)
{
case OptionParser::eNoArgument:
option_arg_vector->push_back (OptionArgPair (std::string (option_str.GetData()),
@@ -1353,7 +1366,7 @@ Args::ParseAliasOptions (Options &options,
result.SetStatus (eReturnStatusSuccessFinishNoResult);
break;
case OptionParser::eRequiredArgument:
- if (OptionParser::GetOptionArgument() != NULL)
+ if (OptionParser::GetOptionArgument() != nullptr)
{
option_arg_vector->push_back (OptionArgPair (std::string (option_str.GetData()),
OptionArgValue (OptionParser::eRequiredArgument,
@@ -1368,7 +1381,7 @@ Args::ParseAliasOptions (Options &options,
}
break;
case OptionParser::eOptionalArgument:
- if (OptionParser::GetOptionArgument() != NULL)
+ if (OptionParser::GetOptionArgument() != nullptr)
{
option_arg_vector->push_back (OptionArgPair (std::string (option_str.GetData()),
OptionArgValue (OptionParser::eOptionalArgument,
@@ -1410,8 +1423,8 @@ Args::ParseAliasOptions (Options &options,
raw_input_string.erase (pos, strlen (tmp_arg));
}
ReplaceArgumentAtIndex (idx, "");
- if ((long_options[long_options_index].has_arg != OptionParser::eNoArgument)
- && (OptionParser::GetOptionArgument() != NULL)
+ if ((long_options[long_options_index].definition->option_has_arg != OptionParser::eNoArgument)
+ && (OptionParser::GetOptionArgument() != nullptr)
&& (idx+1 < GetArgumentCount())
&& (strcmp (OptionParser::GetOptionArgument(), GetArgumentAtIndex(idx+1)) == 0))
{
@@ -1444,7 +1457,7 @@ Args::ParseArgsForCompletion
Option *long_options = options.GetLongOptions();
option_element_vector.clear();
- if (long_options == NULL)
+ if (long_options == nullptr)
{
return;
}
@@ -1453,12 +1466,12 @@ Args::ParseArgsForCompletion
// to suppress error messages.
sstr << ":";
- for (int i = 0; long_options[i].name != NULL; ++i)
+ for (int i = 0; long_options[i].definition != nullptr; ++i)
{
- if (long_options[i].flag == NULL)
+ if (long_options[i].flag == nullptr)
{
sstr << (char) long_options[i].val;
- switch (long_options[i].has_arg)
+ switch (long_options[i].definition->option_has_arg)
{
default:
case OptionParser::eNoArgument:
@@ -1516,11 +1529,11 @@ Args::ParseArgsForCompletion
// were passed. This will be useful when we come to restricting completions based on what other
// options we've seen on the line.
- if (OptionParser::GetOptionIndex() < dummy_vec.size() - 1
+ if (static_cast<size_t>(OptionParser::GetOptionIndex()) < dummy_vec.size() - 1
&& (strcmp (dummy_vec[OptionParser::GetOptionIndex()-1], "--") == 0))
{
dash_dash_pos = OptionParser::GetOptionIndex() - 1;
- if (OptionParser::GetOptionIndex() - 1 == cursor_index)
+ if (static_cast<size_t>(OptionParser::GetOptionIndex() - 1) == cursor_index)
{
option_element_vector.push_back (OptionArgElement (OptionArgElement::eBareDoubleDash, OptionParser::GetOptionIndex() - 1,
OptionArgElement::eBareDoubleDash));
@@ -1555,7 +1568,7 @@ Args::ParseArgsForCompletion
if (long_options_index == -1)
{
for (int j = 0;
- long_options[j].name || long_options[j].has_arg || long_options[j].flag || long_options[j].val;
+ long_options[j].definition || long_options[j].flag || long_options[j].val;
++j)
{
if (long_options[j].val == val)
@@ -1581,13 +1594,15 @@ Args::ParseArgsForCompletion
}
}
- switch (long_options[long_options_index].has_arg)
+ const OptionDefinition *def = long_options[long_options_index].definition;
+ int has_arg = (def == nullptr) ? OptionParser::eNoArgument : def->option_has_arg;
+ switch (has_arg)
{
case OptionParser::eNoArgument:
option_element_vector.push_back (OptionArgElement (opt_defs_index, OptionParser::GetOptionIndex() - 1, 0));
break;
case OptionParser::eRequiredArgument:
- if (OptionParser::GetOptionArgument() != NULL)
+ if (OptionParser::GetOptionArgument() != nullptr)
{
int arg_index;
if (missing_argument)
@@ -1603,7 +1618,7 @@ Args::ParseArgsForCompletion
}
break;
case OptionParser::eOptionalArgument:
- if (OptionParser::GetOptionArgument() != NULL)
+ if (OptionParser::GetOptionArgument() != nullptr)
{
option_element_vector.push_back (OptionArgElement (opt_defs_index, OptionParser::GetOptionIndex() - 2, OptionParser::GetOptionIndex() - 1));
}
@@ -1629,8 +1644,10 @@ Args::ParseArgsForCompletion
// Finally we have to handle the case where the cursor index points at a single "-". We want to mark that in
// the option_element_vector, but only if it is not after the "--". But it turns out that OptionParser::Parse just ignores
// an isolated "-". So we have to look it up by hand here. We only care if it is AT the cursor position.
+ // Note, a single quoted dash is not the same as a single dash...
- if ((dash_dash_pos == -1 || cursor_index < dash_dash_pos)
+ if ((static_cast<int32_t>(dash_dash_pos) == -1 || cursor_index < dash_dash_pos)
+ && m_args_quote_char[cursor_index] == '\0'
&& strcmp (GetArgumentAtIndex(cursor_index), "-") == 0)
{
option_element_vector.push_back (OptionArgElement (OptionArgElement::eBareDash, cursor_index,
@@ -1686,7 +1703,7 @@ Args::EncodeEscapeSequences (const char *src, std::string &dst)
// the main for loop will do this for us, so we advance p by
// one less than i (even if i is zero)
p += i - 1;
- unsigned long octal_value = ::strtoul (oct_str, NULL, 8);
+ unsigned long octal_value = ::strtoul (oct_str, nullptr, 8);
if (octal_value <= UINT8_MAX)
{
dst.append(1, (char)octal_value);
@@ -1709,7 +1726,7 @@ Args::EncodeEscapeSequences (const char *src, std::string &dst)
hex_str[1] = *p;
}
- unsigned long hex_value = strtoul (hex_str, NULL, 16);
+ unsigned long hex_value = strtoul (hex_str, nullptr, 16);
if (hex_value <= UINT8_MAX)
dst.append (1, (char)hex_value);
}
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/CommandHistory.cpp b/contrib/llvm/tools/lldb/source/Interpreter/CommandHistory.cpp
index 33971e3..26996a6 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/CommandHistory.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/CommandHistory.cpp
@@ -41,17 +41,17 @@ CommandHistory::FindString (const char* input_str) const
{
Mutex::Locker locker(m_mutex);
if (!input_str)
- return NULL;
+ return nullptr;
if (input_str[0] != g_repeat_char)
- return NULL;
+ return nullptr;
if (input_str[1] == '-')
{
bool success;
size_t idx = Args::StringToUInt32 (input_str+2, 0, 0, &success);
if (!success)
- return NULL;
+ return nullptr;
if (idx > m_history.size())
- return NULL;
+ return nullptr;
idx = m_history.size() - idx;
return m_history[idx].c_str();
@@ -59,7 +59,7 @@ CommandHistory::FindString (const char* input_str) const
else if (input_str[1] == g_repeat_char)
{
if (m_history.empty())
- return NULL;
+ return nullptr;
else
return m_history.back().c_str();
}
@@ -68,9 +68,9 @@ CommandHistory::FindString (const char* input_str) const
bool success;
uint32_t idx = Args::StringToUInt32 (input_str+1, 0, 0, &success);
if (!success)
- return NULL;
+ return nullptr;
if (idx >= m_history.size())
- return NULL;
+ return nullptr;
return m_history[idx].c_str();
}
}
@@ -81,7 +81,7 @@ CommandHistory::GetStringAtIndex (size_t idx) const
Mutex::Locker locker(m_mutex);
if (idx < m_history.size())
return m_history[idx].c_str();
- return NULL;
+ return nullptr;
}
const char*
@@ -95,7 +95,7 @@ CommandHistory::GetRecentmostString () const
{
Mutex::Locker locker(m_mutex);
if (m_history.empty())
- return NULL;
+ return nullptr;
return m_history.back().c_str();
}
@@ -137,7 +137,7 @@ CommandHistory::Dump (Stream& stream,
if (!hist_item.empty())
{
stream.Indent();
- stream.Printf ("%4zu: %s\n", counter, hist_item.c_str());
+ stream.Printf("%4" PRIu64 ": %s\n", (uint64_t)counter, hist_item.c_str());
}
}
}
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/CommandInterpreter.cpp b/contrib/llvm/tools/lldb/source/Interpreter/CommandInterpreter.cpp
index fb0fc7f..56c8f8c 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -44,12 +44,14 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Log.h"
+#include "lldb/Core/State.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/Timer.h"
#include "lldb/Host/Editline.h"
#include "lldb/Host/Host.h"
+#include "lldb/Host/HostInfo.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandCompletions.h"
@@ -66,6 +68,10 @@
#include "lldb/Utility/CleanUp.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Path.h"
+
using namespace lldb;
using namespace lldb_private;
@@ -73,10 +79,10 @@ using namespace lldb_private;
static PropertyDefinition
g_properties[] =
{
- { "expand-regex-aliases", OptionValue::eTypeBoolean, true, false, NULL, NULL, "If true, regular expression alias commands will show the expanded command that will be executed. This can be used to debug new regular expression alias commands." },
- { "prompt-on-quit", OptionValue::eTypeBoolean, true, true, NULL, NULL, "If true, LLDB will prompt you before quitting if there are any live processes being debugged. If false, LLDB will quit without asking in any case." },
- { "stop-command-source-on-error", OptionValue::eTypeBoolean, true, true, NULL, NULL, "If true, LLDB will stop running a 'command source' script upon encountering an error." },
- { NULL , OptionValue::eTypeInvalid, true, 0 , NULL, NULL, NULL }
+ { "expand-regex-aliases", OptionValue::eTypeBoolean, true, false, nullptr, nullptr, "If true, regular expression alias commands will show the expanded command that will be executed. This can be used to debug new regular expression alias commands." },
+ { "prompt-on-quit", OptionValue::eTypeBoolean, true, true, nullptr, nullptr, "If true, LLDB will prompt you before quitting if there are any live processes being debugged. If false, LLDB will quit without asking in any case." },
+ { "stop-command-source-on-error", OptionValue::eTypeBoolean, true, true, nullptr, nullptr, "If true, LLDB will stop running a 'command source' script upon encountering an error." },
+ { nullptr , OptionValue::eTypeInvalid, true, 0 , nullptr, nullptr, nullptr }
};
enum
@@ -125,21 +131,21 @@ bool
CommandInterpreter::GetExpandRegexAliases () const
{
const uint32_t idx = ePropertyExpandRegexAliases;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean (nullptr, idx, g_properties[idx].default_uint_value != 0);
}
bool
CommandInterpreter::GetPromptOnQuit () const
{
const uint32_t idx = ePropertyPromptOnQuit;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean (nullptr, idx, g_properties[idx].default_uint_value != 0);
}
bool
CommandInterpreter::GetStopCmdSourceOnError () const
{
const uint32_t idx = ePropertyStopCmdSourceOnError;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean (nullptr, idx, g_properties[idx].default_uint_value != 0);
}
void
@@ -324,7 +330,7 @@ CommandInterpreter::Initialize ()
if (cmd_obj_sp)
{
alias_arguments_vector_sp.reset (new OptionArgVector);
-#if defined (__arm__)
+#if defined (__arm__) || defined (__arm64__) || defined (__aarch64__)
ProcessAliasOptionsArgs (cmd_obj_sp, "--", alias_arguments_vector_sp);
#else
ProcessAliasOptionsArgs (cmd_obj_sp, "--shell=" LLDB_DEFAULT_SHELL " --", alias_arguments_vector_sp);
@@ -351,6 +357,15 @@ CommandInterpreter::Initialize ()
}
}
+void
+CommandInterpreter::Clear()
+{
+ m_command_io_handler_sp.reset();
+
+ if (m_script_interpreter_ap)
+ m_script_interpreter_ap->Clear();
+}
+
const char *
CommandInterpreter::ProcessEmbeddedScriptCommands (const char *arg)
{
@@ -405,9 +420,9 @@ CommandInterpreter::LoadCommandDictionary ()
{"^(-.*)$", "breakpoint set %1"},
{"^(.*[^[:space:]])`(.*[^[:space:]])[[:space:]]*$", "breakpoint set --name '%2' --shlib '%1'"},
{"^\\&(.*[^[:space:]])[[:space:]]*$", "breakpoint set --name '%1' --skip-prologue=0"},
- {"^(.*[^[:space:]])[[:space:]]*$", "breakpoint set --name '%1'"}};
+ {"^[\"']?(.*[^[:space:]\"'])[\"']?[[:space:]]*$", "breakpoint set --name '%1'"}};
- size_t num_regexes = sizeof break_regexes/sizeof(char *[2]);
+ size_t num_regexes = llvm::array_lengthof(break_regexes);
std::unique_ptr<CommandObjectRegexCommand>
break_regex_cmd_ap(new CommandObjectRegexCommand (*this,
@@ -702,7 +717,7 @@ CommandInterpreter::GetCommandSP (const char *cmd_cstr, bool include_aliases, bo
CommandObjectSP user_match_sp, alias_match_sp, real_match_sp;
StringList local_matches;
- if (matches == NULL)
+ if (matches == nullptr)
matches = &local_matches;
unsigned int num_cmd_matches = 0;
@@ -830,17 +845,17 @@ CommandInterpreter::GetCommandSPExact (const char *cmd_cstr, bool include_aliase
Args cmd_words (cmd_cstr); // Break up the command string into words, in case it's a multi-word command.
CommandObjectSP ret_val; // Possibly empty return value.
- if (cmd_cstr == NULL)
+ if (cmd_cstr == nullptr)
return ret_val;
if (cmd_words.GetArgumentCount() == 1)
- return GetCommandSP(cmd_cstr, include_aliases, true, NULL);
+ return GetCommandSP(cmd_cstr, include_aliases, true, nullptr);
else
{
// We have a multi-word command (seemingly), so we need to do more work.
// First, get the cmd_obj_sp for the first word in the command.
- CommandObjectSP cmd_obj_sp = GetCommandSP (cmd_words.GetArgumentAtIndex (0), include_aliases, true, NULL);
- if (cmd_obj_sp.get() != NULL)
+ CommandObjectSP cmd_obj_sp = GetCommandSP (cmd_words.GetArgumentAtIndex (0), include_aliases, true, nullptr);
+ if (cmd_obj_sp.get() != nullptr)
{
// Loop through the rest of the words in the command (everything passed in was supposed to be part of a
// command name), and find the appropriate sub-command SP for each command word....
@@ -850,7 +865,7 @@ CommandInterpreter::GetCommandSPExact (const char *cmd_cstr, bool include_aliase
if (cmd_obj_sp->IsMultiwordObject())
{
cmd_obj_sp = cmd_obj_sp->GetSubcommandSP (cmd_words.GetArgumentAtIndex (j));
- if (cmd_obj_sp.get() == NULL)
+ if (cmd_obj_sp.get() == nullptr)
// The sub-command name was invalid. Fail and return the empty 'ret_val'.
return ret_val;
}
@@ -890,7 +905,7 @@ CommandInterpreter::GetCommandObject (const char *cmd_cstr, StringList *matches)
return command_obj;
// If there wasn't an exact match then look for an inexact one in just the commands
- command_obj = GetCommandSP(cmd_cstr, false, false, NULL).get();
+ command_obj = GetCommandSP(cmd_cstr, false, false, nullptr).get();
// Finally, if there wasn't an inexact match among the commands, look for an inexact
// match in both the commands and aliases.
@@ -1156,7 +1171,7 @@ CommandInterpreter::GetCommandObjectForCommand (std::string &command_string)
// This function finds the final, lowest-level, alias-resolved command object whose 'Execute' function will
// eventually be invoked by the given command line.
- CommandObject *cmd_obj = NULL;
+ CommandObject *cmd_obj = nullptr;
std::string white_space (" \t\v");
size_t start = command_string.find_first_not_of (white_space);
size_t end = 0;
@@ -1171,7 +1186,7 @@ CommandInterpreter::GetCommandObjectForCommand (std::string &command_string)
end = command_string.size();
std::string cmd_word = command_string.substr (start, end - start);
- if (cmd_obj == NULL)
+ if (cmd_obj == nullptr)
// Since cmd_obj is NULL we are on our first time through this loop. Check to see if cmd_word is a valid
// command or alias.
cmd_obj = GetCommandObject (cmd_word.c_str());
@@ -1325,7 +1340,7 @@ CommandInterpreter::BuildAliasResult (const char *alias_name,
std::string &alias_result,
CommandReturnObject &result)
{
- CommandObject *alias_cmd_obj = NULL;
+ CommandObject *alias_cmd_obj = nullptr;
Args cmd_args (raw_input_string.c_str());
alias_cmd_obj = GetCommandObject (alias_name);
StreamString result_str;
@@ -1363,7 +1378,7 @@ CommandInterpreter::BuildAliasResult (const char *alias_name,
int index = GetOptionArgumentPosition (value.c_str());
if (index == 0)
result_str.Printf ("%s", value.c_str());
- else if (index >= cmd_args.GetArgumentCount())
+ else if (static_cast<size_t>(index) >= cmd_args.GetArgumentCount())
{
result.AppendErrorWithFormat
@@ -1446,12 +1461,12 @@ CommandInterpreter::PreprocessCommand (std::string &command)
options.SetTryAllThreads(true);
options.SetTimeoutUsec(0);
- ExecutionResults expr_result = target->EvaluateExpression (expr_str.c_str(),
+ ExpressionResults expr_result = target->EvaluateExpression (expr_str.c_str(),
exe_ctx.GetFramePtr(),
expr_result_valobj_sp,
options);
- if (expr_result == eExecutionCompleted)
+ if (expr_result == eExpressionCompleted)
{
Scalar scalar;
if (expr_result_valobj_sp->ResolveValue (scalar))
@@ -1486,24 +1501,29 @@ CommandInterpreter::PreprocessCommand (std::string &command)
switch (expr_result)
{
- case eExecutionSetupError:
+ case eExpressionSetupError:
error.SetErrorStringWithFormat("expression setup error for the expression '%s'", expr_str.c_str());
break;
- case eExecutionCompleted:
+ case eExpressionParseError:
+ error.SetErrorStringWithFormat ("expression parse error for the expression '%s'", expr_str.c_str());
+ break;
+ case eExpressionResultUnavailable:
+ error.SetErrorStringWithFormat ("expression error fetching result for the expression '%s'", expr_str.c_str());
+ case eExpressionCompleted:
break;
- case eExecutionDiscarded:
+ case eExpressionDiscarded:
error.SetErrorStringWithFormat("expression discarded for the expression '%s'", expr_str.c_str());
break;
- case eExecutionInterrupted:
+ case eExpressionInterrupted:
error.SetErrorStringWithFormat("expression interrupted for the expression '%s'", expr_str.c_str());
break;
- case eExecutionHitBreakpoint:
+ case eExpressionHitBreakpoint:
error.SetErrorStringWithFormat("expression hit breakpoint for the expression '%s'", expr_str.c_str());
break;
- case eExecutionTimedOut:
+ case eExpressionTimedOut:
error.SetErrorStringWithFormat("expression timed out for the expression '%s'", expr_str.c_str());
break;
- case eExecutionStoppedForDebug:
+ case eExpressionStoppedForDebug:
error.SetErrorStringWithFormat("expression stop at entry point for debugging for the expression '%s'", expr_str.c_str());
break;
}
@@ -1530,7 +1550,7 @@ CommandInterpreter::HandleCommand (const char *command_line,
{
bool done = false;
- CommandObject *cmd_obj = NULL;
+ CommandObject *cmd_obj = nullptr;
bool wants_raw_input = false;
std::string command_string (command_line);
std::string original_command_string (command_line);
@@ -1540,7 +1560,7 @@ CommandInterpreter::HandleCommand (const char *command_line,
// Make a scoped cleanup object that will clear the crash description string
// on exit of this function.
- lldb_utility::CleanUp <const char *> crash_description_cleanup(NULL, Host::SetCrashDescription);
+ lldb_utility::CleanUp <const char *> crash_description_cleanup(nullptr, Host::SetCrashDescription);
if (log)
log->Printf ("Processing command: %s", command_line);
@@ -1574,7 +1594,7 @@ CommandInterpreter::HandleCommand (const char *command_line,
else if (command_string[non_space] == CommandHistory::g_repeat_char)
{
const char *history_string = m_command_history.FindString(command_string.c_str() + non_space);
- if (history_string == NULL)
+ if (history_string == nullptr)
{
result.AppendErrorWithFormat ("Could not find entry: %s in history", command_string.c_str());
result.SetStatus(eReturnStatusFailed);
@@ -1650,7 +1670,7 @@ CommandInterpreter::HandleCommand (const char *command_line,
char quote_char = '\0';
std::string suffix;
ExtractCommand (command_string, next_word, suffix, quote_char);
- if (cmd_obj == NULL)
+ if (cmd_obj == nullptr)
{
std::string full_name;
if (GetAliasFullName(next_word.c_str(), full_name))
@@ -1710,7 +1730,7 @@ CommandInterpreter::HandleCommand (const char *command_line,
}
}
- if (cmd_obj == NULL)
+ if (cmd_obj == nullptr)
{
const size_t num_matches = matches.GetSize();
if (matches.GetSize() > 1) {
@@ -1823,13 +1843,13 @@ CommandInterpreter::HandleCommand (const char *command_line,
// Take care of things like setting up the history command & calling the appropriate Execute method on the
// CommandObject, with the appropriate arguments.
- if (cmd_obj != NULL)
+ if (cmd_obj != nullptr)
{
if (add_to_history)
{
Args command_args (revised_command_line.GetData());
const char *repeat_command = cmd_obj->GetRepeatCommand(command_args, 0);
- if (repeat_command != NULL)
+ if (repeat_command != nullptr)
m_repeat_command.assign(repeat_command);
else
m_repeat_command.assign(original_command_string.c_str());
@@ -1931,7 +1951,7 @@ CommandInterpreter::HandleCompletionMatches (Args &parsed_line,
if (num_command_matches == 1
&& cmd_obj && cmd_obj->IsMultiwordObject()
- && matches.GetStringAtIndex(0) != NULL
+ && matches.GetStringAtIndex(0) != nullptr
&& strcmp (parsed_line.GetArgumentAtIndex(0), matches.GetStringAtIndex(0)) == 0)
{
if (parsed_line.GetArgumentCount() == 1)
@@ -1956,7 +1976,7 @@ CommandInterpreter::HandleCompletionMatches (Args &parsed_line,
// to complete the command.
// First see if there is a matching initial command:
CommandObject *command_object = GetCommandObject (parsed_line.GetArgumentAtIndex(0));
- if (command_object == NULL)
+ if (command_object == nullptr)
{
return 0;
}
@@ -2002,7 +2022,7 @@ CommandInterpreter::HandleCompletion (const char *current_line,
else if (first_arg[0] == CommandHistory::g_repeat_char)
{
const char *history_string = m_command_history.FindString (first_arg);
- if (history_string != NULL)
+ if (history_string != nullptr)
{
matches.Clear();
matches.InsertStringAtIndex(0, history_string);
@@ -2254,7 +2274,7 @@ CommandInterpreter::BuildAliasCommandArgs (CommandObject *alias_cmd_obj,
}
}
- else if (index >= cmd_args.GetArgumentCount())
+ else if (static_cast<size_t>(index) >= cmd_args.GetArgumentCount())
{
result.AppendErrorWithFormat
("Not enough arguments provided; you need at least %d arguments to use this alias.\n",
@@ -2364,17 +2384,21 @@ CommandInterpreter::SourceInitFile (bool in_cwd, CommandReturnObject &result)
// "-" and the name of the program. If this file doesn't exist, we fall
// back to just the "~/.lldbinit" file. We also obey any requests to not
// load the init files.
- const char *init_file_path = "~/.lldbinit";
+ llvm::SmallString<64> home_dir_path;
+ llvm::sys::path::home_directory(home_dir_path);
+ FileSpec profilePath(home_dir_path.c_str(), false);
+ profilePath.AppendPathComponent(".lldbinit");
+ std::string init_file_path = profilePath.GetPath();
if (m_skip_app_init_files == false)
{
- FileSpec program_file_spec (Host::GetProgramFileSpec());
+ FileSpec program_file_spec(HostInfo::GetProgramFileSpec());
const char *program_name = program_file_spec.GetFilename().AsCString();
if (program_name)
{
char program_init_file_name[PATH_MAX];
- ::snprintf (program_init_file_name, sizeof(program_init_file_name), "%s-%s", init_file_path, program_name);
+ ::snprintf (program_init_file_name, sizeof(program_init_file_name), "%s-%s", init_file_path.c_str(), program_name);
init_file.SetFile (program_init_file_name, true);
if (!init_file.Exists())
init_file.Clear();
@@ -2382,7 +2406,7 @@ CommandInterpreter::SourceInitFile (bool in_cwd, CommandReturnObject &result)
}
if (!init_file && !m_skip_lldbinit_files)
- init_file.SetFile (init_file_path, true);
+ init_file.SetFile (init_file_path.c_str(), false);
}
// If the file exists, tell HandleCommand to 'source' it; this will do the actual broadcasting
@@ -2392,7 +2416,7 @@ CommandInterpreter::SourceInitFile (bool in_cwd, CommandReturnObject &result)
{
const bool saved_batch = SetBatchCommandMode (true);
HandleCommandsFromFile (init_file,
- NULL, // Execution context
+ nullptr, // Execution context
eLazyBoolYes, // Stop on continue
eLazyBoolNo, // Stop on error
eLazyBoolNo, // Don't echo commands
@@ -2445,7 +2469,7 @@ CommandInterpreter::HandleCommands (const StringList &commands,
// If we've been given an execution context, set it at the start, but don't keep resetting it or we will
// cause series of commands that change the context, then do an operation that relies on that context to fail.
- if (override_context != NULL)
+ if (override_context != nullptr)
UpdateExecutionContext (override_context);
if (!stop_on_continue)
@@ -2475,9 +2499,9 @@ CommandInterpreter::HandleCommands (const StringList &commands,
if (!add_to_history)
m_command_source_depth++;
bool success = HandleCommand(cmd, add_to_history, tmp_result,
- NULL, /* override_context */
+ nullptr, /* override_context */
true, /* repeat_on_empty_command */
- override_context != NULL /* no_context_switching */);
+ override_context != nullptr /* no_context_switching */);
if (!add_to_history)
m_command_source_depth--;
@@ -2490,20 +2514,20 @@ CommandInterpreter::HandleCommands (const StringList &commands,
if (!success || !tmp_result.Succeeded())
{
const char *error_msg = tmp_result.GetErrorData();
- if (error_msg == NULL || error_msg[0] == '\0')
+ if (error_msg == nullptr || error_msg[0] == '\0')
error_msg = "<unknown error>.\n";
if (stop_on_error)
{
- result.AppendErrorWithFormat("Aborting reading of commands after command #%zu: '%s' failed with %s",
- idx, cmd, error_msg);
+ result.AppendErrorWithFormat("Aborting reading of commands after command #%" PRIu64 ": '%s' failed with %s",
+ (uint64_t)idx, cmd, error_msg);
result.SetStatus (eReturnStatusFailed);
m_debugger.SetAsyncExecution (old_async_execution);
return;
}
else if (print_results)
{
- result.AppendMessageWithFormat ("Command #%zu '%s' failed with %s",
- idx + 1,
+ result.AppendMessageWithFormat ("Command #%" PRIu64 " '%s' failed with %s",
+ (uint64_t)idx + 1,
cmd,
error_msg);
}
@@ -2527,10 +2551,10 @@ CommandInterpreter::HandleCommands (const StringList &commands,
// status in our real result before returning. This is an error if the continue was not the
// last command in the set of commands to be run.
if (idx != num_lines - 1)
- result.AppendErrorWithFormat("Aborting reading of commands after command #%zu: '%s' continued the target.\n",
- idx + 1, cmd);
+ result.AppendErrorWithFormat("Aborting reading of commands after command #%" PRIu64 ": '%s' continued the target.\n",
+ (uint64_t)idx + 1, cmd);
else
- result.AppendMessageWithFormat ("Command #%zu '%s' continued the target.\n", idx + 1, cmd);
+ result.AppendMessageWithFormat("Command #%" PRIu64 " '%s' continued the target.\n", (uint64_t)idx + 1, cmd);
result.SetStatus(tmp_result.GetStatus());
m_debugger.SetAsyncExecution (old_async_execution);
@@ -2660,9 +2684,10 @@ CommandInterpreter::HandleCommandsFromFile (FileSpec &cmd_file,
empty_stream_sp, // Pass in an empty stream so we inherit the top input reader output stream
empty_stream_sp, // Pass in an empty stream so we inherit the top input reader error stream
flags,
- NULL, // Pass in NULL for "editline_name" so no history is saved, or written
+ nullptr, // Pass in NULL for "editline_name" so no history is saved, or written
debugger.GetPrompt(),
false, // Not multi-line
+ 0,
*this));
const bool old_async_execution = debugger.GetAsyncExecution();
@@ -2699,11 +2724,11 @@ CommandInterpreter::HandleCommandsFromFile (FileSpec &cmd_file,
ScriptInterpreter *
CommandInterpreter::GetScriptInterpreter (bool can_create)
{
- if (m_script_interpreter_ap.get() != NULL)
+ if (m_script_interpreter_ap.get() != nullptr)
return m_script_interpreter_ap.get();
if (!can_create)
- return NULL;
+ return nullptr;
// <rdar://problem/11751427>
// we need to protect the initialization of the script interpreter
@@ -2928,7 +2953,7 @@ CommandInterpreter::FindCommandsForApropos (const char *search_word, StringList
void
CommandInterpreter::UpdateExecutionContext (ExecutionContext *override_context)
{
- if (override_context != NULL)
+ if (override_context != nullptr)
{
m_exe_ctx_ref = *override_context;
}
@@ -3041,6 +3066,24 @@ CommandInterpreter::IOHandlerInputComplete (IOHandler &io_handler, std::string &
}
}
+bool
+CommandInterpreter::IOHandlerInterrupt (IOHandler &io_handler)
+{
+ ExecutionContext exe_ctx (GetExecutionContext());
+ Process *process = exe_ctx.GetProcessPtr();
+
+ if (process)
+ {
+ StateType state = process->GetState();
+ if (StateIsRunningState(state))
+ {
+ process->Halt();
+ return true; // Don't do any updating when we are running
+ }
+ }
+ return false;
+}
+
void
CommandInterpreter::GetLLDBCommandsFromIOHandler (const char *prompt,
IOHandlerDelegate &delegate,
@@ -3052,6 +3095,7 @@ CommandInterpreter::GetLLDBCommandsFromIOHandler (const char *prompt,
"lldb", // Name of input reader for history
prompt, // Prompt
true, // Get multiple lines
+ 0, // Don't show line numbers
delegate)); // IOHandlerDelegate
if (io_handler_sp)
@@ -3077,6 +3121,7 @@ CommandInterpreter::GetPythonCommandsFromIOHandler (const char *prompt,
"lldb-python", // Name of input reader for history
prompt, // Prompt
true, // Get multiple lines
+ 0, // Don't show line numbers
delegate)); // IOHandlerDelegate
if (io_handler_sp)
@@ -3100,17 +3145,23 @@ void
CommandInterpreter::RunCommandInterpreter(bool auto_handle_events,
bool spawn_thread)
{
- const bool multiple_lines = false; // Only get one line at a time
- if (!m_command_io_handler_sp)
- m_command_io_handler_sp.reset(new IOHandlerEditline (m_debugger,
- m_debugger.GetInputFile(),
- m_debugger.GetOutputFile(),
- m_debugger.GetErrorFile(),
- eHandleCommandFlagEchoCommand | eHandleCommandFlagPrintResult,
- "lldb",
- m_debugger.GetPrompt(),
- multiple_lines,
- *this));
+ // Only get one line at a time
+ const bool multiple_lines = false;
+
+ // Always re-create the IOHandlerEditline in case the input
+ // changed. The old instance might have had a non-interactive
+ // input and now it does or vice versa.
+ m_command_io_handler_sp.reset(new IOHandlerEditline (m_debugger,
+ m_debugger.GetInputFile(),
+ m_debugger.GetOutputFile(),
+ m_debugger.GetErrorFile(),
+ eHandleCommandFlagEchoCommand | eHandleCommandFlagPrintResult,
+ "lldb",
+ m_debugger.GetPrompt(),
+ multiple_lines,
+ 0, // Don't show line numbers
+ *this));
+
m_debugger.PushIOHandler(m_command_io_handler_sp);
if (auto_handle_events)
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/CommandObject.cpp b/contrib/llvm/tools/lldb/source/Interpreter/CommandObject.cpp
index c699536..3fdbf99 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/CommandObject.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/CommandObject.cpp
@@ -56,8 +56,9 @@ CommandObject::CommandObject
m_is_alias (false),
m_flags (flags),
m_arguments(),
- m_command_override_callback (NULL),
- m_command_override_baton (NULL)
+ m_deprecated_command_override_callback (nullptr),
+ m_command_override_callback (nullptr),
+ m_command_override_baton (nullptr)
{
if (help && help[0])
m_cmd_help_short = help;
@@ -88,7 +89,7 @@ CommandObject::GetSyntax ()
{
StreamString syntax_str;
syntax_str.Printf ("%s", GetCommandName());
- if (GetOptions() != NULL)
+ if (GetOptions() != nullptr)
syntax_str.Printf (" <cmd-options>");
if (m_arguments.size() > 0)
{
@@ -144,7 +145,7 @@ CommandObject::GetOptions ()
{
// By default commands don't have options unless this virtual function
// is overridden by base classes.
- return NULL;
+ return nullptr;
}
bool
@@ -156,7 +157,7 @@ CommandObject::ParseOptions
{
// See if the subclass has options?
Options *options = GetOptions();
- if (options != NULL)
+ if (options != nullptr)
{
Error error;
options->NotifyOptionParsingStarting();
@@ -251,7 +252,7 @@ CommandObject::CheckRequirements (CommandReturnObject &result)
return false;
}
- if ((flags & eFlagRequiresRegContext) && (m_exe_ctx.GetRegisterContext() == NULL))
+ if ((flags & eFlagRequiresRegContext) && (m_exe_ctx.GetRegisterContext() == nullptr))
{
result.AppendError (GetInvalidRegContextDescription());
return false;
@@ -268,7 +269,7 @@ CommandObject::CheckRequirements (CommandReturnObject &result)
if (GetFlags().AnySet (CommandObject::eFlagProcessMustBeLaunched | CommandObject::eFlagProcessMustBePaused))
{
Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
- if (process == NULL)
+ if (process == nullptr)
{
// A process that is not running is considered paused.
if (GetFlags().Test(CommandObject::eFlagProcessMustBeLaunched))
@@ -335,7 +336,7 @@ class CommandDictCommandPartialMatch
bool operator() (const std::pair<std::string, lldb::CommandObjectSP> map_element) const
{
// A NULL or empty string matches everything.
- if (m_match_str == NULL || *m_match_str == '\0')
+ if (m_match_str == nullptr || *m_match_str == '\0')
return true;
return map_element.first.find (m_match_str, 0) == 0;
@@ -392,7 +393,7 @@ CommandObject::HandleCompletion
CommandReturnObject result;
OptionElementVector opt_element_vector;
- if (cur_options != NULL)
+ if (cur_options != nullptr)
{
// Re-insert the dummy command name string which will have been
// stripped off:
@@ -453,7 +454,7 @@ CommandObject::HelpTextContainsWord (const char *search_word)
found_word = true;
if (!found_word
- && GetOptions() != NULL)
+ && GetOptions() != nullptr)
{
StreamString usage_help;
GetOptions()->GenerateOptionUsage (usage_help, this);
@@ -477,10 +478,10 @@ CommandObject::GetNumArgumentEntries ()
CommandObject::CommandArgumentEntry *
CommandObject::GetArgumentEntryAtIndex (int idx)
{
- if (idx < m_arguments.size())
+ if (static_cast<size_t>(idx) < m_arguments.size())
return &(m_arguments[idx]);
- return NULL;
+ return nullptr;
}
CommandObject::ArgumentTableEntry *
@@ -492,7 +493,7 @@ CommandObject::FindArgumentDataByType (CommandArgumentType arg_type)
if (table[i].arg_type == arg_type)
return (ArgumentTableEntry *) &(table[i]);
- return NULL;
+ return nullptr;
}
void
@@ -771,7 +772,7 @@ static const char *
FormatHelpTextCallback ()
{
- static char* help_text_ptr = NULL;
+ static char* help_text_ptr = nullptr;
if (help_text_ptr)
return help_text_ptr;
@@ -804,7 +805,7 @@ FormatHelpTextCallback ()
static const char *
LanguageTypeHelpTextCallback ()
{
- static char* help_text_ptr = NULL;
+ static char* help_text_ptr = nullptr;
if (help_text_ptr)
return help_text_ptr;
@@ -900,7 +901,7 @@ void
CommandObject::GenerateHelpText (Stream &output_strm)
{
CommandInterpreter& interpreter = GetCommandInterpreter();
- if (GetOptions() != NULL)
+ if (GetOptions() != nullptr)
{
if (WantsRawCommandString())
{
@@ -913,7 +914,7 @@ CommandObject::GenerateHelpText (Stream &output_strm)
output_strm.Printf ("\nSyntax: %s\n", GetSyntax());
GetOptions()->GenerateOptionUsage (output_strm, this);
const char *long_help = GetHelpLong();
- if ((long_help != NULL)
+ if ((long_help != nullptr)
&& (strlen (long_help) > 0))
output_strm.Printf ("\n%s", long_help);
if (WantsRawCommandString() && !WantsCompletion())
@@ -950,7 +951,7 @@ CommandObject::GenerateHelpText (Stream &output_strm)
else
{
const char *long_help = GetHelpLong();
- if ((long_help != NULL)
+ if ((long_help != nullptr)
&& (strlen (long_help) > 0))
output_strm.Printf ("%s", long_help);
else if (WantsRawCommandString())
@@ -990,7 +991,7 @@ CommandObject::GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_typ
{
if (arg_type >=0 && arg_type < eArgTypeLastArg)
return g_arguments_data[arg_type].arg_name;
- return NULL;
+ return nullptr;
}
@@ -999,20 +1000,19 @@ CommandObject::GetArgumentDescriptionAsCString (const lldb::CommandArgumentType
{
if (arg_type >=0 && arg_type < eArgTypeLastArg)
return g_arguments_data[arg_type].help_text;
- return NULL;
+ return nullptr;
}
bool
CommandObjectParsed::Execute (const char *args_string, CommandReturnObject &result)
{
- CommandOverrideCallback command_callback = GetOverrideCallback();
bool handled = false;
Args cmd_args (args_string);
- if (command_callback)
+ if (HasOverrideCallback())
{
Args full_args (GetCommandName ());
full_args.AppendArguments(cmd_args);
- handled = command_callback (GetOverrideCallbackBaton(), full_args.GetConstArgumentVector());
+ handled = InvokeOverrideCallback (full_args.GetConstArgumentVector(), result);
}
if (!handled)
{
@@ -1040,16 +1040,15 @@ CommandObjectParsed::Execute (const char *args_string, CommandReturnObject &resu
bool
CommandObjectRaw::Execute (const char *args_string, CommandReturnObject &result)
{
- CommandOverrideCallback command_callback = GetOverrideCallback();
bool handled = false;
- if (command_callback)
+ if (HasOverrideCallback())
{
std::string full_command (GetCommandName ());
full_command += ' ';
full_command += args_string;
- const char *argv[2] = { NULL, NULL };
+ const char *argv[2] = { nullptr, nullptr };
argv[0] = full_command.c_str();
- handled = command_callback (GetOverrideCallbackBaton(), argv);
+ handled = InvokeOverrideCallback (argv, result);
}
if (!handled)
{
@@ -1068,7 +1067,7 @@ const char *arch_helper()
if (g_archs_help.Empty())
{
StringList archs;
- ArchSpec::AutoComplete(NULL, archs);
+ ArchSpec::AutoComplete(nullptr, archs);
g_archs_help.Printf("These are the supported architecture names:\n");
archs.Join("\n", g_archs_help);
}
@@ -1078,86 +1077,86 @@ const char *arch_helper()
CommandObject::ArgumentTableEntry
CommandObject::g_arguments_data[] =
{
- { eArgTypeAddress, "address", CommandCompletions::eNoCompletion, { NULL, false }, "A valid address in the target program's execution space." },
- { eArgTypeAddressOrExpression, "address-expression", CommandCompletions::eNoCompletion, { NULL, false }, "An expression that resolves to an address." },
- { eArgTypeAliasName, "alias-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of an abbreviation (alias) for a debugger command." },
- { eArgTypeAliasOptions, "options-for-aliased-command", CommandCompletions::eNoCompletion, { NULL, false }, "Command options to be used as part of an alias (abbreviation) definition. (See 'help commands alias' for more information.)" },
+ { eArgTypeAddress, "address", CommandCompletions::eNoCompletion, { nullptr, false }, "A valid address in the target program's execution space." },
+ { eArgTypeAddressOrExpression, "address-expression", CommandCompletions::eNoCompletion, { nullptr, false }, "An expression that resolves to an address." },
+ { eArgTypeAliasName, "alias-name", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of an abbreviation (alias) for a debugger command." },
+ { eArgTypeAliasOptions, "options-for-aliased-command", CommandCompletions::eNoCompletion, { nullptr, false }, "Command options to be used as part of an alias (abbreviation) definition. (See 'help commands alias' for more information.)" },
{ eArgTypeArchitecture, "arch", CommandCompletions::eArchitectureCompletion, { arch_helper, true }, "The architecture name, e.g. i386 or x86_64." },
- { eArgTypeBoolean, "boolean", CommandCompletions::eNoCompletion, { NULL, false }, "A Boolean value: 'true' or 'false'" },
- { eArgTypeBreakpointID, "breakpt-id", CommandCompletions::eNoCompletion, { BreakpointIDHelpTextCallback, false }, NULL },
- { eArgTypeBreakpointIDRange, "breakpt-id-list", CommandCompletions::eNoCompletion, { BreakpointIDRangeHelpTextCallback, false }, NULL },
- { eArgTypeByteSize, "byte-size", CommandCompletions::eNoCompletion, { NULL, false }, "Number of bytes to use." },
- { eArgTypeClassName, "class-name", CommandCompletions::eNoCompletion, { NULL, false }, "Then name of a class from the debug information in the program." },
- { eArgTypeCommandName, "cmd-name", CommandCompletions::eNoCompletion, { NULL, false }, "A debugger command (may be multiple words), without any options or arguments." },
- { eArgTypeCount, "count", CommandCompletions::eNoCompletion, { NULL, false }, "An unsigned integer." },
- { eArgTypeDirectoryName, "directory", CommandCompletions::eDiskDirectoryCompletion, { NULL, false }, "A directory name." },
- { eArgTypeDisassemblyFlavor, "disassembly-flavor", CommandCompletions::eNoCompletion, { NULL, false }, "A disassembly flavor recognized by your disassembly plugin. Currently the only valid options are \"att\" and \"intel\" for Intel targets" },
- { eArgTypeDescriptionVerbosity, "description-verbosity", CommandCompletions::eNoCompletion, { NULL, false }, "How verbose the output of 'po' should be." },
- { eArgTypeEndAddress, "end-address", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
- { eArgTypeExpression, "expr", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
- { eArgTypeExpressionPath, "expr-path", CommandCompletions::eNoCompletion, { ExprPathHelpTextCallback, true }, NULL },
- { eArgTypeExprFormat, "expression-format", CommandCompletions::eNoCompletion, { NULL, false }, "[ [bool|b] | [bin] | [char|c] | [oct|o] | [dec|i|d|u] | [hex|x] | [float|f] | [cstr|s] ]" },
- { eArgTypeFilename, "filename", CommandCompletions::eDiskFileCompletion, { NULL, false }, "The name of a file (can include path)." },
- { eArgTypeFormat, "format", CommandCompletions::eNoCompletion, { FormatHelpTextCallback, true }, NULL },
- { eArgTypeFrameIndex, "frame-index", CommandCompletions::eNoCompletion, { NULL, false }, "Index into a thread's list of frames." },
- { eArgTypeFullName, "fullname", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
- { eArgTypeFunctionName, "function-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a function." },
- { eArgTypeFunctionOrSymbol, "function-or-symbol", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a function or symbol." },
- { eArgTypeGDBFormat, "gdb-format", CommandCompletions::eNoCompletion, { GDBFormatHelpTextCallback, true }, NULL },
- { eArgTypeIndex, "index", CommandCompletions::eNoCompletion, { NULL, false }, "An index into a list." },
- { eArgTypeLanguage, "language", CommandCompletions::eNoCompletion, { LanguageTypeHelpTextCallback, true }, NULL },
- { eArgTypeLineNum, "linenum", CommandCompletions::eNoCompletion, { NULL, false }, "Line number in a source file." },
- { eArgTypeLogCategory, "log-category", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a category within a log channel, e.g. all (try \"log list\" to see a list of all channels and their categories." },
- { eArgTypeLogChannel, "log-channel", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a log channel, e.g. process.gdb-remote (try \"log list\" to see a list of all channels and their categories)." },
- { eArgTypeMethod, "method", CommandCompletions::eNoCompletion, { NULL, false }, "A C++ method name." },
- { eArgTypeName, "name", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
- { eArgTypeNewPathPrefix, "new-path-prefix", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
- { eArgTypeNumLines, "num-lines", CommandCompletions::eNoCompletion, { NULL, false }, "The number of lines to use." },
- { eArgTypeNumberPerLine, "number-per-line", CommandCompletions::eNoCompletion, { NULL, false }, "The number of items per line to display." },
- { eArgTypeOffset, "offset", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
- { eArgTypeOldPathPrefix, "old-path-prefix", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
- { eArgTypeOneLiner, "one-line-command", CommandCompletions::eNoCompletion, { NULL, false }, "A command that is entered as a single line of text." },
- { eArgTypePath, "path", CommandCompletions::eDiskFileCompletion, { NULL, false }, "Path." },
- { eArgTypePermissionsNumber, "perms-numeric", CommandCompletions::eNoCompletion, { NULL, false }, "Permissions given as an octal number (e.g. 755)." },
- { eArgTypePermissionsString, "perms=string", CommandCompletions::eNoCompletion, { NULL, false }, "Permissions given as a string value (e.g. rw-r-xr--)." },
- { eArgTypePid, "pid", CommandCompletions::eNoCompletion, { NULL, false }, "The process ID number." },
- { eArgTypePlugin, "plugin", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
- { eArgTypeProcessName, "process-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of the process." },
- { eArgTypePythonClass, "python-class", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a Python class." },
- { eArgTypePythonFunction, "python-function", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a Python function." },
- { eArgTypePythonScript, "python-script", CommandCompletions::eNoCompletion, { NULL, false }, "Source code written in Python." },
- { eArgTypeQueueName, "queue-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of the thread queue." },
- { eArgTypeRegisterName, "register-name", CommandCompletions::eNoCompletion, { RegisterNameHelpTextCallback, true }, NULL },
- { eArgTypeRegularExpression, "regular-expression", CommandCompletions::eNoCompletion, { NULL, false }, "A regular expression." },
- { eArgTypeRunArgs, "run-args", CommandCompletions::eNoCompletion, { NULL, false }, "Arguments to be passed to the target program when it starts executing." },
- { eArgTypeRunMode, "run-mode", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
- { eArgTypeScriptedCommandSynchronicity, "script-cmd-synchronicity", CommandCompletions::eNoCompletion, { NULL, false }, "The synchronicity to use to run scripted commands with regard to LLDB event system." },
- { eArgTypeScriptLang, "script-language", CommandCompletions::eNoCompletion, { NULL, false }, "The scripting language to be used for script-based commands. Currently only Python is valid." },
- { eArgTypeSearchWord, "search-word", CommandCompletions::eNoCompletion, { NULL, false }, "The word for which you wish to search for information about." },
- { eArgTypeSelector, "selector", CommandCompletions::eNoCompletion, { NULL, false }, "An Objective-C selector name." },
- { eArgTypeSettingIndex, "setting-index", CommandCompletions::eNoCompletion, { NULL, false }, "An index into a settings variable that is an array (try 'settings list' to see all the possible settings variables and their types)." },
- { eArgTypeSettingKey, "setting-key", CommandCompletions::eNoCompletion, { NULL, false }, "A key into a settings variables that is a dictionary (try 'settings list' to see all the possible settings variables and their types)." },
- { eArgTypeSettingPrefix, "setting-prefix", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a settable internal debugger variable up to a dot ('.'), e.g. 'target.process.'" },
- { eArgTypeSettingVariableName, "setting-variable-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a settable internal debugger variable. Type 'settings list' to see a complete list of such variables." },
- { eArgTypeShlibName, "shlib-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a shared library." },
- { eArgTypeSourceFile, "source-file", CommandCompletions::eSourceFileCompletion, { NULL, false }, "The name of a source file.." },
- { eArgTypeSortOrder, "sort-order", CommandCompletions::eNoCompletion, { NULL, false }, "Specify a sort order when dumping lists." },
- { eArgTypeStartAddress, "start-address", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
- { eArgTypeSummaryString, "summary-string", CommandCompletions::eNoCompletion, { SummaryStringHelpTextCallback, true }, NULL },
- { eArgTypeSymbol, "symbol", CommandCompletions::eSymbolCompletion, { NULL, false }, "Any symbol name (function name, variable, argument, etc.)" },
- { eArgTypeThreadID, "thread-id", CommandCompletions::eNoCompletion, { NULL, false }, "Thread ID number." },
- { eArgTypeThreadIndex, "thread-index", CommandCompletions::eNoCompletion, { NULL, false }, "Index into the process' list of threads." },
- { eArgTypeThreadName, "thread-name", CommandCompletions::eNoCompletion, { NULL, false }, "The thread's name." },
- { eArgTypeUnsignedInteger, "unsigned-integer", CommandCompletions::eNoCompletion, { NULL, false }, "An unsigned integer." },
- { eArgTypeUnixSignal, "unix-signal", CommandCompletions::eNoCompletion, { NULL, false }, "A valid Unix signal name or number (e.g. SIGKILL, KILL or 9)." },
- { eArgTypeVarName, "variable-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a variable in your program." },
- { eArgTypeValue, "value", CommandCompletions::eNoCompletion, { NULL, false }, "A value could be anything, depending on where and how it is used." },
- { eArgTypeWidth, "width", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." },
- { eArgTypeNone, "none", CommandCompletions::eNoCompletion, { NULL, false }, "No help available for this." },
- { eArgTypePlatform, "platform-name", CommandCompletions::ePlatformPluginCompletion, { NULL, false }, "The name of an installed platform plug-in . Type 'platform list' to see a complete list of installed platforms." },
- { eArgTypeWatchpointID, "watchpt-id", CommandCompletions::eNoCompletion, { NULL, false }, "Watchpoint IDs are positive integers." },
- { eArgTypeWatchpointIDRange, "watchpt-id-list", CommandCompletions::eNoCompletion, { NULL, false }, "For example, '1-3' or '1 to 3'." },
- { eArgTypeWatchType, "watch-type", CommandCompletions::eNoCompletion, { NULL, false }, "Specify the type for a watchpoint." }
+ { eArgTypeBoolean, "boolean", CommandCompletions::eNoCompletion, { nullptr, false }, "A Boolean value: 'true' or 'false'" },
+ { eArgTypeBreakpointID, "breakpt-id", CommandCompletions::eNoCompletion, { BreakpointIDHelpTextCallback, false }, nullptr },
+ { eArgTypeBreakpointIDRange, "breakpt-id-list", CommandCompletions::eNoCompletion, { BreakpointIDRangeHelpTextCallback, false }, nullptr },
+ { eArgTypeByteSize, "byte-size", CommandCompletions::eNoCompletion, { nullptr, false }, "Number of bytes to use." },
+ { eArgTypeClassName, "class-name", CommandCompletions::eNoCompletion, { nullptr, false }, "Then name of a class from the debug information in the program." },
+ { eArgTypeCommandName, "cmd-name", CommandCompletions::eNoCompletion, { nullptr, false }, "A debugger command (may be multiple words), without any options or arguments." },
+ { eArgTypeCount, "count", CommandCompletions::eNoCompletion, { nullptr, false }, "An unsigned integer." },
+ { eArgTypeDirectoryName, "directory", CommandCompletions::eDiskDirectoryCompletion, { nullptr, false }, "A directory name." },
+ { eArgTypeDisassemblyFlavor, "disassembly-flavor", CommandCompletions::eNoCompletion, { nullptr, false }, "A disassembly flavor recognized by your disassembly plugin. Currently the only valid options are \"att\" and \"intel\" for Intel targets" },
+ { eArgTypeDescriptionVerbosity, "description-verbosity", CommandCompletions::eNoCompletion, { nullptr, false }, "How verbose the output of 'po' should be." },
+ { eArgTypeEndAddress, "end-address", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
+ { eArgTypeExpression, "expr", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
+ { eArgTypeExpressionPath, "expr-path", CommandCompletions::eNoCompletion, { ExprPathHelpTextCallback, true }, nullptr },
+ { eArgTypeExprFormat, "expression-format", CommandCompletions::eNoCompletion, { nullptr, false }, "[ [bool|b] | [bin] | [char|c] | [oct|o] | [dec|i|d|u] | [hex|x] | [float|f] | [cstr|s] ]" },
+ { eArgTypeFilename, "filename", CommandCompletions::eDiskFileCompletion, { nullptr, false }, "The name of a file (can include path)." },
+ { eArgTypeFormat, "format", CommandCompletions::eNoCompletion, { FormatHelpTextCallback, true }, nullptr },
+ { eArgTypeFrameIndex, "frame-index", CommandCompletions::eNoCompletion, { nullptr, false }, "Index into a thread's list of frames." },
+ { eArgTypeFullName, "fullname", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
+ { eArgTypeFunctionName, "function-name", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a function." },
+ { eArgTypeFunctionOrSymbol, "function-or-symbol", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a function or symbol." },
+ { eArgTypeGDBFormat, "gdb-format", CommandCompletions::eNoCompletion, { GDBFormatHelpTextCallback, true }, nullptr },
+ { eArgTypeIndex, "index", CommandCompletions::eNoCompletion, { nullptr, false }, "An index into a list." },
+ { eArgTypeLanguage, "language", CommandCompletions::eNoCompletion, { LanguageTypeHelpTextCallback, true }, nullptr },
+ { eArgTypeLineNum, "linenum", CommandCompletions::eNoCompletion, { nullptr, false }, "Line number in a source file." },
+ { eArgTypeLogCategory, "log-category", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a category within a log channel, e.g. all (try \"log list\" to see a list of all channels and their categories." },
+ { eArgTypeLogChannel, "log-channel", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a log channel, e.g. process.gdb-remote (try \"log list\" to see a list of all channels and their categories)." },
+ { eArgTypeMethod, "method", CommandCompletions::eNoCompletion, { nullptr, false }, "A C++ method name." },
+ { eArgTypeName, "name", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
+ { eArgTypeNewPathPrefix, "new-path-prefix", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
+ { eArgTypeNumLines, "num-lines", CommandCompletions::eNoCompletion, { nullptr, false }, "The number of lines to use." },
+ { eArgTypeNumberPerLine, "number-per-line", CommandCompletions::eNoCompletion, { nullptr, false }, "The number of items per line to display." },
+ { eArgTypeOffset, "offset", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
+ { eArgTypeOldPathPrefix, "old-path-prefix", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
+ { eArgTypeOneLiner, "one-line-command", CommandCompletions::eNoCompletion, { nullptr, false }, "A command that is entered as a single line of text." },
+ { eArgTypePath, "path", CommandCompletions::eDiskFileCompletion, { nullptr, false }, "Path." },
+ { eArgTypePermissionsNumber, "perms-numeric", CommandCompletions::eNoCompletion, { nullptr, false }, "Permissions given as an octal number (e.g. 755)." },
+ { eArgTypePermissionsString, "perms=string", CommandCompletions::eNoCompletion, { nullptr, false }, "Permissions given as a string value (e.g. rw-r-xr--)." },
+ { eArgTypePid, "pid", CommandCompletions::eNoCompletion, { nullptr, false }, "The process ID number." },
+ { eArgTypePlugin, "plugin", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
+ { eArgTypeProcessName, "process-name", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of the process." },
+ { eArgTypePythonClass, "python-class", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a Python class." },
+ { eArgTypePythonFunction, "python-function", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a Python function." },
+ { eArgTypePythonScript, "python-script", CommandCompletions::eNoCompletion, { nullptr, false }, "Source code written in Python." },
+ { eArgTypeQueueName, "queue-name", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of the thread queue." },
+ { eArgTypeRegisterName, "register-name", CommandCompletions::eNoCompletion, { RegisterNameHelpTextCallback, true }, nullptr },
+ { eArgTypeRegularExpression, "regular-expression", CommandCompletions::eNoCompletion, { nullptr, false }, "A regular expression." },
+ { eArgTypeRunArgs, "run-args", CommandCompletions::eNoCompletion, { nullptr, false }, "Arguments to be passed to the target program when it starts executing." },
+ { eArgTypeRunMode, "run-mode", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
+ { eArgTypeScriptedCommandSynchronicity, "script-cmd-synchronicity", CommandCompletions::eNoCompletion, { nullptr, false }, "The synchronicity to use to run scripted commands with regard to LLDB event system." },
+ { eArgTypeScriptLang, "script-language", CommandCompletions::eNoCompletion, { nullptr, false }, "The scripting language to be used for script-based commands. Currently only Python is valid." },
+ { eArgTypeSearchWord, "search-word", CommandCompletions::eNoCompletion, { nullptr, false }, "The word for which you wish to search for information about." },
+ { eArgTypeSelector, "selector", CommandCompletions::eNoCompletion, { nullptr, false }, "An Objective-C selector name." },
+ { eArgTypeSettingIndex, "setting-index", CommandCompletions::eNoCompletion, { nullptr, false }, "An index into a settings variable that is an array (try 'settings list' to see all the possible settings variables and their types)." },
+ { eArgTypeSettingKey, "setting-key", CommandCompletions::eNoCompletion, { nullptr, false }, "A key into a settings variables that is a dictionary (try 'settings list' to see all the possible settings variables and their types)." },
+ { eArgTypeSettingPrefix, "setting-prefix", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a settable internal debugger variable up to a dot ('.'), e.g. 'target.process.'" },
+ { eArgTypeSettingVariableName, "setting-variable-name", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a settable internal debugger variable. Type 'settings list' to see a complete list of such variables." },
+ { eArgTypeShlibName, "shlib-name", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a shared library." },
+ { eArgTypeSourceFile, "source-file", CommandCompletions::eSourceFileCompletion, { nullptr, false }, "The name of a source file.." },
+ { eArgTypeSortOrder, "sort-order", CommandCompletions::eNoCompletion, { nullptr, false }, "Specify a sort order when dumping lists." },
+ { eArgTypeStartAddress, "start-address", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
+ { eArgTypeSummaryString, "summary-string", CommandCompletions::eNoCompletion, { SummaryStringHelpTextCallback, true }, nullptr },
+ { eArgTypeSymbol, "symbol", CommandCompletions::eSymbolCompletion, { nullptr, false }, "Any symbol name (function name, variable, argument, etc.)" },
+ { eArgTypeThreadID, "thread-id", CommandCompletions::eNoCompletion, { nullptr, false }, "Thread ID number." },
+ { eArgTypeThreadIndex, "thread-index", CommandCompletions::eNoCompletion, { nullptr, false }, "Index into the process' list of threads." },
+ { eArgTypeThreadName, "thread-name", CommandCompletions::eNoCompletion, { nullptr, false }, "The thread's name." },
+ { eArgTypeUnsignedInteger, "unsigned-integer", CommandCompletions::eNoCompletion, { nullptr, false }, "An unsigned integer." },
+ { eArgTypeUnixSignal, "unix-signal", CommandCompletions::eNoCompletion, { nullptr, false }, "A valid Unix signal name or number (e.g. SIGKILL, KILL or 9)." },
+ { eArgTypeVarName, "variable-name", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a variable in your program." },
+ { eArgTypeValue, "value", CommandCompletions::eNoCompletion, { nullptr, false }, "A value could be anything, depending on where and how it is used." },
+ { eArgTypeWidth, "width", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
+ { eArgTypeNone, "none", CommandCompletions::eNoCompletion, { nullptr, false }, "No help available for this." },
+ { eArgTypePlatform, "platform-name", CommandCompletions::ePlatformPluginCompletion, { nullptr, false }, "The name of an installed platform plug-in . Type 'platform list' to see a complete list of installed platforms." },
+ { eArgTypeWatchpointID, "watchpt-id", CommandCompletions::eNoCompletion, { nullptr, false }, "Watchpoint IDs are positive integers." },
+ { eArgTypeWatchpointIDRange, "watchpt-id-list", CommandCompletions::eNoCompletion, { nullptr, false }, "For example, '1-3' or '1 to 3'." },
+ { eArgTypeWatchType, "watch-type", CommandCompletions::eNoCompletion, { nullptr, false }, "Specify the type for a watchpoint." }
};
const CommandObject::ArgumentTableEntry*
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/CommandObjectRegexCommand.cpp b/contrib/llvm/tools/lldb/source/Interpreter/CommandObjectRegexCommand.cpp
index 59cf1f0..d27320d 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/CommandObjectRegexCommand.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/CommandObjectRegexCommand.cpp
@@ -86,11 +86,11 @@ CommandObjectRegexCommand::DoExecute
result.GetOutputStream().Printf("%s\n", new_command.c_str());
// Pass in true for "no context switching". The command that called us should have set up the context
// appropriately, we shouldn't have to redo that.
- return m_interpreter.HandleCommand(new_command.c_str(), eLazyBoolCalculate, result, NULL, true, true);
+ return m_interpreter.HandleCommand(new_command.c_str(), eLazyBoolCalculate, result, nullptr, true, true);
}
}
result.SetStatus(eReturnStatusFailed);
- if (GetSyntax() != NULL)
+ if (GetSyntax() != nullptr)
result.AppendError (GetSyntax());
else
result.AppendErrorWithFormat ("Command contents '%s' failed to match any regular expression in the '%s' regex command.\n",
@@ -136,7 +136,7 @@ CommandObjectRegexCommand::HandleCompletion (Args &input,
completion_str.c_str(),
match_start_point,
max_return_elements,
- NULL,
+ nullptr,
word_complete,
matches);
return matches.GetSize();
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/CommandObjectScript.cpp b/contrib/llvm/tools/lldb/source/Interpreter/CommandObjectScript.cpp
index aff507d..9c67e42 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/CommandObjectScript.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/CommandObjectScript.cpp
@@ -66,7 +66,7 @@ CommandObjectScript::DoExecute
ScriptInterpreter *script_interpreter = m_interpreter.GetScriptInterpreter ();
- if (script_interpreter == NULL)
+ if (script_interpreter == nullptr)
{
result.AppendError("no script interpreter");
result.SetStatus (eReturnStatusFailed);
@@ -75,7 +75,7 @@ CommandObjectScript::DoExecute
DataVisualization::ForceUpdate(); // script might change Python code we use for formatting.. make sure we keep up to date with it
- if (command == NULL || command[0] == '\0')
+ if (command == nullptr || command[0] == '\0')
{
script_interpreter->ExecuteInterpreterLoop ();
result.SetStatus (eReturnStatusSuccessFinishNoResult);
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/CommandOptionValidators.cpp b/contrib/llvm/tools/lldb/source/Interpreter/CommandOptionValidators.cpp
new file mode 100644
index 0000000..7d66de5
--- /dev/null
+++ b/contrib/llvm/tools/lldb/source/Interpreter/CommandOptionValidators.cpp
@@ -0,0 +1,39 @@
+//===-- CommandOptionValidators.cpp -----------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Interpreter/CommandOptionValidators.h"
+
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Target/Platform.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+bool PosixPlatformCommandOptionValidator::IsValid(Platform &platform, const ExecutionContext &target) const
+{
+ llvm::Triple::OSType os = platform.GetSystemArchitecture().GetTriple().getOS();
+ switch (os)
+ {
+ // Are there any other platforms that are not POSIX-compatible?
+ case llvm::Triple::Win32:
+ return false;
+ default:
+ return true;
+ }
+}
+
+const char* PosixPlatformCommandOptionValidator::ShortConditionString() const
+{
+ return "POSIX";
+}
+
+const char* PosixPlatformCommandOptionValidator::LongConditionString() const
+{
+ return "Option only valid for POSIX-compliant hosts.";
+}
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/CommandReturnObject.cpp b/contrib/llvm/tools/lldb/source/Interpreter/CommandReturnObject.cpp
index 9c63753..1b54187 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/CommandReturnObject.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/CommandReturnObject.cpp
@@ -46,7 +46,8 @@ CommandReturnObject::CommandReturnObject () :
m_out_stream (),
m_err_stream (),
m_status (eReturnStatusStarted),
- m_did_change_process_state (false)
+ m_did_change_process_state (false),
+ m_interactive (true)
{
}
@@ -141,7 +142,7 @@ void
CommandReturnObject::SetError (const Error &error, const char *fallback_error_cstr)
{
const char *error_cstr = error.AsCString();
- if (error_cstr == NULL)
+ if (error_cstr == nullptr)
error_cstr = fallback_error_cstr;
SetError(error_cstr);
}
@@ -203,6 +204,7 @@ CommandReturnObject::Clear()
static_cast<StreamString *>(stream_sp.get())->Clear();
m_status = eReturnStatusStarted;
m_did_change_process_state = false;
+ m_interactive = true;
}
bool
@@ -217,3 +219,17 @@ CommandReturnObject::SetDidChangeProcessState (bool b)
m_did_change_process_state = b;
}
+
+bool
+CommandReturnObject::GetInteractive () const
+{
+ return m_interactive;
+}
+
+void
+CommandReturnObject::SetInteractive (bool b)
+{
+ m_interactive = b;
+}
+
+
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupArchitecture.cpp b/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupArchitecture.cpp
index d8f3567..3a45409 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupArchitecture.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupArchitecture.cpp
@@ -30,7 +30,7 @@ OptionGroupArchitecture::~OptionGroupArchitecture ()
static OptionDefinition
g_option_table[] =
{
- { LLDB_OPT_SET_1 , false, "arch" , 'a', OptionParser::eRequiredArgument, NULL, 0, eArgTypeArchitecture , "Specify the architecture for the target."},
+ { LLDB_OPT_SET_1 , false, "arch" , 'a', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeArchitecture , "Specify the architecture for the target."},
};
uint32_t
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupBoolean.cpp b/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupBoolean.cpp
index feb1353..0c502cc 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupBoolean.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupBoolean.cpp
@@ -30,8 +30,9 @@ OptionGroupBoolean::OptionGroupBoolean (uint32_t usage_mask,
m_option_definition.required = required;
m_option_definition.long_option = long_option;
m_option_definition.short_option = short_option;
+ m_option_definition.validator = nullptr;
m_option_definition.option_has_arg = no_argument_toggle_default ? OptionParser::eNoArgument : OptionParser::eRequiredArgument;
- m_option_definition.enum_values = NULL;
+ m_option_definition.enum_values = nullptr;
m_option_definition.completion_type = 0;
m_option_definition.argument_type = eArgTypeBoolean;
m_option_definition.usage_text = usage_text;
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupFile.cpp b/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupFile.cpp
index 48469a8..9bfe8dd 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupFile.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupFile.cpp
@@ -30,8 +30,9 @@ OptionGroupFile::OptionGroupFile (uint32_t usage_mask,
m_option_definition.required = required;
m_option_definition.long_option = long_option;
m_option_definition.short_option = short_option;
+ m_option_definition.validator = nullptr;
m_option_definition.option_has_arg = OptionParser::eRequiredArgument;
- m_option_definition.enum_values = NULL;
+ m_option_definition.enum_values = nullptr;
m_option_definition.completion_type = completion_type;
m_option_definition.argument_type = argument_type;
m_option_definition.usage_text = usage_text;
@@ -70,8 +71,9 @@ OptionGroupFileList::OptionGroupFileList (uint32_t usage_mask,
m_option_definition.required = required;
m_option_definition.long_option = long_option;
m_option_definition.short_option = short_option;
+ m_option_definition.validator = nullptr;
m_option_definition.option_has_arg = OptionParser::eRequiredArgument;
- m_option_definition.enum_values = NULL;
+ m_option_definition.enum_values = nullptr;
m_option_definition.completion_type = completion_type;
m_option_definition.argument_type = argument_type;
m_option_definition.usage_text = usage_text;
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupFormat.cpp b/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupFormat.cpp
index 5cae378..601a784 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupFormat.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupFormat.cpp
@@ -42,10 +42,10 @@ OptionGroupFormat::~OptionGroupFormat ()
static OptionDefinition
g_option_table[] =
{
-{ LLDB_OPT_SET_1, false, "format" ,'f', OptionParser::eRequiredArgument, NULL, 0, eArgTypeFormat , "Specify a format to be used for display."},
-{ LLDB_OPT_SET_2, false, "gdb-format",'G', OptionParser::eRequiredArgument, NULL, 0, eArgTypeGDBFormat, "Specify a format using a GDB format specifier string."},
-{ LLDB_OPT_SET_3, false, "size" ,'s', OptionParser::eRequiredArgument, NULL, 0, eArgTypeByteSize , "The size in bytes to use when displaying with the selected format."},
-{ LLDB_OPT_SET_4, false, "count" ,'c', OptionParser::eRequiredArgument, NULL, 0, eArgTypeCount , "The number of total items to display."},
+{ LLDB_OPT_SET_1, false, "format" ,'f', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeFormat , "Specify a format to be used for display."},
+{ LLDB_OPT_SET_2, false, "gdb-format",'G', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeGDBFormat, "Specify a format using a GDB format specifier string."},
+{ LLDB_OPT_SET_3, false, "size" ,'s', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeByteSize , "The size in bytes to use when displaying with the selected format."},
+{ LLDB_OPT_SET_4, false, "count" ,'c', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeCount , "The number of total items to display."},
};
uint32_t
@@ -109,7 +109,7 @@ OptionGroupFormat::SetOptionValue (CommandInterpreter &interpreter,
case 'G':
{
- char *end = NULL;
+ char *end = nullptr;
const char *gdb_format_cstr = option_arg;
uint64_t count = 0;
if (::isdigit (gdb_format_cstr[0]))
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupOutputFile.cpp b/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupOutputFile.cpp
index 3bb8ab3..ec9e166 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupOutputFile.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupOutputFile.cpp
@@ -28,11 +28,15 @@ OptionGroupOutputFile::~OptionGroupOutputFile ()
{
}
+static const uint32_t SHORT_OPTION_APND = 0x61706e64; // 'apnd'
+
static OptionDefinition
g_option_table[] =
{
- { LLDB_OPT_SET_1 , false, "outfile", 'o', OptionParser::eRequiredArgument, NULL, 0, eArgTypeFilename , "Specify a path for capturing command output."},
- { LLDB_OPT_SET_1 , false, "append-outfile" , 'apnd', OptionParser::eNoArgument, NULL, 0, eArgTypeNone , "Append to the the file specified with '--outfile <path>'."},
+ { LLDB_OPT_SET_1 , false, "outfile", 'o', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeFilename , "Specify a path for capturing command output."},
+ { LLDB_OPT_SET_1 , false, "append-outfile" , SHORT_OPTION_APND,
+ OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone ,
+ "Append to the the file specified with '--outfile <path>'."},
};
uint32_t
@@ -61,7 +65,7 @@ OptionGroupOutputFile::SetOptionValue (CommandInterpreter &interpreter,
error = m_file.SetValueFromCString (option_arg);
break;
- case 'apnd':
+ case SHORT_OPTION_APND:
m_append.SetCurrentValue(true);
break;
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupPlatform.cpp b/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupPlatform.cpp
index 83e28bd..9ffd5f0 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupPlatform.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupPlatform.cpp
@@ -85,10 +85,10 @@ OptionGroupPlatform::OptionParsingStarting (CommandInterpreter &interpreter)
static OptionDefinition
g_option_table[] =
{
- { LLDB_OPT_SET_ALL, false, "platform", 'p', OptionParser::eRequiredArgument, NULL, 0, eArgTypePlatform, "Specify name of the platform to use for this target, creating the platform if necessary."},
- { LLDB_OPT_SET_ALL, false, "version" , 'v', OptionParser::eRequiredArgument, NULL, 0, eArgTypeNone, "Specify the initial SDK version to use prior to connecting." },
- { LLDB_OPT_SET_ALL, false, "build" , 'b', OptionParser::eRequiredArgument, NULL, 0, eArgTypeNone, "Specify the initial SDK build number." },
- { LLDB_OPT_SET_ALL, false, "sysroot" , 'S', OptionParser::eRequiredArgument, NULL, 0, eArgTypeFilename, "Specify the SDK root directory that contains a root of all remote system files." }
+ { LLDB_OPT_SET_ALL, false, "platform", 'p', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePlatform, "Specify name of the platform to use for this target, creating the platform if necessary."},
+ { LLDB_OPT_SET_ALL, false, "version" , 'v', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeNone, "Specify the initial SDK version to use prior to connecting." },
+ { LLDB_OPT_SET_ALL, false, "build" , 'b', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeNone, "Specify the initial SDK build number." },
+ { LLDB_OPT_SET_ALL, false, "sysroot" , 'S', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeFilename, "Specify the SDK root directory that contains a root of all remote system files." }
};
const OptionDefinition*
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupString.cpp b/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupString.cpp
index 37a70d0..9bc1c94 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupString.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupString.cpp
@@ -31,8 +31,9 @@ OptionGroupString::OptionGroupString (uint32_t usage_mask,
m_option_definition.required = required;
m_option_definition.long_option = long_option;
m_option_definition.short_option = short_option;
+ m_option_definition.validator = nullptr;
m_option_definition.option_has_arg = OptionParser::eRequiredArgument;
- m_option_definition.enum_values = NULL;
+ m_option_definition.enum_values = nullptr;
m_option_definition.completion_type = completion_type;
m_option_definition.argument_type = argument_type;
m_option_definition.usage_text = usage_text;
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupUInt64.cpp b/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupUInt64.cpp
index b66c845..440c2a7 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupUInt64.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupUInt64.cpp
@@ -31,8 +31,9 @@ OptionGroupUInt64::OptionGroupUInt64 (uint32_t usage_mask,
m_option_definition.required = required;
m_option_definition.long_option = long_option;
m_option_definition.short_option = short_option;
+ m_option_definition.validator = nullptr;
m_option_definition.option_has_arg = OptionParser::eRequiredArgument;
- m_option_definition.enum_values = NULL;
+ m_option_definition.enum_values = nullptr;
m_option_definition.completion_type = completion_type;
m_option_definition.argument_type = argument_type;
m_option_definition.usage_text = usage_text;
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupUUID.cpp b/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupUUID.cpp
index fb3ebcf..43f7386 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupUUID.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupUUID.cpp
@@ -30,7 +30,7 @@ OptionGroupUUID::~OptionGroupUUID ()
static OptionDefinition
g_option_table[] =
{
- { LLDB_OPT_SET_1 , false, "uuid", 'u', OptionParser::eRequiredArgument, NULL, 0, eArgTypeNone, "A module UUID value."},
+ { LLDB_OPT_SET_1 , false, "uuid", 'u', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeNone, "A module UUID value."},
};
uint32_t
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp b/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
index c79f49d..125e5fb 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
@@ -34,18 +34,18 @@ OptionGroupValueObjectDisplay::~OptionGroupValueObjectDisplay ()
static OptionDefinition
g_option_table[] =
{
- { LLDB_OPT_SET_1, false, "dynamic-type", 'd', OptionParser::eRequiredArgument, g_dynamic_value_types, 0, eArgTypeNone, "Show the object as its full dynamic type, not its static type, if available."},
- { LLDB_OPT_SET_1, false, "synthetic-type", 'S', OptionParser::eRequiredArgument, NULL, 0, eArgTypeBoolean, "Show the object obeying its synthetic provider, if available."},
- { LLDB_OPT_SET_1, false, "depth", 'D', OptionParser::eRequiredArgument, NULL, 0, eArgTypeCount, "Set the max recurse depth when dumping aggregate types (default is infinity)."},
- { LLDB_OPT_SET_1, false, "flat", 'F', OptionParser::eNoArgument, NULL, 0, eArgTypeNone, "Display results in a flat format that uses expression paths for each variable or member."},
- { LLDB_OPT_SET_1, false, "location", 'L', OptionParser::eNoArgument, NULL, 0, eArgTypeNone, "Show variable location information."},
- { LLDB_OPT_SET_1, false, "object-description", 'O', OptionParser::eNoArgument, NULL, 0, eArgTypeNone, "Print as an Objective-C object."},
- { LLDB_OPT_SET_1, false, "ptr-depth", 'P', OptionParser::eRequiredArgument, NULL, 0, eArgTypeCount, "The number of pointers to be traversed when dumping values (default is zero)."},
- { LLDB_OPT_SET_1, false, "show-types", 'T', OptionParser::eNoArgument, NULL, 0, eArgTypeNone, "Show variable types when dumping values."},
- { LLDB_OPT_SET_1, false, "no-summary-depth", 'Y', OptionParser::eOptionalArgument, NULL, 0, eArgTypeCount, "Set the depth at which omitting summary information stops (default is 1)."},
- { LLDB_OPT_SET_1, false, "raw-output", 'R', OptionParser::eNoArgument, NULL, 0, eArgTypeNone, "Don't use formatting options."},
- { LLDB_OPT_SET_1, false, "show-all-children", 'A', OptionParser::eNoArgument, NULL, 0, eArgTypeNone, "Ignore the upper bound on the number of children to show."},
- { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
+ { LLDB_OPT_SET_1, false, "dynamic-type", 'd', OptionParser::eRequiredArgument, nullptr, g_dynamic_value_types, 0, eArgTypeNone, "Show the object as its full dynamic type, not its static type, if available."},
+ { LLDB_OPT_SET_1, false, "synthetic-type", 'S', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "Show the object obeying its synthetic provider, if available."},
+ { LLDB_OPT_SET_1, false, "depth", 'D', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeCount, "Set the max recurse depth when dumping aggregate types (default is infinity)."},
+ { LLDB_OPT_SET_1, false, "flat", 'F', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Display results in a flat format that uses expression paths for each variable or member."},
+ { LLDB_OPT_SET_1, false, "location", 'L', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Show variable location information."},
+ { LLDB_OPT_SET_1, false, "object-description", 'O', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Print as an Objective-C object."},
+ { LLDB_OPT_SET_1, false, "ptr-depth", 'P', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeCount, "The number of pointers to be traversed when dumping values (default is zero)."},
+ { LLDB_OPT_SET_1, false, "show-types", 'T', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Show variable types when dumping values."},
+ { LLDB_OPT_SET_1, false, "no-summary-depth", 'Y', OptionParser::eOptionalArgument, nullptr, nullptr, 0, eArgTypeCount, "Set the depth at which omitting summary information stops (default is 1)."},
+ { LLDB_OPT_SET_1, false, "raw-output", 'R', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Don't use formatting options."},
+ { LLDB_OPT_SET_1, false, "show-all-children", 'A', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Ignore the upper bound on the number of children to show."},
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
uint32_t
@@ -139,7 +139,7 @@ OptionGroupValueObjectDisplay::OptionParsingStarting (CommandInterpreter &interp
ignore_cap = false;
Target *target = interpreter.GetExecutionContext().GetTargetPtr();
- if (target != NULL)
+ if (target != nullptr)
use_dynamic = target->GetPreferDynamicValue();
else
{
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupVariable.cpp b/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupVariable.cpp
index 31c2547..05cf3f7 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupVariable.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupVariable.cpp
@@ -28,14 +28,14 @@ using namespace lldb_private;
static OptionDefinition
g_option_table[] =
{
- { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "no-args", 'a', OptionParser::eNoArgument, NULL, 0, eArgTypeNone, "Omit function arguments."},
- { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "no-locals", 'l', OptionParser::eNoArgument, NULL, 0, eArgTypeNone, "Omit local variables."},
- { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "show-globals", 'g', OptionParser::eNoArgument, NULL, 0, eArgTypeNone, "Show the current frame source file global and static variables."},
- { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "show-declaration",'c', OptionParser::eNoArgument, NULL, 0, eArgTypeNone, "Show variable declaration information (source file and line where the variable was declared)."},
- { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "regex", 'r', OptionParser::eNoArgument, NULL, 0, eArgTypeRegularExpression, "The <variable-name> argument for name lookups are regular expressions."},
- { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "scope", 's', OptionParser::eNoArgument, NULL, 0, eArgTypeNone, "Show variable scope (argument, local, global, static)."},
- { LLDB_OPT_SET_1, false, "summary", 'y', OptionParser::eRequiredArgument, NULL, 0, eArgTypeName, "Specify the summary that the variable output should use."},
- { LLDB_OPT_SET_2, false, "summary-string", 'z', OptionParser::eRequiredArgument, NULL, 0, eArgTypeName, "Specify a summary string to use to format the variable output."},
+ { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "no-args", 'a', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Omit function arguments."},
+ { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "no-locals", 'l', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Omit local variables."},
+ { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "show-globals", 'g', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Show the current frame source file global and static variables."},
+ { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "show-declaration",'c', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Show variable declaration information (source file and line where the variable was declared)."},
+ { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "regex", 'r', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeRegularExpression, "The <variable-name> argument for name lookups are regular expressions."},
+ { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "scope", 's', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Show variable scope (argument, local, global, static)."},
+ { LLDB_OPT_SET_1, false, "summary", 'y', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeName, "Specify the summary that the variable output should use."},
+ { LLDB_OPT_SET_2, false, "summary-string", 'z', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeName, "Specify a summary string to use to format the variable output."},
};
static Error
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupWatchpoint.cpp b/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupWatchpoint.cpp
index 09dc8ed..f4d8df1 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupWatchpoint.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/OptionGroupWatchpoint.cpp
@@ -25,7 +25,7 @@ static OptionEnumValueElement g_watch_type[] =
{ OptionGroupWatchpoint::eWatchRead, "read", "Watch for read"},
{ OptionGroupWatchpoint::eWatchWrite, "write", "Watch for write"},
{ OptionGroupWatchpoint::eWatchReadWrite, "read_write", "Watch for read/write"},
- { 0, NULL, NULL }
+ { 0, nullptr, nullptr }
};
static OptionEnumValueElement g_watch_size[] =
@@ -34,14 +34,14 @@ static OptionEnumValueElement g_watch_size[] =
{ 2, "2", "Watch for byte size of 2"},
{ 4, "4", "Watch for byte size of 4"},
{ 8, "8", "Watch for byte size of 8"},
- { 0, NULL, NULL }
+ { 0, nullptr, nullptr }
};
static OptionDefinition
g_option_table[] =
{
- { LLDB_OPT_SET_1, false, "watch", 'w', OptionParser::eRequiredArgument, g_watch_type, 0, eArgTypeWatchType, "Specify the type of watching to perform."},
- { LLDB_OPT_SET_1, false, "xsize", 'x', OptionParser::eRequiredArgument, g_watch_size, 0, eArgTypeByteSize, "Number of bytes to use to watch a region."}
+ { LLDB_OPT_SET_1, false, "watch", 'w', OptionParser::eRequiredArgument, nullptr, g_watch_type, 0, eArgTypeWatchType, "Specify the type of watching to perform."},
+ { LLDB_OPT_SET_1, false, "xsize", 'x', OptionParser::eRequiredArgument, nullptr, g_watch_size, 0, eArgTypeByteSize, "Number of bytes to use to watch a region."}
};
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/OptionValue.cpp b/contrib/llvm/tools/lldb/source/Interpreter/OptionValue.cpp
index 1f6b03d..bc1e1c4 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/OptionValue.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/OptionValue.cpp
@@ -60,7 +60,7 @@ OptionValue::GetAsBoolean ()
{
if (GetType () == OptionValue::eTypeBoolean)
return static_cast<OptionValueBoolean *>(this);
- return NULL;
+ return nullptr;
}
const OptionValueBoolean *
@@ -68,7 +68,7 @@ OptionValue::GetAsBoolean () const
{
if (GetType () == OptionValue::eTypeBoolean)
return static_cast<const OptionValueBoolean *>(this);
- return NULL;
+ return nullptr;
}
@@ -77,7 +77,7 @@ OptionValue::GetAsFileSpec ()
{
if (GetType () == OptionValue::eTypeFileSpec)
return static_cast<OptionValueFileSpec *>(this);
- return NULL;
+ return nullptr;
}
@@ -86,7 +86,7 @@ OptionValue::GetAsFileSpec () const
{
if (GetType () == OptionValue::eTypeFileSpec)
return static_cast<const OptionValueFileSpec *>(this);
- return NULL;
+ return nullptr;
}
@@ -95,7 +95,7 @@ OptionValue::GetAsFileSpecList ()
{
if (GetType () == OptionValue::eTypeFileSpecList)
return static_cast<OptionValueFileSpecList *>(this);
- return NULL;
+ return nullptr;
}
@@ -104,7 +104,7 @@ OptionValue::GetAsFileSpecList () const
{
if (GetType () == OptionValue::eTypeFileSpecList)
return static_cast<const OptionValueFileSpecList *>(this);
- return NULL;
+ return nullptr;
}
@@ -113,7 +113,7 @@ OptionValue::GetAsArch ()
{
if (GetType () == OptionValue::eTypeArch)
return static_cast<OptionValueArch *>(this);
- return NULL;
+ return nullptr;
}
@@ -122,7 +122,7 @@ OptionValue::GetAsArch () const
{
if (GetType () == OptionValue::eTypeArch)
return static_cast<const OptionValueArch *>(this);
- return NULL;
+ return nullptr;
}
OptionValueArray *
@@ -130,7 +130,7 @@ OptionValue::GetAsArray ()
{
if (GetType () == OptionValue::eTypeArray)
return static_cast<OptionValueArray *>(this);
- return NULL;
+ return nullptr;
}
@@ -139,7 +139,7 @@ OptionValue::GetAsArray () const
{
if (GetType () == OptionValue::eTypeArray)
return static_cast<const OptionValueArray *>(this);
- return NULL;
+ return nullptr;
}
OptionValueArgs *
@@ -147,7 +147,7 @@ OptionValue::GetAsArgs ()
{
if (GetType () == OptionValue::eTypeArgs)
return static_cast<OptionValueArgs *>(this);
- return NULL;
+ return nullptr;
}
@@ -156,7 +156,7 @@ OptionValue::GetAsArgs () const
{
if (GetType () == OptionValue::eTypeArgs)
return static_cast<const OptionValueArgs *>(this);
- return NULL;
+ return nullptr;
}
OptionValueDictionary *
@@ -164,7 +164,7 @@ OptionValue::GetAsDictionary ()
{
if (GetType () == OptionValue::eTypeDictionary)
return static_cast<OptionValueDictionary *>(this);
- return NULL;
+ return nullptr;
}
const OptionValueDictionary *
@@ -172,7 +172,7 @@ OptionValue::GetAsDictionary () const
{
if (GetType () == OptionValue::eTypeDictionary)
return static_cast<const OptionValueDictionary *>(this);
- return NULL;
+ return nullptr;
}
OptionValueEnumeration *
@@ -180,7 +180,7 @@ OptionValue::GetAsEnumeration ()
{
if (GetType () == OptionValue::eTypeEnum)
return static_cast<OptionValueEnumeration *>(this);
- return NULL;
+ return nullptr;
}
const OptionValueEnumeration *
@@ -188,7 +188,7 @@ OptionValue::GetAsEnumeration () const
{
if (GetType () == OptionValue::eTypeEnum)
return static_cast<const OptionValueEnumeration *>(this);
- return NULL;
+ return nullptr;
}
OptionValueFormat *
@@ -196,7 +196,7 @@ OptionValue::GetAsFormat ()
{
if (GetType () == OptionValue::eTypeFormat)
return static_cast<OptionValueFormat *>(this);
- return NULL;
+ return nullptr;
}
const OptionValueFormat *
@@ -204,7 +204,7 @@ OptionValue::GetAsFormat () const
{
if (GetType () == OptionValue::eTypeFormat)
return static_cast<const OptionValueFormat *>(this);
- return NULL;
+ return nullptr;
}
OptionValuePathMappings *
@@ -212,7 +212,7 @@ OptionValue::GetAsPathMappings ()
{
if (GetType () == OptionValue::eTypePathMap)
return static_cast<OptionValuePathMappings *>(this);
- return NULL;
+ return nullptr;
}
const OptionValuePathMappings *
@@ -220,7 +220,7 @@ OptionValue::GetAsPathMappings () const
{
if (GetType () == OptionValue::eTypePathMap)
return static_cast<const OptionValuePathMappings *>(this);
- return NULL;
+ return nullptr;
}
OptionValueProperties *
@@ -228,7 +228,7 @@ OptionValue::GetAsProperties ()
{
if (GetType () == OptionValue::eTypeProperties)
return static_cast<OptionValueProperties *>(this);
- return NULL;
+ return nullptr;
}
const OptionValueProperties *
@@ -236,7 +236,7 @@ OptionValue::GetAsProperties () const
{
if (GetType () == OptionValue::eTypeProperties)
return static_cast<const OptionValueProperties *>(this);
- return NULL;
+ return nullptr;
}
OptionValueRegex *
@@ -244,7 +244,7 @@ OptionValue::GetAsRegex ()
{
if (GetType () == OptionValue::eTypeRegex)
return static_cast<OptionValueRegex *>(this);
- return NULL;
+ return nullptr;
}
const OptionValueRegex *
@@ -252,7 +252,7 @@ OptionValue::GetAsRegex () const
{
if (GetType () == OptionValue::eTypeRegex)
return static_cast<const OptionValueRegex *>(this);
- return NULL;
+ return nullptr;
}
OptionValueSInt64 *
@@ -260,7 +260,7 @@ OptionValue::GetAsSInt64 ()
{
if (GetType () == OptionValue::eTypeSInt64)
return static_cast<OptionValueSInt64 *>(this);
- return NULL;
+ return nullptr;
}
const OptionValueSInt64 *
@@ -268,7 +268,7 @@ OptionValue::GetAsSInt64 () const
{
if (GetType () == OptionValue::eTypeSInt64)
return static_cast<const OptionValueSInt64 *>(this);
- return NULL;
+ return nullptr;
}
OptionValueString *
@@ -276,7 +276,7 @@ OptionValue::GetAsString ()
{
if (GetType () == OptionValue::eTypeString)
return static_cast<OptionValueString *>(this);
- return NULL;
+ return nullptr;
}
const OptionValueString *
@@ -284,7 +284,7 @@ OptionValue::GetAsString () const
{
if (GetType () == OptionValue::eTypeString)
return static_cast<const OptionValueString *>(this);
- return NULL;
+ return nullptr;
}
OptionValueUInt64 *
@@ -292,7 +292,7 @@ OptionValue::GetAsUInt64 ()
{
if (GetType () == OptionValue::eTypeUInt64)
return static_cast<OptionValueUInt64 *>(this);
- return NULL;
+ return nullptr;
}
const OptionValueUInt64 *
@@ -300,7 +300,7 @@ OptionValue::GetAsUInt64 () const
{
if (GetType () == OptionValue::eTypeUInt64)
return static_cast<const OptionValueUInt64 *>(this);
- return NULL;
+ return nullptr;
}
OptionValueUUID *
@@ -308,7 +308,7 @@ OptionValue::GetAsUUID ()
{
if (GetType () == OptionValue::eTypeUUID)
return static_cast<OptionValueUUID *>(this);
- return NULL;
+ return nullptr;
}
@@ -317,7 +317,7 @@ OptionValue::GetAsUUID () const
{
if (GetType () == OptionValue::eTypeUUID)
return static_cast<const OptionValueUUID *>(this);
- return NULL;
+ return nullptr;
}
@@ -422,7 +422,7 @@ OptionValue::GetRegexValue () const
const OptionValueRegex *option_value = GetAsRegex ();
if (option_value)
return option_value->GetCurrentValue();
- return NULL;
+ return nullptr;
}
@@ -533,7 +533,7 @@ OptionValue::GetBuiltinTypeAsCString (Type t)
case eTypeUInt64: return "unsigned";
case eTypeUUID: return "uuid";
}
- return NULL;
+ return nullptr;
}
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/OptionValueArch.cpp b/contrib/llvm/tools/lldb/source/Interpreter/OptionValueArch.cpp
index 92fedff..6d283d6 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/OptionValueArch.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/OptionValueArch.cpp
@@ -100,7 +100,7 @@ OptionValueArch::AutoComplete (CommandInterpreter &interpreter,
s,
match_start_point,
max_return_elements,
- NULL,
+ nullptr,
word_complete,
matches);
return matches.GetSize();
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/OptionValueArray.cpp b/contrib/llvm/tools/lldb/source/Interpreter/OptionValueArray.cpp
index 9a01558..769aadd 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/OptionValueArray.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/OptionValueArray.cpp
@@ -90,12 +90,12 @@ OptionValueArray::GetSubValue (const ExecutionContext *exe_ctx,
const char *end_bracket = strchr (name+1, ']');
if (end_bracket)
{
- const char *sub_value = NULL;
+ const char *sub_value = nullptr;
if (end_bracket[1])
sub_value = end_bracket + 1;
std::string index_str (name+1, end_bracket);
const size_t array_count = m_values.size();
- int32_t idx = Args::StringToSInt32(index_str.c_str(), INT32_MAX, 0, NULL);
+ int32_t idx = Args::StringToSInt32(index_str.c_str(), INT32_MAX, 0, nullptr);
if (idx != INT32_MAX)
{
;
@@ -222,7 +222,8 @@ OptionValueArray::SetArgs (const Args &args, VarSetOperationType op)
size_t i;
for (i=0; i<argc; ++i)
{
- const int idx = Args::StringToSInt32(args.GetArgumentAtIndex(i), INT32_MAX);
+ const size_t idx =
+ Args::StringToSInt32(args.GetArgumentAtIndex(i), INT32_MAX);
if (idx >= size)
{
all_indexes_valid = false;
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/OptionValueBoolean.cpp b/contrib/llvm/tools/lldb/source/Interpreter/OptionValueBoolean.cpp
index 6471943..bf153a1 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/OptionValueBoolean.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/OptionValueBoolean.cpp
@@ -16,6 +16,7 @@
#include "lldb/Core/Stream.h"
#include "lldb/Core/StringList.h"
#include "lldb/Interpreter/Args.h"
+#include "llvm/ADT/STLExtras.h"
using namespace lldb;
using namespace lldb_private;
@@ -58,7 +59,7 @@ OptionValueBoolean::SetValueFromCString (const char *value_cstr,
}
else
{
- if (value_cstr == NULL)
+ if (value_cstr == nullptr)
error.SetErrorString ("invalid boolean string value: NULL");
else if (value_cstr[0] == '\0')
error.SetErrorString ("invalid boolean string value <empty>");
@@ -110,7 +111,7 @@ OptionValueBoolean::AutoComplete (CommandInterpreter &interpreter,
{ "1" , 1 },
{ "0" , 1 },
};
- const size_t k_num_autocomplete_entries = sizeof(g_autocomplete_entries)/sizeof(StringEntry);
+ const size_t k_num_autocomplete_entries = llvm::array_lengthof(g_autocomplete_entries);
if (s && s[0])
{
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/OptionValueDictionary.cpp b/contrib/llvm/tools/lldb/source/Interpreter/OptionValueDictionary.cpp
index 61f8aba..b560937 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/OptionValueDictionary.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/OptionValueDictionary.cpp
@@ -91,7 +91,7 @@ OptionValueDictionary::GetArgs (Args &args) const
{
StreamString strm;
strm.Printf("%s=", pos->first.GetCString());
- pos->second->DumpValue(NULL, strm, eDumpOptionValue|eDumpOptionRaw);
+ pos->second->DumpValue(nullptr, strm, eDumpOptionValue|eDumpOptionRaw);
args.AppendArgument(strm.GetString().c_str());
}
return args.GetArgumentCount();
@@ -210,7 +210,7 @@ OptionValueDictionary::SetArgs (const Args &args, VarSetOperationType op)
case eVarSetOperationInsertBefore:
case eVarSetOperationInsertAfter:
case eVarSetOperationInvalid:
- error = OptionValue::SetValueFromCString (NULL, op);
+ error = OptionValue::SetValueFromCString (nullptr, op);
break;
}
return error;
@@ -230,14 +230,14 @@ OptionValueDictionary::GetSubValue (const ExecutionContext *exe_ctx, const char
if (name && name[0])
{
- const char *sub_name = NULL;
+ const char *sub_name = nullptr;
ConstString key;
const char *open_bracket = ::strchr (name, '[');
if (open_bracket)
{
const char *key_start = open_bracket + 1;
- const char *key_end = NULL;
+ const char *key_end = nullptr;
switch (open_bracket[1])
{
case '\'':
@@ -314,7 +314,7 @@ OptionValueDictionary::GetSubValue (const ExecutionContext *exe_ctx, const char
}
}
}
- if (!value_sp && error.AsCString() == NULL)
+ if (!value_sp && error.AsCString() == nullptr)
{
error.SetErrorStringWithFormat ("invalid value path '%s', %s values only support '[<key>]' subvalues where <key> a string value optionally delimitted by single or double quotes",
name,
@@ -334,7 +334,7 @@ OptionValueDictionary::SetSubValue (const ExecutionContext *exe_ctx, VarSetOpera
error = value_sp->SetValueFromCString(value, op);
else
{
- if (error.AsCString() == NULL)
+ if (error.AsCString() == nullptr)
error.SetErrorStringWithFormat("invalid value path '%s'", name);
}
return error;
@@ -361,7 +361,7 @@ OptionValueDictionary::GetStringValueForKey (const ConstString &key)
if (string_value)
return string_value->GetCurrentValue();
}
- return NULL;
+ return nullptr;
}
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/OptionValueEnumeration.cpp b/contrib/llvm/tools/lldb/source/Interpreter/OptionValueEnumeration.cpp
index f282235..7aceac9 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/OptionValueEnumeration.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/OptionValueEnumeration.cpp
@@ -113,7 +113,7 @@ OptionValueEnumeration::SetEnumerations (const OptionEnumValueElement *enumerato
m_enumerations.Clear();
if (enumerators)
{
- for (size_t i=0; enumerators[i].string_value != NULL; ++i)
+ for (size_t i=0; enumerators[i].string_value != nullptr; ++i)
{
ConstString const_enumerator_name(enumerators[i].string_value);
EnumeratorInfo enumerator_info = { enumerators[i].value, enumerators[i].usage };
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/OptionValueFileSpec.cpp b/contrib/llvm/tools/lldb/source/Interpreter/OptionValueFileSpec.cpp
index 3d2a7ff..c8aaade 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/OptionValueFileSpec.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/OptionValueFileSpec.cpp
@@ -99,6 +99,7 @@ OptionValueFileSpec::SetValueFromCString (const char *value_cstr,
m_value_was_set = true;
m_current_value.SetFile(filepath.c_str(), true);
+ m_data_sp.reset();
}
else
{
@@ -139,7 +140,7 @@ OptionValueFileSpec::AutoComplete (CommandInterpreter &interpreter,
s,
match_start_point,
max_return_elements,
- NULL,
+ nullptr,
word_complete,
matches);
return matches.GetSize();
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/OptionValueFormat.cpp b/contrib/llvm/tools/lldb/source/Interpreter/OptionValueFormat.cpp
index 34d3672..296dd98 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/OptionValueFormat.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/OptionValueFormat.cpp
@@ -49,7 +49,7 @@ OptionValueFormat::SetValueFromCString (const char *value_cstr, VarSetOperationT
case eVarSetOperationAssign:
{
Format new_format;
- error = Args::StringToFormat (value_cstr, new_format, NULL);
+ error = Args::StringToFormat (value_cstr, new_format, nullptr);
if (error.Success())
{
m_value_was_set = true;
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/OptionValueProperties.cpp b/contrib/llvm/tools/lldb/source/Interpreter/OptionValueProperties.cpp
index abee55d..0497ee1 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/OptionValueProperties.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/OptionValueProperties.cpp
@@ -35,6 +35,7 @@ OptionValueProperties::OptionValueProperties (const ConstString &name) :
OptionValueProperties::OptionValueProperties (const OptionValueProperties &global_properties) :
OptionValue (global_properties),
+ std::enable_shared_from_this<OptionValueProperties> (),
m_name (global_properties.m_name),
m_properties (global_properties.m_properties),
m_name_to_index (global_properties.m_name_to_index)
@@ -46,7 +47,7 @@ OptionValueProperties::OptionValueProperties (const OptionValueProperties &globa
const size_t num_properties = m_properties.size();
for (size_t i=0; i<num_properties; ++i)
{
- // Duplicate any values that are not global when contructing properties from
+ // Duplicate any values that are not global when constructing properties from
// a global copy
if (m_properties[i].IsGlobal() == false)
{
@@ -135,7 +136,7 @@ OptionValueProperties::GetSubValue (const ExecutionContext *exe_ctx,
if (name && name[0])
{
- const char *sub_name = NULL;
+ const char *sub_name = nullptr;
ConstString key;
size_t key_len = ::strcspn (name, ".[{");
@@ -163,7 +164,7 @@ OptionValueProperties::GetSubValue (const ExecutionContext *exe_ctx,
// OptionValueProperties for a lldb_private::Target might implement:
// "target.run-args{arch==i386}" -- only set run args if the arch is i386
// "target.run-args{path=/tmp/a/b/c/a.out}" -- only set run args if the path matches
- // "target.run-args{basename==test&&arch==x86_64}" -- only set run args if exectable basename is "test" and arch is "x86_64"
+ // "target.run-args{basename==test&&arch==x86_64}" -- only set run args if executable basename is "test" and arch is "x86_64"
if (sub_name[1])
{
const char *predicate_start = sub_name + 1;
@@ -218,7 +219,7 @@ OptionValueProperties::SetSubValue (const ExecutionContext *exe_ctx,
error = value_sp->SetValueFromCString(value, op);
else
{
- if (error.AsCString() == NULL)
+ if (error.AsCString() == nullptr)
error.SetErrorStringWithFormat("invalid value path '%s'", name);
}
return error;
@@ -228,7 +229,7 @@ OptionValueProperties::SetSubValue (const ExecutionContext *exe_ctx,
ConstString
OptionValueProperties::GetPropertyNameAtIndex (uint32_t idx) const
{
- const Property *property = GetPropertyAtIndex(NULL, false, idx);
+ const Property *property = GetPropertyAtIndex(nullptr, false, idx);
if (property)
return property->GetName();
return ConstString();
@@ -238,10 +239,10 @@ OptionValueProperties::GetPropertyNameAtIndex (uint32_t idx) const
const char *
OptionValueProperties::GetPropertyDescriptionAtIndex (uint32_t idx) const
{
- const Property *property = GetPropertyAtIndex(NULL, false, idx);
+ const Property *property = GetPropertyAtIndex(nullptr, false, idx);
if (property)
return property->GetDescription();
- return NULL;
+ return nullptr;
}
uint32_t
@@ -279,7 +280,7 @@ OptionValueProperties::GetPropertyAtIndexAsOptionValuePathMappings (const Execut
OptionValueSP value_sp(GetPropertyValueAtIndex (exe_ctx, will_modify, idx));
if (value_sp)
return value_sp->GetAsPathMappings();
- return NULL;
+ return nullptr;
}
OptionValueFileSpecList *
@@ -288,7 +289,7 @@ OptionValueProperties::GetPropertyAtIndexAsOptionValueFileSpecList (const Execut
OptionValueSP value_sp(GetPropertyValueAtIndex (exe_ctx, will_modify, idx));
if (value_sp)
return value_sp->GetAsFileSpecList();
- return NULL;
+ return nullptr;
}
OptionValueArch *
@@ -297,7 +298,7 @@ OptionValueProperties::GetPropertyAtIndexAsOptionValueArch (const ExecutionConte
const Property *property = GetPropertyAtIndex (exe_ctx, false, idx);
if (property)
return property->GetValue()->GetAsArch();
- return NULL;
+ return nullptr;
}
bool
@@ -381,7 +382,7 @@ OptionValueProperties::GetPropertyAtIndexAsOptionValueDictionary (const Executio
const Property *property = GetPropertyAtIndex (exe_ctx, false, idx);
if (property)
return property->GetValue()->GetAsDictionary();
- return NULL;
+ return nullptr;
}
int64_t
@@ -421,7 +422,7 @@ OptionValueProperties::GetPropertyAtIndexAsOptionValueFileSpec (const ExecutionC
if (value)
return value->GetAsFileSpec();
}
- return NULL;
+ return nullptr;
}
@@ -462,7 +463,7 @@ OptionValueProperties::GetPropertyAtIndexAsOptionValueRegex (const ExecutionCont
if (value)
return value->GetRegexValue();
}
- return NULL;
+ return nullptr;
}
OptionValueSInt64 *
@@ -475,7 +476,7 @@ OptionValueProperties::GetPropertyAtIndexAsOptionValueSInt64 (const ExecutionCon
if (value)
return value->GetAsSInt64();
}
- return NULL;
+ return nullptr;
}
int64_t
@@ -536,7 +537,7 @@ OptionValueProperties::GetPropertyAtIndexAsOptionValueString (const ExecutionCon
OptionValueSP value_sp(GetPropertyValueAtIndex (exe_ctx, will_modify, idx));
if (value_sp)
return value_sp->GetAsString();
- return NULL;
+ return nullptr;
}
@@ -659,10 +660,10 @@ OptionValueProperties::GetPropertyAtPath (const ExecutionContext *exe_ctx,
bool will_modify,
const char *name) const
{
- const Property *property = NULL;
+ const Property *property = nullptr;
if (name && name[0])
{
- const char *sub_name = NULL;
+ const char *sub_name = nullptr;
ConstString key;
size_t key_len = ::strcspn (name, ".[{");
@@ -683,7 +684,7 @@ OptionValueProperties::GetPropertyAtPath (const ExecutionContext *exe_ctx,
if (sub_properties)
return sub_properties->GetPropertyAtPath(exe_ctx, will_modify, sub_name + 1);
}
- property = NULL;
+ property = nullptr;
}
}
return property;
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/OptionValueUUID.cpp b/contrib/llvm/tools/lldb/source/Interpreter/OptionValueUUID.cpp
index 340f1e5..0141911 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/OptionValueUUID.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/OptionValueUUID.cpp
@@ -92,7 +92,7 @@ OptionValueUUID::AutoComplete (CommandInterpreter &interpreter,
if (num_modules > 0)
{
UUID::ValueType uuid_bytes;
- const size_t num_bytes_decoded = UUID::DecodeUUIDBytesFromCString(s, uuid_bytes, NULL);
+ const size_t num_bytes_decoded = UUID::DecodeUUIDBytesFromCString(s, uuid_bytes, nullptr);
for (size_t i=0; i<num_modules; ++i)
{
ModuleSP module_sp (target->GetImages().GetModuleAtIndex(i));
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/Options.cpp b/contrib/llvm/tools/lldb/source/Interpreter/Options.cpp
index c6c66d8..a8766f5 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/Options.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/Options.cpp
@@ -242,14 +242,14 @@ uint32_t
Options::NumCommandOptions ()
{
const OptionDefinition *opt_defs = GetDefinitions ();
- if (opt_defs == NULL)
+ if (opt_defs == nullptr)
return 0;
int i = 0;
- if (opt_defs != NULL)
+ if (opt_defs != nullptr)
{
- while (opt_defs[i].long_option != NULL)
+ while (opt_defs[i].long_option != nullptr)
++i;
}
@@ -265,7 +265,7 @@ Options::GetLongOptions ()
// Check to see if there are any options.
const uint32_t num_options = NumCommandOptions();
if (num_options == 0)
- return NULL;
+ return nullptr;
uint32_t i;
const OptionDefinition *opt_defs = GetDefinitions();
@@ -277,9 +277,8 @@ Options::GetLongOptions ()
{
const int short_opt = opt_defs[i].short_option;
- m_getopt_table[i].name = opt_defs[i].long_option;
- m_getopt_table[i].has_arg = opt_defs[i].option_has_arg;
- m_getopt_table[i].flag = NULL;
+ m_getopt_table[i].definition = &opt_defs[i];
+ m_getopt_table[i].flag = nullptr;
m_getopt_table[i].val = short_opt;
if (option_seen.find(short_opt) == option_seen.end())
@@ -297,7 +296,7 @@ Options::GetLongOptions ()
opt_defs[i].long_option,
short_opt,
pos->second,
- m_getopt_table[pos->second].name,
+ m_getopt_table[pos->second].definition->long_option,
opt_defs[i].long_option);
else
Host::SystemLog (Host::eSystemLogError, "option[%u] --%s has a short option 0x%x that conflicts with option[%u] --%s, short option won't be used for --%s\n",
@@ -305,21 +304,20 @@ Options::GetLongOptions ()
opt_defs[i].long_option,
short_opt,
pos->second,
- m_getopt_table[pos->second].name,
+ m_getopt_table[pos->second].definition->long_option,
opt_defs[i].long_option);
}
}
//getopt_long_only requires a NULL final entry in the table:
- m_getopt_table[i].name = NULL;
- m_getopt_table[i].has_arg = 0;
- m_getopt_table[i].flag = NULL;
- m_getopt_table[i].val = 0;
+ m_getopt_table[i].definition = nullptr;
+ m_getopt_table[i].flag = nullptr;
+ m_getopt_table[i].val = 0;
}
if (m_getopt_table.empty())
- return NULL;
+ return nullptr;
return &m_getopt_table.front();
}
@@ -336,18 +334,29 @@ void
Options::OutputFormattedUsageText
(
Stream &strm,
- const char *text,
+ const OptionDefinition &option_def,
uint32_t output_max_columns
)
{
- int len = strlen (text);
+ std::string actual_text;
+ if (option_def.validator)
+ {
+ const char *condition = option_def.validator->ShortConditionString();
+ if (condition)
+ {
+ actual_text = "[";
+ actual_text.append(condition);
+ actual_text.append("] ");
+ }
+ }
+ actual_text.append(option_def.usage_text);
// Will it all fit on one line?
- if ((len + strm.GetIndentLevel()) < output_max_columns)
+ if (static_cast<uint32_t>(actual_text.length() + strm.GetIndentLevel()) < output_max_columns)
{
// Output it as a single line.
- strm.Indent (text);
+ strm.Indent (actual_text.c_str());
strm.EOL();
}
else
@@ -357,13 +366,13 @@ Options::OutputFormattedUsageText
int text_width = output_max_columns - strm.GetIndentLevel() - 1;
int start = 0;
int end = start;
- int final_end = strlen (text);
+ int final_end = actual_text.length();
int sub_len;
while (end < final_end)
{
// Don't start the 'text' on a space, since we're already outputting the indentation.
- while ((start < final_end) && (text[start] == ' '))
+ while ((start < final_end) && (actual_text[start] == ' '))
start++;
end = start + text_width;
@@ -373,7 +382,7 @@ Options::OutputFormattedUsageText
{
// If we're not at the end of the text, make sure we break the line on white space.
while (end > start
- && text[end] != ' ' && text[end] != '\t' && text[end] != '\n')
+ && actual_text[end] != ' ' && actual_text[end] != '\t' && actual_text[end] != '\n')
end--;
}
@@ -383,7 +392,7 @@ Options::OutputFormattedUsageText
strm.Indent();
assert (start < final_end);
assert (start + sub_len <= final_end);
- strm.Write(text + start, sub_len);
+ strm.Write(actual_text.c_str() + start, sub_len);
start = end + 1;
}
strm.EOL();
@@ -592,7 +601,7 @@ Options::GenerateOptionUsage
if (opt_defs[i].usage_mask & opt_set_mask && isprint8(opt_defs[i].short_option))
{
if (opt_defs[i].required && opt_defs[i].option_has_arg != OptionParser::eNoArgument)
- PrintOption (opt_defs[i], eDisplayBestOption, " ", NULL, true, strm);
+ PrintOption (opt_defs[i], eDisplayBestOption, " ", nullptr, true, strm);
}
}
@@ -605,7 +614,7 @@ Options::GenerateOptionUsage
// Add current option to the end of out_stream.
if (!opt_defs[i].required && opt_defs[i].option_has_arg != OptionParser::eNoArgument)
- PrintOption (opt_defs[i], eDisplayBestOption, " ", NULL, true, strm);
+ PrintOption (opt_defs[i], eDisplayBestOption, " ", nullptr, true, strm);
}
}
@@ -630,7 +639,7 @@ Options::GenerateOptionUsage
strm.Printf ("\n\n");
// Now print out all the detailed information about the various options: long form, short form and help text:
- // --long_name <argument> ( -short <argument> )
+ // -short <argument> ( --long_name <argument> )
// help text
// This variable is used to keep track of which options' info we've printed out, because some options can be in
@@ -669,13 +678,13 @@ Options::GenerateOptionUsage
strm.Indent ();
if (opt_defs[i].short_option && isprint8(opt_defs[i].short_option))
{
- PrintOption (opt_defs[i], eDisplayShortOption, NULL, NULL, false, strm);
+ PrintOption (opt_defs[i], eDisplayShortOption, nullptr, nullptr, false, strm);
PrintOption (opt_defs[i], eDisplayLongOption, " ( ", " )", false, strm);
}
else
{
// Short option is not printable, just print long option
- PrintOption (opt_defs[i], eDisplayLongOption, NULL, NULL, false, strm);
+ PrintOption (opt_defs[i], eDisplayLongOption, nullptr, nullptr, false, strm);
}
strm.EOL();
@@ -683,13 +692,13 @@ Options::GenerateOptionUsage
if (opt_defs[i].usage_text)
OutputFormattedUsageText (strm,
- opt_defs[i].usage_text,
+ opt_defs[i],
screen_width);
- if (opt_defs[i].enum_values != NULL)
+ if (opt_defs[i].enum_values != nullptr)
{
strm.Indent ();
strm.Printf("Values: ");
- for (int k = 0; opt_defs[i].enum_values[k].string_value != NULL; k++)
+ for (int k = 0; opt_defs[i].enum_values[k].string_value != nullptr; k++)
{
if (k == 0)
strm.Printf("%s", opt_defs[i].enum_values[k].string_value);
@@ -908,11 +917,11 @@ Options::HandleOptionArgumentCompletion
// See if this is an enumeration type option, and if so complete it here:
OptionEnumValueElement *enum_values = opt_defs[opt_defs_index].enum_values;
- if (enum_values != NULL)
+ if (enum_values != nullptr)
{
bool return_value = false;
std::string match_string(input.GetArgumentAtIndex (opt_arg_pos), input.GetArgumentAtIndex (opt_arg_pos) + char_pos);
- for (int i = 0; enum_values[i].string_value != NULL; i++)
+ for (int i = 0; enum_values[i].string_value != nullptr; i++)
{
if (strstr(enum_values[i].string_value, match_string.c_str()) == enum_values[i].string_value)
{
@@ -1001,7 +1010,7 @@ OptionGroupOptions::GetGroupWithOption (char short_opt)
if (opt_def.short_option == short_opt)
return m_option_infos[i].option_group;
}
- return NULL;
+ return nullptr;
}
void
@@ -1026,7 +1035,7 @@ void
OptionGroupOptions::Finalize ()
{
m_did_finalize = true;
- OptionDefinition empty_option_def = { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL };
+ OptionDefinition empty_option_def = { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr };
m_option_defs.push_back (empty_option_def);
}
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/Property.cpp b/contrib/llvm/tools/lldb/source/Interpreter/Property.cpp
index e5cf63a..4937626 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/Property.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/Property.cpp
@@ -56,7 +56,7 @@ Property::Property (const PropertyDefinition &definition) :
// "definition.default_cstr_value" as a string value that represents the default
// value.
if (definition.default_cstr_value)
- m_value_sp.reset (new OptionValueBoolean(Args::StringToBoolean (definition.default_cstr_value, false, NULL)));
+ m_value_sp.reset (new OptionValueBoolean(Args::StringToBoolean (definition.default_cstr_value, false, nullptr)));
else
m_value_sp.reset (new OptionValueBoolean(definition.default_uint_value != 0));
break;
@@ -108,7 +108,7 @@ Property::Property (const PropertyDefinition &definition) :
{
Format new_format = eFormatInvalid;
if (definition.default_cstr_value)
- Args::StringToFormat (definition.default_cstr_value, new_format, NULL);
+ Args::StringToFormat (definition.default_cstr_value, new_format, nullptr);
else
new_format = (Format)definition.default_uint_value;
m_value_sp.reset (new OptionValueFormat(new_format));
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/PythonDataObjects.cpp b/contrib/llvm/tools/lldb/source/Interpreter/PythonDataObjects.cpp
index 053ff34..3ea6c0d 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/PythonDataObjects.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/PythonDataObjects.cpp
@@ -31,7 +31,7 @@ using namespace lldb;
// PythonObject
//----------------------------------------------------------------------
PythonObject::PythonObject (const lldb::ScriptInterpreterObjectSP &script_object_sp) :
- m_py_obj (NULL)
+ m_py_obj (nullptr)
{
if (script_object_sp)
Reset ((PyObject *)script_object_sp->GetObject());
@@ -133,8 +133,8 @@ PythonString::Reset (PyObject *py_obj)
if (py_obj && PyString_Check(py_obj))
return PythonObject::Reset(py_obj);
- PythonObject::Reset(NULL);
- return py_obj == NULL;
+ PythonObject::Reset(nullptr);
+ return py_obj == nullptr;
}
const char*
@@ -142,7 +142,7 @@ PythonString::GetString() const
{
if (m_py_obj)
return PyString_AsString(m_py_obj);
- return NULL;
+ return nullptr;
}
size_t
@@ -202,8 +202,8 @@ PythonInteger::Reset (PyObject *py_obj)
return PythonObject::Reset(py_obj);
}
- PythonObject::Reset(NULL);
- return py_obj == NULL;
+ PythonObject::Reset(nullptr);
+ return py_obj == nullptr;
}
int64_t
@@ -230,7 +230,7 @@ PythonInteger::SetInteger (int64_t value)
//----------------------------------------------------------------------
PythonList::PythonList (bool create_empty) :
- PythonObject(create_empty ? PyList_New(0) : NULL)
+ PythonObject(create_empty ? PyList_New(0) : nullptr)
{
}
@@ -269,8 +269,8 @@ PythonList::Reset (PyObject *py_obj)
if (py_obj && PyList_Check(py_obj))
return PythonObject::Reset(py_obj);
- PythonObject::Reset(NULL);
- return py_obj == NULL;
+ PythonObject::Reset(nullptr);
+ return py_obj == nullptr;
}
uint32_t
@@ -308,7 +308,7 @@ PythonList::AppendItem (const PythonObject &object)
//----------------------------------------------------------------------
PythonDictionary::PythonDictionary (bool create_empty) :
-PythonObject(create_empty ? PyDict_New() : NULL)
+PythonObject(create_empty ? PyDict_New() : nullptr)
{
}
@@ -342,8 +342,8 @@ PythonDictionary::Reset (PyObject *py_obj)
if (py_obj && PyDict_Check(py_obj))
return PythonObject::Reset(py_obj);
- PythonObject::Reset(NULL);
- return py_obj == NULL;
+ PythonObject::Reset(nullptr);
+ return py_obj == nullptr;
}
uint32_t
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/ScriptInterpreter.cpp b/contrib/llvm/tools/lldb/source/Interpreter/ScriptInterpreter.cpp
index 1b751af..b6c46f8 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/ScriptInterpreter.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/ScriptInterpreter.cpp
@@ -44,7 +44,7 @@ ScriptInterpreter::GetCommandInterpreter ()
void
ScriptInterpreter::CollectDataForBreakpointCommandCallback
(
- BreakpointOptions *bp_options,
+ std::vector<BreakpointOptions *> &bp_options_vec,
CommandReturnObject &result
)
{
@@ -81,6 +81,30 @@ ScriptInterpreter::LanguageToString (lldb::ScriptLanguage language)
return return_value;
}
+Error
+ScriptInterpreter::SetBreakpointCommandCallback (std::vector<BreakpointOptions *> &bp_options_vec,
+ const char *callback_text)
+{
+ Error return_error;
+ for (BreakpointOptions *bp_options : bp_options_vec)
+ {
+ return_error = SetBreakpointCommandCallback(bp_options, callback_text);
+ if (return_error.Success())
+ break;
+ }
+ return return_error;
+}
+
+void
+ScriptInterpreter::SetBreakpointCommandCallbackFunction (std::vector<BreakpointOptions *> &bp_options_vec,
+ const char *function_name)
+{
+ for (BreakpointOptions *bp_options : bp_options_vec)
+ {
+ SetBreakpointCommandCallbackFunction(bp_options, function_name);
+ }
+}
+
std::unique_ptr<ScriptInterpreterLocker>
ScriptInterpreter::AcquireInterpreterLock ()
{
@@ -132,12 +156,3 @@ ScriptInterpreter::InitializeInterpreter (SWIGInitCallback python_swig_init_call
swig_plugin_get);
#endif // #ifndef LLDB_DISABLE_PYTHON
}
-
-void
-ScriptInterpreter::TerminateInterpreter ()
-{
-#ifndef LLDB_DISABLE_PYTHON
- ScriptInterpreterPython::TerminateInterpreter ();
-#endif // #ifndef LLDB_DISABLE_PYTHON
-}
-
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/contrib/llvm/tools/lldb/source/Interpreter/ScriptInterpreterPython.cpp
index c1d28e8..1b24fea 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/ScriptInterpreterPython.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/ScriptInterpreterPython.cpp
@@ -31,7 +31,8 @@
#include "lldb/Core/ConnectionFileDescriptor.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Timer.h"
-#include "lldb/Host/Host.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Host/Pipe.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/PythonDataObjects.h"
@@ -41,33 +42,26 @@ using namespace lldb;
using namespace lldb_private;
-static ScriptInterpreter::SWIGInitCallback g_swig_init_callback = NULL;
-static ScriptInterpreter::SWIGBreakpointCallbackFunction g_swig_breakpoint_callback = NULL;
-static ScriptInterpreter::SWIGWatchpointCallbackFunction g_swig_watchpoint_callback = NULL;
-static ScriptInterpreter::SWIGPythonTypeScriptCallbackFunction g_swig_typescript_callback = NULL;
-static ScriptInterpreter::SWIGPythonCreateSyntheticProvider g_swig_synthetic_script = NULL;
-static ScriptInterpreter::SWIGPythonCalculateNumChildren g_swig_calc_children = NULL;
-static ScriptInterpreter::SWIGPythonGetChildAtIndex g_swig_get_child_index = NULL;
-static ScriptInterpreter::SWIGPythonGetIndexOfChildWithName g_swig_get_index_child = NULL;
-static ScriptInterpreter::SWIGPythonCastPyObjectToSBValue g_swig_cast_to_sbvalue = NULL;
-static ScriptInterpreter::SWIGPythonGetValueObjectSPFromSBValue g_swig_get_valobj_sp_from_sbvalue = NULL;
-static ScriptInterpreter::SWIGPythonUpdateSynthProviderInstance g_swig_update_provider = NULL;
-static ScriptInterpreter::SWIGPythonMightHaveChildrenSynthProviderInstance g_swig_mighthavechildren_provider = NULL;
-static ScriptInterpreter::SWIGPythonCallCommand g_swig_call_command = NULL;
-static ScriptInterpreter::SWIGPythonCallModuleInit g_swig_call_module_init = NULL;
-static ScriptInterpreter::SWIGPythonCreateOSPlugin g_swig_create_os_plugin = NULL;
-static ScriptInterpreter::SWIGPythonScriptKeyword_Process g_swig_run_script_keyword_process = NULL;
-static ScriptInterpreter::SWIGPythonScriptKeyword_Thread g_swig_run_script_keyword_thread = NULL;
-static ScriptInterpreter::SWIGPythonScriptKeyword_Target g_swig_run_script_keyword_target = NULL;
-static ScriptInterpreter::SWIGPythonScriptKeyword_Frame g_swig_run_script_keyword_frame = NULL;
-static ScriptInterpreter::SWIGPython_GetDynamicSetting g_swig_plugin_get = NULL;
-
-static int
-_check_and_flush (FILE *stream)
-{
- int prev_fail = ferror (stream);
- return fflush (stream) || prev_fail ? EOF : 0;
-}
+static ScriptInterpreter::SWIGInitCallback g_swig_init_callback = nullptr;
+static ScriptInterpreter::SWIGBreakpointCallbackFunction g_swig_breakpoint_callback = nullptr;
+static ScriptInterpreter::SWIGWatchpointCallbackFunction g_swig_watchpoint_callback = nullptr;
+static ScriptInterpreter::SWIGPythonTypeScriptCallbackFunction g_swig_typescript_callback = nullptr;
+static ScriptInterpreter::SWIGPythonCreateSyntheticProvider g_swig_synthetic_script = nullptr;
+static ScriptInterpreter::SWIGPythonCalculateNumChildren g_swig_calc_children = nullptr;
+static ScriptInterpreter::SWIGPythonGetChildAtIndex g_swig_get_child_index = nullptr;
+static ScriptInterpreter::SWIGPythonGetIndexOfChildWithName g_swig_get_index_child = nullptr;
+static ScriptInterpreter::SWIGPythonCastPyObjectToSBValue g_swig_cast_to_sbvalue = nullptr;
+static ScriptInterpreter::SWIGPythonGetValueObjectSPFromSBValue g_swig_get_valobj_sp_from_sbvalue = nullptr;
+static ScriptInterpreter::SWIGPythonUpdateSynthProviderInstance g_swig_update_provider = nullptr;
+static ScriptInterpreter::SWIGPythonMightHaveChildrenSynthProviderInstance g_swig_mighthavechildren_provider = nullptr;
+static ScriptInterpreter::SWIGPythonCallCommand g_swig_call_command = nullptr;
+static ScriptInterpreter::SWIGPythonCallModuleInit g_swig_call_module_init = nullptr;
+static ScriptInterpreter::SWIGPythonCreateOSPlugin g_swig_create_os_plugin = nullptr;
+static ScriptInterpreter::SWIGPythonScriptKeyword_Process g_swig_run_script_keyword_process = nullptr;
+static ScriptInterpreter::SWIGPythonScriptKeyword_Thread g_swig_run_script_keyword_thread = nullptr;
+static ScriptInterpreter::SWIGPythonScriptKeyword_Target g_swig_run_script_keyword_target = nullptr;
+static ScriptInterpreter::SWIGPythonScriptKeyword_Frame g_swig_run_script_keyword_frame = nullptr;
+static ScriptInterpreter::SWIGPython_GetDynamicSetting g_swig_plugin_get = nullptr;
static std::string
ReadPythonBacktrace (PyObject* py_backtrace);
@@ -100,6 +94,13 @@ ScriptInterpreterPython::Locker::DoAcquireLock()
m_GILState = PyGILState_Ensure();
if (log)
log->Printf("Ensured PyGILState. Previous state = %slocked\n", m_GILState == PyGILState_UNLOCKED ? "un" : "");
+
+ // we need to save the thread state when we first start the command
+ // because we might decide to interrupt it while some action is taking
+ // place outside of Python (e.g. printing to screen, waiting for the network, ...)
+ // in that case, _PyThreadState_Current will be NULL - and we would be unable
+ // to set the asynchronous exception - not a desirable situation
+ m_python_interpreter->SetThreadState (_PyThreadState_Current);
return true;
}
@@ -156,7 +157,7 @@ ScriptInterpreterPython::ScriptInterpreterPython (CommandInterpreter &interprete
m_session_is_active (false),
m_pty_slave_is_open (false),
m_valid_session (true),
- m_command_thread_state (NULL)
+ m_command_thread_state (nullptr)
{
ScriptInterpreterPython::InitializePrivate ();
@@ -213,7 +214,7 @@ ScriptInterpreterPython::~ScriptInterpreterPython ()
void
ScriptInterpreterPython::IOHandlerActivated (IOHandler &io_handler)
{
- const char *instructions = NULL;
+ const char *instructions = nullptr;
switch (m_active_io_handler)
{
@@ -255,24 +256,30 @@ ScriptInterpreterPython::IOHandlerInputComplete (IOHandler &io_handler, std::str
break;
case eIOHandlerBreakpoint:
{
- BreakpointOptions *bp_options = (BreakpointOptions *)io_handler.GetUserData();
- std::unique_ptr<BreakpointOptions::CommandData> data_ap(new BreakpointOptions::CommandData());
- if (data_ap.get())
+ std::vector<BreakpointOptions *> *bp_options_vec = (std::vector<BreakpointOptions *> *)io_handler.GetUserData();
+ for (auto bp_options : *bp_options_vec)
{
- data_ap->user_source.SplitIntoLines(data);
-
- if (GenerateBreakpointCommandCallbackData (data_ap->user_source, data_ap->script_source))
+ if (!bp_options)
+ continue;
+
+ std::unique_ptr<BreakpointOptions::CommandData> data_ap(new BreakpointOptions::CommandData());
+ if (data_ap.get())
{
- BatonSP baton_sp (new BreakpointOptions::CommandBaton (data_ap.release()));
- bp_options->SetCallback (ScriptInterpreterPython::BreakpointCallbackFunction, baton_sp);
- }
- else if (!batch_mode)
- {
- StreamFileSP error_sp = io_handler.GetErrorStreamFile();
- if (error_sp)
+ data_ap->user_source.SplitIntoLines(data);
+
+ if (GenerateBreakpointCommandCallbackData (data_ap->user_source, data_ap->script_source).Success())
{
- error_sp->Printf ("Warning: No command attached to breakpoint.\n");
- error_sp->Flush();
+ BatonSP baton_sp (new BreakpointOptions::CommandBaton (data_ap.release()));
+ bp_options->SetCallback (ScriptInterpreterPython::BreakpointCallbackFunction, baton_sp);
+ }
+ else if (!batch_mode)
+ {
+ StreamFileSP error_sp = io_handler.GetErrorStreamFile();
+ if (error_sp)
+ {
+ error_sp->Printf ("Warning: No command attached to breakpoint.\n");
+ error_sp->Flush();
+ }
}
}
}
@@ -306,8 +313,6 @@ ScriptInterpreterPython::IOHandlerInputComplete (IOHandler &io_handler, std::str
}
break;
}
-
-
}
@@ -427,42 +432,42 @@ ScriptInterpreterPython::EnterSession (uint16_t on_entry_flags,
lldb::StreamFileSP in_sp;
lldb::StreamFileSP out_sp;
lldb::StreamFileSP err_sp;
- if (in == NULL || out == NULL || err == NULL)
+ if (in == nullptr || out == nullptr || err == nullptr)
m_interpreter.GetDebugger().AdoptTopIOHandlerFilesIfInvalid (in_sp, out_sp, err_sp);
- if (in == NULL && in_sp && (on_entry_flags & Locker::NoSTDIN) == 0)
+ if (in == nullptr && in_sp && (on_entry_flags & Locker::NoSTDIN) == 0)
in = in_sp->GetFile().GetStream();
if (in)
{
m_saved_stdin.Reset(sys_module_dict.GetItemForKey("stdin"));
- PyObject *new_file = PyFile_FromFile (in, (char *) "", (char *) "r", 0);
+ PyObject *new_file = PyFile_FromFile (in, (char *) "", (char *) "r", nullptr);
sys_module_dict.SetItemForKey ("stdin", new_file);
Py_DECREF (new_file);
}
else
m_saved_stdin.Reset();
- if (out == NULL && out_sp)
+ if (out == nullptr && out_sp)
out = out_sp->GetFile().GetStream();
if (out)
{
m_saved_stdout.Reset(sys_module_dict.GetItemForKey("stdout"));
- PyObject *new_file = PyFile_FromFile (out, (char *) "", (char *) "w", 0);
+ PyObject *new_file = PyFile_FromFile (out, (char *) "", (char *) "w", nullptr);
sys_module_dict.SetItemForKey ("stdout", new_file);
Py_DECREF (new_file);
}
else
m_saved_stdout.Reset();
- if (err == NULL && err_sp)
+ if (err == nullptr && err_sp)
err = err_sp->GetFile().GetStream();
if (err)
{
m_saved_stderr.Reset(sys_module_dict.GetItemForKey("stderr"));
- PyObject *new_file = PyFile_FromFile (err, (char *) "", (char *) "w", 0);
+ PyObject *new_file = PyFile_FromFile (err, (char *) "", (char *) "w", nullptr);
sys_module_dict.SetItemForKey ("stderr", new_file);
Py_DECREF (new_file);
}
@@ -517,7 +522,7 @@ ScriptInterpreterPython::GetSysModuleDictionary ()
static std::string
GenerateUniqueName (const char* base_name_wanted,
uint32_t& functions_counter,
- void* name_token = NULL)
+ void* name_token = nullptr)
{
StreamString sstr;
@@ -538,7 +543,7 @@ ScriptInterpreterPython::GetEmbeddedInterpreterModuleObjects ()
if (!m_run_one_line_function)
{
PyObject *module = PyImport_AddModule ("lldb.embedded_interpreter");
- if (module != NULL)
+ if (module != nullptr)
{
PythonDictionary module_dict (PyModule_GetDict (module));
if (module_dict)
@@ -580,8 +585,7 @@ ScriptInterpreterPython::ExecuteOneLine (const char *command, CommandReturnObjec
StreamFileSP output_file_sp;
StreamFileSP error_file_sp;
Communication output_comm ("lldb.ScriptInterpreterPython.ExecuteOneLine.comm");
- int pipe_fds[2] = { -1, -1 };
-
+ bool join_read_thread = false;
if (options.GetEnableIO())
{
if (result)
@@ -589,20 +593,21 @@ ScriptInterpreterPython::ExecuteOneLine (const char *command, CommandReturnObjec
input_file_sp = debugger.GetInputFile();
// Set output to a temporary file so we can forward the results on to the result object
- int err = pipe(pipe_fds);
- if (err == 0)
+ Pipe pipe;
+ if (pipe.Open())
{
- std::unique_ptr<ConnectionFileDescriptor> conn_ap(new ConnectionFileDescriptor(pipe_fds[0], true));
+ std::unique_ptr<ConnectionFileDescriptor> conn_ap(new ConnectionFileDescriptor(pipe.ReleaseReadFileDescriptor(), true));
if (conn_ap->IsConnected())
{
output_comm.SetConnection(conn_ap.release());
output_comm.SetReadThreadBytesReceivedCallback(ReadThreadBytesReceived, &result->GetOutputStream());
output_comm.StartReadThread();
- FILE *outfile_handle = fdopen (pipe_fds[1], "w");
+ join_read_thread = true;
+ FILE *outfile_handle = fdopen (pipe.ReleaseWriteFileDescriptor(), "w");
output_file_sp.reset(new StreamFile(outfile_handle, true));
error_file_sp = output_file_sp;
if (outfile_handle)
- ::setbuf (outfile_handle, NULL);
+ ::setbuf (outfile_handle, nullptr);
result->SetImmediateOutputFile(debugger.GetOutputFile()->GetFile().GetStream());
result->SetImmediateErrorFile(debugger.GetErrorFile()->GetFile().GetStream());
@@ -667,7 +672,7 @@ ScriptInterpreterPython::ExecuteOneLine (const char *command, CommandReturnObjec
if (out_file != err_file)
::fflush (err_file);
- if (pipe_fds[0] != -1)
+ if (join_read_thread)
{
// Close the write end of the pipe since we are done with our
// one line script. This should cause the read thread that
@@ -788,10 +793,27 @@ public:
}
- virtual void
+ virtual bool
Interrupt ()
{
-
+ Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_SCRIPT));
+
+ PyThreadState* state = _PyThreadState_Current;
+ if (!state)
+ state = m_python->GetThreadState();
+ if (state)
+ {
+ long tid = state->thread_id;
+ _PyThreadState_Current = state;
+ int num_threads = PyThreadState_SetAsyncExc(tid, PyExc_KeyboardInterrupt);
+ if (log)
+ log->Printf("ScriptInterpreterPython::NonInteractiveInputReaderCallback, eInputReaderInterrupt, tid = %ld, num_threads = %d, state = %p",
+ tid, num_threads, static_cast<void *>(state));
+ }
+ else if (log)
+ log->Printf("ScriptInterpreterPython::NonInteractiveInputReaderCallback, eInputReaderInterrupt, state = NULL");
+
+ return false;
}
virtual void
@@ -834,13 +856,13 @@ ScriptInterpreterPython::ExecuteOneLineWithReturn (const char *in_string,
{
Locker locker(this,
- ScriptInterpreterPython::Locker::AcquireLock | ScriptInterpreterPython::Locker::InitSession | (options.GetSetLLDBGlobals() ? ScriptInterpreterPython::Locker::InitGlobals : 0),
+ ScriptInterpreterPython::Locker::AcquireLock | ScriptInterpreterPython::Locker::InitSession | (options.GetSetLLDBGlobals() ? ScriptInterpreterPython::Locker::InitGlobals : 0) | Locker::NoSTDIN,
ScriptInterpreterPython::Locker::FreeAcquiredLock | ScriptInterpreterPython::Locker::TearDownSession);
- PyObject *py_return = NULL;
+ PyObject *py_return = nullptr;
PythonObject &main_module = GetMainModule ();
PythonDictionary globals (PyModule_GetDict(main_module.get()));
- PyObject *py_error = NULL;
+ PyObject *py_error = nullptr;
bool ret_success = false;
int success;
@@ -855,25 +877,25 @@ ScriptInterpreterPython::ExecuteOneLineWithReturn (const char *in_string,
locals = globals;
py_error = PyErr_Occurred();
- if (py_error != NULL)
+ if (py_error != nullptr)
PyErr_Clear();
- if (in_string != NULL)
+ if (in_string != nullptr)
{
{ // scope for PythonInputReaderManager
//PythonInputReaderManager py_input(options.GetEnableIO() ? this : NULL);
py_return = PyRun_String (in_string, Py_eval_input, globals.get(), locals.get());
- if (py_return == NULL)
+ if (py_return == nullptr)
{
py_error = PyErr_Occurred ();
- if (py_error != NULL)
+ if (py_error != nullptr)
PyErr_Clear ();
py_return = PyRun_String (in_string, Py_single_input, globals.get(), locals.get());
}
}
- if (py_return != NULL)
+ if (py_return != nullptr)
{
switch (return_type)
{
@@ -978,7 +1000,7 @@ ScriptInterpreterPython::ExecuteOneLineWithReturn (const char *in_string,
}
py_error = PyErr_Occurred();
- if (py_error != NULL)
+ if (py_error != nullptr)
{
ret_success = false;
if (options.GetMaskoutErrors())
@@ -998,14 +1020,13 @@ ScriptInterpreterPython::ExecuteMultipleLines (const char *in_string, const Exec
Error error;
Locker locker(this,
- ScriptInterpreterPython::Locker::AcquireLock | ScriptInterpreterPython::Locker::InitSession | (options.GetSetLLDBGlobals() ? ScriptInterpreterPython::Locker::InitGlobals : 0),
+ ScriptInterpreterPython::Locker::AcquireLock | ScriptInterpreterPython::Locker::InitSession | (options.GetSetLLDBGlobals() ? ScriptInterpreterPython::Locker::InitGlobals : 0) | Locker::NoSTDIN,
ScriptInterpreterPython::Locker::FreeAcquiredLock | ScriptInterpreterPython::Locker::TearDownSession);
- bool success = false;
PythonObject return_value;
PythonObject &main_module = GetMainModule ();
PythonDictionary globals (PyModule_GetDict(main_module.get()));
- PyObject *py_error = NULL;
+ PyObject *py_error = nullptr;
PythonDictionary locals = GetSessionDictionary ();
@@ -1020,10 +1041,10 @@ ScriptInterpreterPython::ExecuteMultipleLines (const char *in_string, const Exec
}
py_error = PyErr_Occurred();
- if (py_error != NULL)
+ if (py_error != nullptr)
PyErr_Clear();
- if (in_string != NULL)
+ if (in_string != nullptr)
{
struct _node *compiled_node = PyParser_SimpleParseString (in_string, Py_file_input);
if (compiled_node)
@@ -1031,27 +1052,22 @@ ScriptInterpreterPython::ExecuteMultipleLines (const char *in_string, const Exec
PyCodeObject *compiled_code = PyNode_Compile (compiled_node, "temp.py");
if (compiled_code)
{
- { // scope for PythonInputReaderManager
- //PythonInputReaderManager py_input(options.GetEnableIO() ? this : NULL);
- return_value.Reset(PyEval_EvalCode (compiled_code, globals.get(), locals.get()));
- }
- if (return_value)
- success = true;
+ return_value.Reset(PyEval_EvalCode (compiled_code, globals.get(), locals.get()));
}
}
}
py_error = PyErr_Occurred ();
- if (py_error != NULL)
+ if (py_error != nullptr)
{
// puts(in_string);
// _PyObject_Dump (py_error);
// PyErr_Print();
// success = false;
- PyObject *type = NULL;
- PyObject *value = NULL;
- PyObject *traceback = NULL;
+ PyObject *type = nullptr;
+ PyObject *value = nullptr;
+ PyObject *traceback = nullptr;
PyErr_Fetch (&type,&value,&traceback);
// get the backtrace
@@ -1075,11 +1091,11 @@ ScriptInterpreterPython::ExecuteMultipleLines (const char *in_string, const Exec
void
-ScriptInterpreterPython::CollectDataForBreakpointCommandCallback (BreakpointOptions *bp_options,
+ScriptInterpreterPython::CollectDataForBreakpointCommandCallback (std::vector<BreakpointOptions *> &bp_options_vec,
CommandReturnObject &result)
{
m_active_io_handler = eIOHandlerBreakpoint;
- m_interpreter.GetPythonCommandsFromIOHandler (" ", *this, true, bp_options);
+ m_interpreter.GetPythonCommandsFromIOHandler (" ", *this, true, &bp_options_vec);
}
void
@@ -1090,27 +1106,39 @@ ScriptInterpreterPython::CollectDataForWatchpointCommandCallback (WatchpointOpti
m_interpreter.GetPythonCommandsFromIOHandler (" ", *this, true, wp_options);
}
-// Set a Python one-liner as the callback for the breakpoint.
void
+ScriptInterpreterPython::SetBreakpointCommandCallbackFunction (BreakpointOptions *bp_options,
+ const char *function_name)
+{
+ // For now just cons up a oneliner that calls the provided function.
+ std::string oneliner("return ");
+ oneliner += function_name;
+ oneliner += "(frame, bp_loc, internal_dict)";
+ m_interpreter.GetScriptInterpreter()->SetBreakpointCommandCallback (bp_options,
+ oneliner.c_str());
+}
+
+// Set a Python one-liner as the callback for the breakpoint.
+Error
ScriptInterpreterPython::SetBreakpointCommandCallback (BreakpointOptions *bp_options,
- const char *oneliner)
+ const char *command_body_text)
{
std::unique_ptr<BreakpointOptions::CommandData> data_ap(new BreakpointOptions::CommandData());
- // It's necessary to set both user_source and script_source to the oneliner.
- // The former is used to generate callback description (as in breakpoint command list)
- // while the latter is used for Python to interpret during the actual callback.
-
- data_ap->user_source.AppendString (oneliner);
- data_ap->script_source.assign (oneliner);
-
- if (GenerateBreakpointCommandCallbackData (data_ap->user_source, data_ap->script_source))
+ // Split the command_body_text into lines, and pass that to GenerateBreakpointCommandCallbackData. That will
+ // wrap the body in an auto-generated function, and return the function name in script_source. That is what
+ // the callback will actually invoke.
+
+ data_ap->user_source.SplitIntoLines(command_body_text);
+ Error error = GenerateBreakpointCommandCallbackData (data_ap->user_source, data_ap->script_source);
+ if (error.Success())
{
BatonSP baton_sp (new BreakpointOptions::CommandBaton (data_ap.release()));
bp_options->SetCallback (ScriptInterpreterPython::BreakpointCallbackFunction, baton_sp);
+ return error;
}
-
- return;
+ else
+ return error;
}
// Set a Python one-liner as the callback for the watchpoint.
@@ -1136,24 +1164,32 @@ ScriptInterpreterPython::SetWatchpointCommandCallback (WatchpointOptions *wp_opt
return;
}
-bool
+Error
ScriptInterpreterPython::ExportFunctionDefinitionToInterpreter (StringList &function_def)
{
// Convert StringList to one long, newline delimited, const char *.
std::string function_def_string(function_def.CopyList());
- return ExecuteMultipleLines (function_def_string.c_str(), ScriptInterpreter::ExecuteScriptOptions().SetEnableIO(false)).Success();
+ Error error = ExecuteMultipleLines (function_def_string.c_str(), ScriptInterpreter::ExecuteScriptOptions().SetEnableIO(false));
+ return error;
}
-bool
+Error
ScriptInterpreterPython::GenerateFunction(const char *signature, const StringList &input)
{
+ Error error;
int num_lines = input.GetSize ();
if (num_lines == 0)
- return false;
+ {
+ error.SetErrorString ("No input data.");
+ return error;
+ }
if (!signature || *signature == 0)
- return false;
+ {
+ error.SetErrorString("No output function name.");
+ return error;
+ }
StreamString sstr;
StringList auto_generated_function;
@@ -1180,11 +1216,9 @@ ScriptInterpreterPython::GenerateFunction(const char *signature, const StringLis
// Verify that the results are valid Python.
- if (!ExportFunctionDefinitionToInterpreter (auto_generated_function))
- return false;
+ error = ExportFunctionDefinitionToInterpreter (auto_generated_function);
- return true;
-
+ return error;
}
bool
@@ -1204,7 +1238,7 @@ ScriptInterpreterPython::GenerateTypeScriptFunction (StringList &user_input, std
std::string auto_generated_function_name(GenerateUniqueName("lldb_autogen_python_type_print_func", num_created_functions, name_token));
sstr.Printf ("def %s (valobj, internal_dict):", auto_generated_function_name.c_str());
- if (!GenerateFunction(sstr.GetData(), user_input))
+ if (!GenerateFunction(sstr.GetData(), user_input).Success())
return false;
// Store the name of the auto-generated function to be called.
@@ -1227,7 +1261,7 @@ ScriptInterpreterPython::GenerateScriptAliasFunction (StringList &user_input, st
sstr.Printf ("def %s (debugger, args, result, internal_dict):", auto_generated_function_name.c_str());
- if (!GenerateFunction(sstr.GetData(),user_input))
+ if (!GenerateFunction(sstr.GetData(),user_input).Success())
return false;
// Store the name of the auto-generated function to be called.
@@ -1273,7 +1307,7 @@ ScriptInterpreterPython::GenerateTypeSynthClass (StringList &user_input, std::st
// Verify that the results are valid Python.
// (even though the method is ExportFunctionDefinitionToInterpreter, a class will actually be exported)
// (TODO: rename that method to ExportDefinitionToInterpreter)
- if (!ExportFunctionDefinitionToInterpreter (auto_generated_class))
+ if (!ExportFunctionDefinitionToInterpreter (auto_generated_class).Success())
return false;
// Store the name of the auto-generated class
@@ -1285,7 +1319,7 @@ ScriptInterpreterPython::GenerateTypeSynthClass (StringList &user_input, std::st
lldb::ScriptInterpreterObjectSP
ScriptInterpreterPython::OSPlugin_CreatePluginObject (const char *class_name, lldb::ProcessSP process_sp)
{
- if (class_name == NULL || class_name[0] == '\0')
+ if (class_name == nullptr || class_name[0] == '\0')
return lldb::ScriptInterpreterObjectSP();
if (!process_sp)
@@ -1319,7 +1353,7 @@ ScriptInterpreterPython::OSPlugin_RegisterInfo (lldb::ScriptInterpreterObjectSP
PyObject* implementor = (PyObject*)os_plugin_object_sp->GetObject();
- if (implementor == NULL || implementor == Py_None)
+ if (implementor == nullptr || implementor == Py_None)
return lldb::ScriptInterpreterObjectSP();
PyObject* pmeth = PyObject_GetAttrString(implementor, callee_name);
@@ -1329,7 +1363,7 @@ ScriptInterpreterPython::OSPlugin_RegisterInfo (lldb::ScriptInterpreterObjectSP
PyErr_Clear();
}
- if (pmeth == NULL || pmeth == Py_None)
+ if (pmeth == nullptr || pmeth == Py_None)
{
Py_XDECREF(pmeth);
return lldb::ScriptInterpreterObjectSP();
@@ -1354,7 +1388,7 @@ ScriptInterpreterPython::OSPlugin_RegisterInfo (lldb::ScriptInterpreterObjectSP
Py_XDECREF(pmeth);
// right now we know this function exists and is callable..
- PyObject* py_return = PyObject_CallMethod(implementor, callee_name, NULL);
+ PyObject* py_return = PyObject_CallMethod(implementor, callee_name, nullptr);
// if it fails, print the error but otherwise go on
if (PyErr_Occurred())
@@ -1380,7 +1414,7 @@ ScriptInterpreterPython::OSPlugin_ThreadsInfo (lldb::ScriptInterpreterObjectSP o
PyObject* implementor = (PyObject*)os_plugin_object_sp->GetObject();
- if (implementor == NULL || implementor == Py_None)
+ if (implementor == nullptr || implementor == Py_None)
return lldb::ScriptInterpreterObjectSP();
PyObject* pmeth = PyObject_GetAttrString(implementor, callee_name);
@@ -1390,7 +1424,7 @@ ScriptInterpreterPython::OSPlugin_ThreadsInfo (lldb::ScriptInterpreterObjectSP o
PyErr_Clear();
}
- if (pmeth == NULL || pmeth == Py_None)
+ if (pmeth == nullptr || pmeth == Py_None)
{
Py_XDECREF(pmeth);
return lldb::ScriptInterpreterObjectSP();
@@ -1415,7 +1449,7 @@ ScriptInterpreterPython::OSPlugin_ThreadsInfo (lldb::ScriptInterpreterObjectSP o
Py_XDECREF(pmeth);
// right now we know this function exists and is callable..
- PyObject* py_return = PyObject_CallMethod(implementor, callee_name, NULL);
+ PyObject* py_return = PyObject_CallMethod(implementor, callee_name, nullptr);
// if it fails, print the error but otherwise go on
if (PyErr_Occurred())
@@ -1437,7 +1471,7 @@ template <typename T>
const char *GetPythonValueFormatString(T t)
{
assert(!"Unhandled type passed to GetPythonValueFormatString(T), make a specialization of GetPythonValueFormatString() to support this type.");
- return NULL;
+ return nullptr;
}
template <> const char *GetPythonValueFormatString (char *) { return "s"; }
template <> const char *GetPythonValueFormatString (char) { return "b"; }
@@ -1469,7 +1503,7 @@ ScriptInterpreterPython::OSPlugin_RegisterContextData (lldb::ScriptInterpreterOb
PyObject* implementor = (PyObject*)os_plugin_object_sp->GetObject();
- if (implementor == NULL || implementor == Py_None)
+ if (implementor == nullptr || implementor == Py_None)
return lldb::ScriptInterpreterObjectSP();
PyObject* pmeth = PyObject_GetAttrString(implementor, callee_name);
@@ -1479,7 +1513,7 @@ ScriptInterpreterPython::OSPlugin_RegisterContextData (lldb::ScriptInterpreterOb
PyErr_Clear();
}
- if (pmeth == NULL || pmeth == Py_None)
+ if (pmeth == nullptr || pmeth == Py_None)
{
Py_XDECREF(pmeth);
return lldb::ScriptInterpreterObjectSP();
@@ -1535,7 +1569,7 @@ ScriptInterpreterPython::OSPlugin_CreateThread (lldb::ScriptInterpreterObjectSP
PyObject* implementor = (PyObject*)os_plugin_object_sp->GetObject();
- if (implementor == NULL || implementor == Py_None)
+ if (implementor == nullptr || implementor == Py_None)
return lldb::ScriptInterpreterObjectSP();
PyObject* pmeth = PyObject_GetAttrString(implementor, callee_name);
@@ -1545,7 +1579,7 @@ ScriptInterpreterPython::OSPlugin_CreateThread (lldb::ScriptInterpreterObjectSP
PyErr_Clear();
}
- if (pmeth == NULL || pmeth == Py_None)
+ if (pmeth == nullptr || pmeth == Py_None)
{
Py_XDECREF(pmeth);
return lldb::ScriptInterpreterObjectSP();
@@ -1627,7 +1661,7 @@ lldb::ScriptInterpreterObjectSP
ScriptInterpreterPython::CreateSyntheticScriptedProvider (const char *class_name,
lldb::ValueObjectSP valobj)
{
- if (class_name == NULL || class_name[0] == '\0')
+ if (class_name == nullptr || class_name[0] == '\0')
return lldb::ScriptInterpreterObjectSP();
if (!valobj.get())
@@ -1675,25 +1709,29 @@ ScriptInterpreterPython::GenerateTypeSynthClass (const char* oneliner, std::stri
}
-bool
+Error
ScriptInterpreterPython::GenerateBreakpointCommandCallbackData (StringList &user_input, std::string& output)
{
static uint32_t num_created_functions = 0;
user_input.RemoveBlankLines ();
StreamString sstr;
-
+ Error error;
if (user_input.GetSize() == 0)
- return false;
+ {
+ error.SetErrorString("No input data.");
+ return error;
+ }
std::string auto_generated_function_name(GenerateUniqueName("lldb_autogen_python_bp_callback_func_",num_created_functions));
sstr.Printf ("def %s (frame, bp_loc, internal_dict):", auto_generated_function_name.c_str());
- if (!GenerateFunction(sstr.GetData(), user_input))
- return false;
+ error = GenerateFunction(sstr.GetData(), user_input);
+ if (!error.Success())
+ return error;
// Store the name of the auto-generated function to be called.
output.assign(auto_generated_function_name);
- return true;
+ return error;
}
bool
@@ -1709,7 +1747,7 @@ ScriptInterpreterPython::GenerateWatchpointCommandCallbackData (StringList &user
std::string auto_generated_function_name(GenerateUniqueName("lldb_autogen_python_wp_callback_func_",num_created_functions));
sstr.Printf ("def %s (frame, wp, internal_dict):", auto_generated_function_name.c_str());
- if (!GenerateFunction(sstr.GetData(), user_input))
+ if (!GenerateFunction(sstr.GetData(), user_input).Success())
return false;
// Store the name of the auto-generated function to be called.
@@ -1732,7 +1770,7 @@ ScriptInterpreterPython::GetScriptedSummary (const char *python_function_name,
return false;
}
- void* old_callee = (callee_wrapper_sp ? callee_wrapper_sp->GetObject() : NULL);
+ void* old_callee = (callee_wrapper_sp ? callee_wrapper_sp->GetObject() : nullptr);
void* new_callee = old_callee;
bool ret_val;
@@ -1764,6 +1802,21 @@ ScriptInterpreterPython::GetScriptedSummary (const char *python_function_name,
}
+void
+ScriptInterpreterPython::Clear ()
+{
+ // Release any global variables that might have strong references to
+ // LLDB objects when clearing the python script interpreter.
+ Locker locker(this,
+ ScriptInterpreterPython::Locker::AcquireLock,
+ ScriptInterpreterPython::Locker::FreeAcquiredLock);
+
+ // This may be called as part of Py_Finalize. In that case the modules are destroyed in random
+ // order and we can't guarantee that we can access these.
+ if (Py_IsInitialized())
+ PyRun_SimpleString("lldb.debugger = None; lldb.target = None; lldb.process = None; lldb.thread = None; lldb.frame = None");
+}
+
bool
ScriptInterpreterPython::BreakpointCallbackFunction
(
@@ -1914,10 +1967,10 @@ ScriptInterpreterPython::GetChildAtIndex (const lldb::ScriptInterpreterObjectSP&
{
Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
void* child_ptr = g_swig_get_child_index (implementor,idx);
- if (child_ptr != NULL && child_ptr != Py_None)
+ if (child_ptr != nullptr && child_ptr != Py_None)
{
lldb::SBValue* sb_value_ptr = (lldb::SBValue*)g_swig_cast_to_sbvalue(child_ptr);
- if (sb_value_ptr == NULL)
+ if (sb_value_ptr == nullptr)
Py_XDECREF(child_ptr);
else
ret_val = g_swig_get_valobj_sp_from_sbvalue (sb_value_ptr);
@@ -2006,15 +2059,15 @@ ScriptInterpreterPython::MightHaveChildrenSynthProviderInstance (const lldb::Scr
static std::string
ReadPythonBacktrace (PyObject* py_backtrace)
{
- PyObject* traceback_module = NULL,
- *stringIO_module = NULL,
- *stringIO_builder = NULL,
- *stringIO_buffer = NULL,
- *printTB = NULL,
- *printTB_args = NULL,
- *printTB_result = NULL,
- *stringIO_getvalue = NULL,
- *printTB_string = NULL;
+ PyObject* traceback_module = nullptr,
+ *stringIO_module = nullptr,
+ *stringIO_builder = nullptr,
+ *stringIO_buffer = nullptr,
+ *printTB = nullptr,
+ *printTB_args = nullptr,
+ *printTB_result = nullptr,
+ *stringIO_getvalue = nullptr,
+ *printTB_string = nullptr;
std::string retval("backtrace unavailable");
@@ -2028,7 +2081,7 @@ ReadPythonBacktrace (PyObject* py_backtrace)
stringIO_builder = PyObject_GetAttrString(stringIO_module, "StringIO");
if (stringIO_builder && stringIO_builder != Py_None)
{
- stringIO_buffer = PyObject_CallObject(stringIO_builder, NULL);
+ stringIO_buffer = PyObject_CallObject(stringIO_builder, nullptr);
if (stringIO_buffer && stringIO_buffer != Py_None)
{
printTB = PyObject_GetAttrString(traceback_module, "print_tb");
@@ -2039,7 +2092,7 @@ ReadPythonBacktrace (PyObject* py_backtrace)
stringIO_getvalue = PyObject_GetAttrString(stringIO_buffer, "getvalue");
if (stringIO_getvalue && stringIO_getvalue != Py_None)
{
- printTB_string = PyObject_CallObject (stringIO_getvalue,NULL);
+ printTB_string = PyObject_CallObject (stringIO_getvalue,nullptr);
if (printTB_string && printTB_string != Py_None && PyString_Check(printTB_string))
retval.assign(PyString_AsString(printTB_string));
}
@@ -2393,29 +2446,20 @@ ScriptInterpreterPython::RunScriptBasedCommand(const char* impl_function,
{
error.SetErrorString("invalid Debugger pointer");
return false;
- }
+ }
bool ret_val = false;
std::string err_msg;
-
+
{
Locker py_lock(this,
- Locker::AcquireLock | Locker::InitSession,
+ Locker::AcquireLock | Locker::InitSession | (cmd_retobj.GetInteractive() ? 0 : Locker::NoSTDIN),
Locker::FreeLock | Locker::TearDownSession);
SynchronicityHandler synch_handler(debugger_sp,
synchronicity);
- // we need to save the thread state when we first start the command
- // because we might decide to interrupt it while some action is taking
- // place outside of Python (e.g. printing to screen, waiting for the network, ...)
- // in that case, _PyThreadState_Current will be NULL - and we would be unable
- // to set the asynchronous exception - not a desirable situation
- m_command_thread_state = _PyThreadState_Current;
-
- //PythonInputReaderManager py_input(this);
-
ret_val = g_swig_call_command (impl_function,
m_dictionary_name.c_str(),
debugger_sp,
@@ -2443,7 +2487,7 @@ ScriptInterpreterPython::GetDocumentationForItem(const char* item, std::string&
std::string command(item);
command += ".__doc__";
- char* result_ptr = NULL; // Python is going to point this to valid data if ExecuteOneLineWithReturn returns successfully
+ char* result_ptr = nullptr; // Python is going to point this to valid data if ExecuteOneLineWithReturn returns successfully
if (ExecuteOneLineWithReturn (command.c_str(),
ScriptInterpreter::eScriptReturnTypeCharStrOrNone,
@@ -2561,7 +2605,7 @@ ScriptInterpreterPython::InitializePrivate ()
FileSpec file_spec;
char python_dir_path[PATH_MAX];
- if (Host::GetLLDBPath (ePathTypePythonDir, file_spec))
+ if (HostInfo::GetLLDBPath(ePathTypePythonDir, file_spec))
{
std::string python_path("sys.path.insert(0,\"");
size_t orig_len = python_path.length();
@@ -2572,8 +2616,8 @@ ScriptInterpreterPython::InitializePrivate ()
PyRun_SimpleString (python_path.c_str());
python_path.resize (orig_len);
}
-
- if (Host::GetLLDBPath (ePathTypeLLDBShlibDir, file_spec))
+
+ if (HostInfo::GetLLDBPath(ePathTypeLLDBShlibDir, file_spec))
{
if (file_spec.GetPath(python_dir_path, sizeof (python_dir_path)))
{
@@ -2585,7 +2629,7 @@ ScriptInterpreterPython::InitializePrivate ()
}
}
- PyRun_SimpleString ("sys.dont_write_bytecode = 1; import lldb.embedded_interpreter; from lldb.embedded_interpreter import run_python_interpreter; from lldb.embedded_interpreter import run_one_line; from termios import *");
+ PyRun_SimpleString ("sys.dont_write_bytecode = 1; import lldb.embedded_interpreter; from lldb.embedded_interpreter import run_python_interpreter; from lldb.embedded_interpreter import run_one_line");
if (threads_already_initialized) {
if (log)
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/embedded_interpreter.py b/contrib/llvm/tools/lldb/source/Interpreter/embedded_interpreter.py
index bc0dd6d..51a9716 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/embedded_interpreter.py
+++ b/contrib/llvm/tools/lldb/source/Interpreter/embedded_interpreter.py
@@ -9,6 +9,10 @@ try:
import rlcompleter
except ImportError:
have_readline = False
+except AttributeError:
+ # This exception gets hit by the rlcompleter when Linux is using
+ # the readline suppression import.
+ have_readline = False
else:
have_readline = True
if 'libedit' in readline.__doc__:
OpenPOWER on IntegriCloud