diff options
Diffstat (limited to 'lldb/source/Interpreter')
| -rw-r--r-- | lldb/source/Interpreter/Args.cpp | 45 | ||||
| -rw-r--r-- | lldb/source/Interpreter/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | lldb/source/Interpreter/CommandOptionValidators.cpp | 39 | ||||
| -rw-r--r-- | lldb/source/Interpreter/OptionGroupArchitecture.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Interpreter/OptionGroupFormat.cpp | 8 | ||||
| -rw-r--r-- | lldb/source/Interpreter/OptionGroupOutputFile.cpp | 4 | ||||
| -rw-r--r-- | lldb/source/Interpreter/OptionGroupPlatform.cpp | 8 | ||||
| -rw-r--r-- | lldb/source/Interpreter/OptionGroupUUID.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp | 24 | ||||
| -rw-r--r-- | lldb/source/Interpreter/OptionGroupVariable.cpp | 16 | ||||
| -rw-r--r-- | lldb/source/Interpreter/OptionGroupWatchpoint.cpp | 4 | ||||
| -rw-r--r-- | lldb/source/Interpreter/Options.cpp | 47 |
12 files changed, 132 insertions, 68 deletions
diff --git a/lldb/source/Interpreter/Args.cpp b/lldb/source/Interpreter/Args.cpp index facddcd94c4..0b8f3e1a917 100644 --- a/lldb/source/Interpreter/Args.cpp +++ b/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" @@ -627,14 +628,14 @@ Args::ParseOptions (Options &options) return error; } - for (int i=0; long_options[i].name != nullptr; ++i) + for (int i=0; long_options[i].definition != nullptr; ++i) { 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 ? nullptr : 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 { @@ -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) @@ -1278,12 +1289,12 @@ Args::ParseAliasOptions (Options &options, return; } - for (i = 0; long_options[i].name != nullptr; ++i) + for (i = 0; long_options[i].definition != nullptr; ++i) { 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: @@ -1328,7 +1339,7 @@ Args::ParseAliasOptions (Options &options, 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()), @@ -1410,7 +1423,7 @@ Args::ParseAliasOptions (Options &options, raw_input_string.erase (pos, strlen (tmp_arg)); } ReplaceArgumentAtIndex (idx, ""); - if ((long_options[long_options_index].has_arg != OptionParser::eNoArgument) + 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)) @@ -1453,12 +1466,12 @@ Args::ParseArgsForCompletion // to suppress error messages. sstr << ":"; - for (int i = 0; long_options[i].name != nullptr; ++i) + for (int i = 0; long_options[i].definition != nullptr; ++i) { 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: @@ -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,7 +1594,9 @@ 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)); diff --git a/lldb/source/Interpreter/CMakeLists.txt b/lldb/source/Interpreter/CMakeLists.txt index 27597fc3c3e..52f89bb3e9b 100644 --- a/lldb/source/Interpreter/CMakeLists.txt +++ b/lldb/source/Interpreter/CMakeLists.txt @@ -7,6 +7,7 @@ add_lldb_library(lldbInterpreter CommandObject.cpp CommandObjectRegexCommand.cpp CommandObjectScript.cpp + CommandOptionValidators.cpp CommandReturnObject.cpp OptionGroupArchitecture.cpp OptionGroupBoolean.cpp diff --git a/lldb/source/Interpreter/CommandOptionValidators.cpp b/lldb/source/Interpreter/CommandOptionValidators.cpp new file mode 100644 index 00000000000..7d66de53c0b --- /dev/null +++ b/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/lldb/source/Interpreter/OptionGroupArchitecture.cpp b/lldb/source/Interpreter/OptionGroupArchitecture.cpp index 4c9d8ab28f6..3a454093ab2 100644 --- a/lldb/source/Interpreter/OptionGroupArchitecture.cpp +++ b/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, nullptr, 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/lldb/source/Interpreter/OptionGroupFormat.cpp b/lldb/source/Interpreter/OptionGroupFormat.cpp index f929b55bd56..601a7845873 100644 --- a/lldb/source/Interpreter/OptionGroupFormat.cpp +++ b/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, nullptr, 0, eArgTypeFormat , "Specify a format to be used for display."}, -{ LLDB_OPT_SET_2, false, "gdb-format",'G', OptionParser::eRequiredArgument, nullptr, 0, eArgTypeGDBFormat, "Specify a format using a GDB format specifier string."}, -{ LLDB_OPT_SET_3, false, "size" ,'s', OptionParser::eRequiredArgument, 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, 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 diff --git a/lldb/source/Interpreter/OptionGroupOutputFile.cpp b/lldb/source/Interpreter/OptionGroupOutputFile.cpp index f3ffb8a75c8..ec9e166d2f0 100644 --- a/lldb/source/Interpreter/OptionGroupOutputFile.cpp +++ b/lldb/source/Interpreter/OptionGroupOutputFile.cpp @@ -33,9 +33,9 @@ static const uint32_t SHORT_OPTION_APND = 0x61706e64; // 'apnd' static OptionDefinition g_option_table[] = { - { LLDB_OPT_SET_1 , false, "outfile", 'o', OptionParser::eRequiredArgument, nullptr, 0, eArgTypeFilename , "Specify a path for capturing command output."}, + { 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, 0, eArgTypeNone , + OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone , "Append to the the file specified with '--outfile <path>'."}, }; diff --git a/lldb/source/Interpreter/OptionGroupPlatform.cpp b/lldb/source/Interpreter/OptionGroupPlatform.cpp index a97249c2f07..9ffd5f072d9 100644 --- a/lldb/source/Interpreter/OptionGroupPlatform.cpp +++ b/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, 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, 0, eArgTypeNone, "Specify the initial SDK version to use prior to connecting." }, - { LLDB_OPT_SET_ALL, false, "build" , 'b', OptionParser::eRequiredArgument, nullptr, 0, eArgTypeNone, "Specify the initial SDK build number." }, - { LLDB_OPT_SET_ALL, false, "sysroot" , 'S', OptionParser::eRequiredArgument, nullptr, 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/lldb/source/Interpreter/OptionGroupUUID.cpp b/lldb/source/Interpreter/OptionGroupUUID.cpp index 91b5fafc54b..43f7386c9ca 100644 --- a/lldb/source/Interpreter/OptionGroupUUID.cpp +++ b/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, nullptr, 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/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp b/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp index 3badc0fa5a4..125e5fb0a5d 100644 --- a/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp +++ b/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, nullptr, 0, eArgTypeBoolean, "Show the object obeying its synthetic provider, if available."}, - { LLDB_OPT_SET_1, false, "depth", 'D', OptionParser::eRequiredArgument, 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, 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, 0, eArgTypeNone, "Show variable location information."}, - { LLDB_OPT_SET_1, false, "object-description", 'O', OptionParser::eNoArgument, nullptr, 0, eArgTypeNone, "Print as an Objective-C object."}, - { LLDB_OPT_SET_1, false, "ptr-depth", 'P', OptionParser::eRequiredArgument, 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, 0, eArgTypeNone, "Show variable types when dumping values."}, - { LLDB_OPT_SET_1, false, "no-summary-depth", 'Y', OptionParser::eOptionalArgument, 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, 0, eArgTypeNone, "Don't use formatting options."}, - { LLDB_OPT_SET_1, false, "show-all-children", 'A', OptionParser::eNoArgument, nullptr, 0, eArgTypeNone, "Ignore the upper bound on the number of children to show."}, - { 0, false, nullptr, 0, 0, nullptr, 0, eArgTypeNone, nullptr } + { 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 diff --git a/lldb/source/Interpreter/OptionGroupVariable.cpp b/lldb/source/Interpreter/OptionGroupVariable.cpp index e2acc94df20..05cf3f73bfe 100644 --- a/lldb/source/Interpreter/OptionGroupVariable.cpp +++ b/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, nullptr, 0, eArgTypeNone, "Omit function arguments."}, - { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "no-locals", 'l', OptionParser::eNoArgument, nullptr, 0, eArgTypeNone, "Omit local variables."}, - { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "show-globals", 'g', OptionParser::eNoArgument, 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, 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, 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, 0, eArgTypeNone, "Show variable scope (argument, local, global, static)."}, - { LLDB_OPT_SET_1, false, "summary", 'y', OptionParser::eRequiredArgument, nullptr, 0, eArgTypeName, "Specify the summary that the variable output should use."}, - { LLDB_OPT_SET_2, false, "summary-string", 'z', OptionParser::eRequiredArgument, nullptr, 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/lldb/source/Interpreter/OptionGroupWatchpoint.cpp b/lldb/source/Interpreter/OptionGroupWatchpoint.cpp index bc2548e4445..f4d8df1e6ba 100644 --- a/lldb/source/Interpreter/OptionGroupWatchpoint.cpp +++ b/lldb/source/Interpreter/OptionGroupWatchpoint.cpp @@ -40,8 +40,8 @@ static OptionEnumValueElement g_watch_size[] = 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/lldb/source/Interpreter/Options.cpp b/lldb/source/Interpreter/Options.cpp index 3d65116a45e..a8766f5f861 100644 --- a/lldb/source/Interpreter/Options.cpp +++ b/lldb/source/Interpreter/Options.cpp @@ -277,8 +277,7 @@ 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].definition = &opt_defs[i]; m_getopt_table[i].flag = nullptr; m_getopt_table[i].val = short_opt; @@ -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,17 +304,16 @@ 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 = nullptr; - m_getopt_table[i].has_arg = 0; - m_getopt_table[i].flag = nullptr; - 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()) @@ -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 (static_cast<uint32_t>(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(); @@ -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 @@ -683,7 +692,7 @@ 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 != nullptr) { @@ -1026,7 +1035,7 @@ void OptionGroupOptions::Finalize () { m_did_finalize = true; - OptionDefinition empty_option_def = { 0, false, nullptr, 0, 0, nullptr, 0, eArgTypeNone, nullptr }; + OptionDefinition empty_option_def = { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }; m_option_defs.push_back (empty_option_def); } |

