diff options
Diffstat (limited to 'lldb/source/Interpreter/OptionGroupFormat.cpp')
-rw-r--r-- | lldb/source/Interpreter/OptionGroupFormat.cpp | 56 |
1 files changed, 45 insertions, 11 deletions
diff --git a/lldb/source/Interpreter/OptionGroupFormat.cpp b/lldb/source/Interpreter/OptionGroupFormat.cpp index 7f6ebbf51fd..ad4f371d836 100644 --- a/lldb/source/Interpreter/OptionGroupFormat.cpp +++ b/lldb/source/Interpreter/OptionGroupFormat.cpp @@ -18,14 +18,12 @@ using namespace lldb; using namespace lldb_private; -OptionGroupFormat::OptionGroupFormat(lldb::Format default_format, - uint32_t default_byte_size, - bool byte_size_prefix_ok) : - m_format (default_format, - default_format, - default_byte_size, - default_byte_size, - byte_size_prefix_ok) +OptionGroupFormat::OptionGroupFormat (lldb::Format default_format, + uint64_t default_byte_size, + uint64_t default_count) : + m_format (default_format, default_format), + m_byte_size (default_byte_size, default_byte_size), + m_count (default_count, default_count) { } @@ -36,13 +34,22 @@ OptionGroupFormat::~OptionGroupFormat () static OptionDefinition g_option_table[] = { - { LLDB_OPT_SET_1 , false, "format", 'f', required_argument, NULL, 0, eArgTypeFormat , "Specify a format to be used for display."}, +{ LLDB_OPT_SET_1, false, "format",'f', required_argument, NULL, 0, eArgTypeFormat , "Specify a format to be used for display."}, +{ LLDB_OPT_SET_2, false, "size" ,'s', required_argument, NULL, 0, eArgTypeByteSize, "The size in bytes to use when displaying with the selected format."}, +{ LLDB_OPT_SET_3, false, "count" ,'c', required_argument, NULL, 0, eArgTypeCount , "The number of total items to display."}, }; uint32_t OptionGroupFormat::GetNumDefinitions () { - return arraysize(g_option_table); + if (m_byte_size.GetDefaultValue() < UINT64_MAX) + { + if (m_count.GetDefaultValue() < UINT64_MAX) + return 3; + else + return 2; + } + return 1; } const OptionDefinition * @@ -65,6 +72,32 @@ OptionGroupFormat::SetOptionValue (CommandInterpreter &interpreter, error = m_format.SetValueFromCString (option_arg); break; + case 'c': + if (m_count.GetDefaultValue() == 0) + { + error.SetErrorString ("--count option is disabled"); + } + else + { + error = m_count.SetValueFromCString (option_arg); + if (m_count.GetCurrentValue() == 0) + error.SetErrorStringWithFormat("invalid --count option value '%s'", option_arg); + } + break; + + case 's': + if (m_byte_size.GetDefaultValue() == 0) + { + error.SetErrorString ("--size option is disabled"); + } + else + { + error = m_byte_size.SetValueFromCString (option_arg); + if (m_byte_size.GetCurrentValue() == 0) + error.SetErrorStringWithFormat("invalid --size option value '%s'", option_arg); + } + break; + default: error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); break; @@ -77,5 +110,6 @@ void OptionGroupFormat::OptionParsingStarting (CommandInterpreter &interpreter) { m_format.Clear(); + m_byte_size.Clear(); + m_count.Clear(); } - |