diff options
author | Greg Clayton <gclayton@apple.com> | 2011-10-25 06:44:01 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2011-10-25 06:44:01 +0000 |
commit | 1deb79623896414dae71b7827de8c9ba2eb3bdd9 (patch) | |
tree | 47b4b9f36f0aaa3392665144a0c2ee28f947522f /lldb/source/Interpreter | |
parent | d4268d91e7f1df42776a8e1994c7415fc04d7571 (diff) | |
download | bcm5719-llvm-1deb79623896414dae71b7827de8c9ba2eb3bdd9.tar.gz bcm5719-llvm-1deb79623896414dae71b7827de8c9ba2eb3bdd9.zip |
Updated all commands that use a "--format" / "-f" options to use the new
OptionGroupFormat. Updated OptionGroupFormat to be able to also use the
"--size" and "--count" options. Commands that use a OptionGroupFormat instance
can choose which of the options they want by initializing OptionGroupFormat
accordingly. Clients can either get only the "--format", "--format" + "--size",
or "--format" + "--size" + "--count". This is in preparation for upcoming
chnages where there are alternate ways (GDB format specification) to set a
format.
llvm-svn: 142911
Diffstat (limited to 'lldb/source/Interpreter')
-rw-r--r-- | lldb/source/Interpreter/NamedOptionValue.cpp | 5 | ||||
-rw-r--r-- | lldb/source/Interpreter/OptionGroupFormat.cpp | 56 | ||||
-rw-r--r-- | lldb/source/Interpreter/OptionGroupVariable.cpp | 3 |
3 files changed, 46 insertions, 18 deletions
diff --git a/lldb/source/Interpreter/NamedOptionValue.cpp b/lldb/source/Interpreter/NamedOptionValue.cpp index ab4f4d0da64..f4c0e345882 100644 --- a/lldb/source/Interpreter/NamedOptionValue.cpp +++ b/lldb/source/Interpreter/NamedOptionValue.cpp @@ -368,14 +368,11 @@ Error OptionValueFormat::SetValueFromCString (const char *value_cstr) { Format new_format; - uint32_t new_byte_size = UINT32_MAX; - Error error (Args::StringToFormat(value_cstr, new_format, m_byte_size_prefix_ok ? &new_byte_size : NULL)); + Error error (Args::StringToFormat (value_cstr, new_format, NULL)); if (error.Success()) { m_value_was_set = true; m_current_value = new_format; - if (new_byte_size != UINT32_MAX) - m_current_byte_size = new_byte_size; } return error; } 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(); } - diff --git a/lldb/source/Interpreter/OptionGroupVariable.cpp b/lldb/source/Interpreter/OptionGroupVariable.cpp index a2bdbb26e2a..9e9de7d91b1 100644 --- a/lldb/source/Interpreter/OptionGroupVariable.cpp +++ b/lldb/source/Interpreter/OptionGroupVariable.cpp @@ -28,7 +28,6 @@ g_option_table[] = { LLDB_OPT_SET_1, false, "no-locals", 'l', no_argument, NULL, 0, eArgTypeNone, "Omit local variables."}, { LLDB_OPT_SET_1, false, "show-globals", 'g', no_argument, NULL, 0, eArgTypeNone, "Show the current frame source file global and static variables."}, { LLDB_OPT_SET_1, false, "show-declaration",'c', no_argument, NULL, 0, eArgTypeNone, "Show variable declaration information (source file and line where the variable was declared)."}, - { LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, eArgTypeExprFormat, "Specify the format that the variable output should use."}, { LLDB_OPT_SET_1, false, "regex", 'r', no_argument, NULL, 0, eArgTypeRegularExpression, "The <variable-name> argument for name lookups are regular expressions."}, { LLDB_OPT_SET_1, false, "scope", 's', no_argument, NULL, 0, eArgTypeNone, "Show variable scope (argument, local, global, static)."}, { LLDB_OPT_SET_1, false, "summary", 'y', required_argument, NULL, 0, eArgTypeName, "Specify the summary that the variable output should use."}, @@ -61,7 +60,6 @@ OptionGroupVariable::SetOptionValue (CommandInterpreter &interpreter, case 'l': show_locals = false; break; case 'g': show_globals = true; break; case 'c': show_decl = true; break; - case 'f': error = Args::StringToFormat(option_arg, format, NULL); break; case 's': show_scope = true; break; @@ -83,7 +81,6 @@ OptionGroupVariable::OptionParsingStarting (CommandInterpreter &interpreter) show_locals = true; // Frame option only show_globals = false; // Frame option only show_decl = false; - format = lldb::eFormatDefault; use_regex = false; show_scope = false; summary = ""; |