[Lldb-commits] [lldb] r142911 - in /lldb/trunk: include/lldb/Interpreter/ lldb.xcodeproj/ source/Commands/ source/Interpreter/

Greg Clayton gclayton at apple.com
Mon Oct 24 23:44:01 PDT 2011


Author: gclayton
Date: Tue Oct 25 01:44:01 2011
New Revision: 142911

URL: http://llvm.org/viewvc/llvm-project?rev=142911&view=rev
Log:
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. 


Modified:
    lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h
    lldb/trunk/include/lldb/Interpreter/OptionGroupFormat.h
    lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h
    lldb/trunk/lldb.xcodeproj/project.pbxproj
    lldb/trunk/source/Commands/CommandObjectExpression.cpp
    lldb/trunk/source/Commands/CommandObjectExpression.h
    lldb/trunk/source/Commands/CommandObjectFrame.cpp
    lldb/trunk/source/Commands/CommandObjectMemory.cpp
    lldb/trunk/source/Commands/CommandObjectRegister.cpp
    lldb/trunk/source/Commands/CommandObjectTarget.cpp
    lldb/trunk/source/Commands/CommandObjectType.cpp
    lldb/trunk/source/Commands/CommandObjectType.h
    lldb/trunk/source/Interpreter/NamedOptionValue.cpp
    lldb/trunk/source/Interpreter/OptionGroupFormat.cpp
    lldb/trunk/source/Interpreter/OptionGroupVariable.cpp

Modified: lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h?rev=142911&r1=142910&r2=142911&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h (original)
+++ lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h Tue Oct 25 01:44:01 2011
@@ -729,16 +729,10 @@
     class OptionValueFormat : public OptionValue
     {
     public:
-        OptionValueFormat (lldb::Format current_value = lldb::eFormatDefault, 
-                           lldb::Format default_value = lldb::eFormatDefault,
-                           uint32_t current_byte_size = 0,
-                           uint32_t default_byte_size = 0,
-                           bool byte_size_prefix_ok = false) :
+        OptionValueFormat (lldb::Format current_value, 
+                           lldb::Format default_value) :
             m_current_value (current_value),
-            m_default_value (default_value),
-            m_current_byte_size (current_byte_size),
-            m_default_byte_size (default_byte_size),
-            m_byte_size_prefix_ok (byte_size_prefix_ok)
+            m_default_value (default_value)
         {
         }
         
@@ -799,36 +793,9 @@
             m_default_value = value;
         }
         
-        uint32_t 
-        GetCurrentByteSize () const
-        {
-            return m_current_byte_size;
-        }
-
-        uint32_t 
-        GetDefaultByteSize () const
-        {
-            return m_default_byte_size;
-        }
-        
-        void
-        SetCurrentByteSize (uint32_t byte_size)
-        {
-            m_current_byte_size = byte_size;
-        }
-        
-        void
-        SetDefaultByteSize (uint32_t byte_size)
-        {
-            m_default_byte_size = byte_size;
-        }
-
     protected:
         lldb::Format m_current_value;
         lldb::Format m_default_value;
-        uint32_t m_current_byte_size;
-        uint32_t m_default_byte_size;
-        bool m_byte_size_prefix_ok;
     };
     
     

Modified: lldb/trunk/include/lldb/Interpreter/OptionGroupFormat.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionGroupFormat.h?rev=142911&r1=142910&r2=142911&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/OptionGroupFormat.h (original)
+++ lldb/trunk/include/lldb/Interpreter/OptionGroupFormat.h Tue Oct 25 01:44:01 2011
@@ -26,10 +26,13 @@
 class OptionGroupFormat : public OptionGroup
 {
 public:
+    static const uint32_t OPTION_GROUP_FORMAT = LLDB_OPT_SET_1;
+    static const uint32_t OPTION_GROUP_SIZE   = LLDB_OPT_SET_2;
+    static const uint32_t OPTION_GROUP_COUNT  = LLDB_OPT_SET_3;
     
     OptionGroupFormat (lldb::Format default_format, 
-                       uint32_t default_byte_size,
-                       bool byte_size_prefix_ok);
+                       uint64_t default_byte_size = UINT64_MAX,  // Pass UINT64_MAX to disable the "--size" option
+                       uint64_t default_count = UINT64_MAX);     // Pass UINT64_MAX to disable the "--count" option
     
     virtual
     ~OptionGroupFormat ();
@@ -55,15 +58,48 @@
         return m_format.GetCurrentValue();
     }
 
-    uint32_t
-    GetByteSize() const
+    OptionValueFormat &
+    GetFormatValue()
     {
-        return m_format.GetCurrentByteSize();
+        return m_format;
     }
     
+    const OptionValueFormat &
+    GetFormatValue() const
+    {
+        return m_format;
+    }
+    
+    OptionValueUInt64  &
+    GetByteSizeValue()
+    {
+        return m_byte_size;
+    }
+
+    const OptionValueUInt64  &
+    GetByteSizeValue() const 
+    {
+        return m_byte_size;
+    }
+
+    OptionValueUInt64  &
+    GetCountValue()
+    {
+        return m_count;
+    }
+
+    const OptionValueUInt64  &
+    GetCountValue() const
+    {
+        return m_count;
+    }
+    
+
 protected:
 
     OptionValueFormat m_format;
+    OptionValueUInt64 m_byte_size;
+    OptionValueUInt64 m_count;
 };
 
 } // namespace lldb_private

Modified: lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h?rev=142911&r1=142910&r2=142911&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h (original)
+++ lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h Tue Oct 25 01:44:01 2011
@@ -52,7 +52,6 @@
              use_regex:1,
              show_scope:1,
              show_decl:1;
-        lldb::Format format;
         std::string summary;
 
     private:

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=142911&r1=142910&r2=142911&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Oct 25 01:44:01 2011
@@ -3577,7 +3577,7 @@
 			buildSettings = {
 				ALWAYS_SEARCH_USER_PATHS = NO;
 				ARCHS = "$(ARCHS_STANDARD_64_BIT)";
-				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				DEBUG_INFORMATION_FORMAT = dwarf;
 				GCC_C_LANGUAGE_STANDARD = gnu99;
 				GCC_OPTIMIZATION_LEVEL = 0;
 				GCC_PREPROCESSOR_DEFINITIONS = (

Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=142911&r1=142910&r2=142911&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Tue Oct 25 01:44:01 2011
@@ -37,11 +37,9 @@
 using namespace lldb;
 using namespace lldb_private;
 
-CommandObjectExpression::CommandOptions::CommandOptions (CommandInterpreter &interpreter) :
-    Options(interpreter)
+CommandObjectExpression::CommandOptions::CommandOptions () :
+    OptionGroup()
 {
-    // Keep only one place to reset the values to their defaults
-    OptionParsingStarting();
 }
 
 
@@ -49,12 +47,29 @@
 {
 }
 
+OptionDefinition
+CommandObjectExpression::CommandOptions::g_option_table[] =
+{
+    { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "dynamic-value",      'd', required_argument, NULL, 0, eArgTypeBoolean,    "Upcast the value resulting from the expression to its dynamic type if available."},
+    { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "unwind-on-error",    'u', required_argument, NULL, 0, eArgTypeBoolean,    "Clean up program state if the expression causes a crash, breakpoint hit or signal."},
+    { LLDB_OPT_SET_2                 , false, "object-description", 'o', no_argument,       NULL, 0, eArgTypeNone,       "Print the object description of the value resulting from the expression."},
+};
+
+
+uint32_t
+CommandObjectExpression::CommandOptions::GetNumDefinitions ()
+{
+    return sizeof(g_option_table)/sizeof(OptionDefinition);
+}
+
 Error
-CommandObjectExpression::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
+CommandObjectExpression::CommandOptions::SetOptionValue (CommandInterpreter &interpreter,
+                                                         uint32_t option_idx,
+                                                         const char *option_arg)
 {
     Error error;
 
-    char short_option = (char) m_getopt_table[option_idx].val;
+    const char short_option = (char) g_option_table[option_idx].short_option;
 
     switch (short_option)
     {
@@ -65,14 +80,6 @@
       //}
       //break;
 
-    case 'g':
-        debug = true;
-        break;
-
-    case 'f':
-        error = Args::StringToFormat(option_arg, format, NULL);
-        break;
-        
     case 'o':
         print_object = true;
         break;
@@ -111,13 +118,10 @@
 }
 
 void
-CommandObjectExpression::CommandOptions::OptionParsingStarting ()
+CommandObjectExpression::CommandOptions::OptionParsingStarting (CommandInterpreter &interpreter)
 {
-    //language.Clear();
-    debug = false;
-    format = eFormatDefault;
-    print_object = false;
     use_dynamic = eLazyBoolCalculate;
+    print_object = false;
     unwind_on_error = true;
     show_types = true;
     show_summary = true;
@@ -134,7 +138,9 @@
                    "expression",
                    "Evaluate a C/ObjC/C++ expression in the current program context, using variables currently in scope.",
                    NULL),
-    m_options (interpreter),
+    m_option_group (interpreter),
+    m_format_options (eFormatDefault),
+    m_command_options (),
     m_expr_line_count (0),
     m_expr_lines ()
 {
@@ -157,6 +163,11 @@
 
     // Push the data for the first argument into the m_arguments vector.
     m_arguments.push_back (arg);
+    
+    // Add the "--format" and "--count" options to group 1 and 3
+    m_option_group.Append (&m_format_options, OptionGroupFormat::OPTION_GROUP_FORMAT, LLDB_OPT_SET_1);
+    m_option_group.Append (&m_command_options);
+    m_option_group.Finalize();
 }
 
 CommandObjectExpression::~CommandObjectExpression ()
@@ -166,7 +177,7 @@
 Options *
 CommandObjectExpression::GetOptions ()
 {
-    return &m_options;
+    return &m_option_group;
 }
 
 
@@ -281,7 +292,7 @@
         bool keep_in_memory = true;
         lldb::DynamicValueType use_dynamic;
         // If use dynamic is not set, get it from the target:
-        switch (m_options.use_dynamic)
+        switch (m_command_options.use_dynamic)
         {
         case eLazyBoolCalculate:
             use_dynamic = target->GetPreferDynamicValue();
@@ -297,12 +308,12 @@
         exe_results = target->EvaluateExpression (expr, 
                                                   m_exe_ctx.GetFramePtr(),
                                                   eExecutionPolicyOnlyWhenNeeded,
-                                                  m_options.unwind_on_error,
+                                                  m_command_options.unwind_on_error,
                                                   keep_in_memory, 
                                                   use_dynamic, 
                                                   result_valobj_sp);
         
-        if (exe_results == eExecutionInterrupted && !m_options.unwind_on_error)
+        if (exe_results == eExecutionInterrupted && !m_command_options.unwind_on_error)
         {
             uint32_t start_frame = 0;
             uint32_t num_frames = 1;
@@ -334,8 +345,9 @@
         {
             if (result_valobj_sp->GetError().Success())
             {
-                if (m_options.format != eFormatDefault)
-                    result_valobj_sp->SetFormat (m_options.format);
+                Format format = m_format_options.GetFormat();
+                if (format != eFormatDefault)
+                    result_valobj_sp->SetFormat (format);
 
                 ValueObject::DumpValueObject (*(output_stream),
                                               result_valobj_sp.get(),   // Variable object to dump
@@ -343,9 +355,9 @@
                                               0,                        // Pointer depth to traverse (zero means stop at pointers)
                                               0,                        // Current depth, this is the top most, so zero...
                                               UINT32_MAX,               // Max depth to go when dumping concrete types, dump everything...
-                                              m_options.show_types,     // Show types when dumping?
+                                              m_command_options.show_types,     // Show types when dumping?
                                               false,                    // Show locations of variables, no since this is a host address which we don't care to see
-                                              m_options.print_object,   // Print the objective C object?
+                                              m_command_options.print_object,   // Print the objective C object?
                                               use_dynamic,
                                               true,                     // Use synthetic children if available
                                               true,                     // Scope is already checked. Const results are always in scope.
@@ -406,7 +418,7 @@
 {
     m_exe_ctx = m_interpreter.GetExecutionContext();
 
-    m_options.NotifyOptionParsingStarting();
+    m_option_group.NotifyOptionParsingStarting();
 
     const char * expr = NULL;
 
@@ -471,7 +483,7 @@
             if (!ParseOptions (args, result))
                 return false;
             
-            Error error (m_options.NotifyOptionParsingFinished());
+            Error error (m_option_group.NotifyOptionParsingFinished());
             if (error.Fail())
             {
                 result.AppendError (error.AsCString());
@@ -491,16 +503,3 @@
     return false;
 }
 
-OptionDefinition
-CommandObjectExpression::CommandOptions::g_option_table[] =
-{
-//{ LLDB_OPT_SET_ALL, false, "language",   'l', required_argument, NULL, 0, "[c|c++|objc|objc++]",          "Sets the language to use when parsing the expression."},
-//{ LLDB_OPT_SET_1, false, "format",     'f', required_argument, NULL, 0, "[ [bool|b] | [bin] | [char|c] | [oct|o] | [dec|i|d|u] | [hex|x] | [float|f] | [cstr|s] ]",  "Specify the format that the expression output should use."},
-{ LLDB_OPT_SET_1,   false, "format",             'f', required_argument, NULL, 0, eArgTypeExprFormat, "Specify the format that the expression output should use."},
-{ LLDB_OPT_SET_2,   false, "object-description", 'o', no_argument,       NULL, 0, eArgTypeNone,       "Print the object description of the value resulting from the expression."},
-{ LLDB_OPT_SET_2,   false, "dynamic-value",      'd', required_argument, NULL, 0, eArgTypeBoolean,    "Upcast the value resulting from the expression to its dynamic type if available."},
-{ LLDB_OPT_SET_ALL, false, "unwind-on-error",    'u', required_argument, NULL, 0, eArgTypeBoolean,    "Clean up program state if the expression causes a crash, breakpoint hit or signal."},
-{ LLDB_OPT_SET_ALL, false, "debug",              'g', no_argument,       NULL, 0, eArgTypeNone,       "Enable verbose debug logging of the expression parsing and evaluation."},
-{ 0,                false, NULL,                 0,   0,                 NULL, 0, eArgTypeNone,       NULL }
-};
-

Modified: lldb/trunk/source/Commands/CommandObjectExpression.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.h?rev=142911&r1=142910&r2=142911&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectExpression.h (original)
+++ lldb/trunk/source/Commands/CommandObjectExpression.h Tue Oct 25 01:44:01 2011
@@ -15,8 +15,7 @@
 // Other libraries and framework includes
 // Project includes
 #include "lldb/Interpreter/CommandObject.h"
-#include "lldb/Interpreter/Options.h"
-#include "lldb/Core/Language.h"
+#include "lldb/Interpreter/OptionGroupFormat.h"
 #include "lldb/Target/ExecutionContext.h"
 
 namespace lldb_private {
@@ -25,31 +24,32 @@
 {
 public:
 
-    class CommandOptions : public Options
+    class CommandOptions : public OptionGroup
     {
     public:
 
-        CommandOptions (CommandInterpreter &interpreter);
+        CommandOptions ();
 
         virtual
         ~CommandOptions ();
 
-        virtual Error
-        SetOptionValue (uint32_t option_idx, const char *option_arg);
-
-        void
-        OptionParsingStarting ();
-
-        const OptionDefinition*
+        virtual uint32_t
+        GetNumDefinitions ();
+        
+        virtual const OptionDefinition*
         GetDefinitions ();
+        
+        virtual Error
+        SetOptionValue (CommandInterpreter &interpreter,
+                        uint32_t option_idx,
+                        const char *option_value);
+        
+        virtual void
+        OptionParsingStarting (CommandInterpreter &interpreter);
 
         // Options table: Required for subclasses of Options.
 
         static OptionDefinition g_option_table[];
-        //Language  language;
-        lldb::Encoding  encoding;
-        lldb::Format    format;
-        bool        debug;
         bool        print_object;
         LazyBool    use_dynamic;
         bool        unwind_on_error;
@@ -93,7 +93,9 @@
                         Stream *error_stream,
                         CommandReturnObject *result = NULL);
 
-    CommandOptions m_options;
+    OptionGroupOptions m_option_group;
+    OptionGroupFormat m_format_options;
+    CommandOptions m_command_options;
     ExecutionContext m_exe_ctx;
     uint32_t m_expr_line_count;
     std::string m_expr_lines; // Multi-line expression support

Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=142911&r1=142910&r2=142911&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Tue Oct 25 01:44:01 2011
@@ -29,6 +29,7 @@
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Interpreter/Options.h"
+#include "lldb/Interpreter/OptionGroupFormat.h"
 #include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
 #include "lldb/Interpreter/OptionGroupVariable.h"
 #include "lldb/Interpreter/OptionGroupWatchpoint.h"
@@ -336,6 +337,7 @@
                        eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
         m_option_group (interpreter),
         m_option_variable(true), // Include the frame specific options by passing "true"
+        m_option_format (eFormatDefault),
         m_option_watchpoint(),
         m_varobj_options()
     {
@@ -353,6 +355,7 @@
         m_arguments.push_back (arg);
         
         m_option_group.Append (&m_option_variable, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
+        m_option_group.Append (&m_option_format, OptionGroupFormat::OPTION_GROUP_FORMAT, LLDB_OPT_SET_1);
         m_option_group.Append (&m_option_watchpoint, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
         m_option_group.Append (&m_varobj_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
         m_option_group.Finalize();
@@ -440,6 +443,9 @@
                 // Things have checked out ok...
                 // m_option_watchpoint.watch_type specifies the type of watching.
             }
+            
+            const Format format = m_option_format.GetFormat();
+
             if (command.GetArgumentCount() > 0)
             {
                 VariableList regex_var_list;
@@ -470,8 +476,8 @@
                                         valobj_sp = frame->GetValueObjectForFrameVariable (var_sp, m_varobj_options.use_dynamic);
                                         if (valobj_sp)
                                         {
-                                            if (m_option_variable.format != eFormatDefault)
-                                                valobj_sp->SetFormat (m_option_variable.format);
+                                            if (format != eFormatDefault)
+                                                valobj_sp->SetFormat (format);
                                             
                                             if (m_option_variable.show_decl && var_sp->GetDeclaration ().GetFile())
                                             {
@@ -515,8 +521,8 @@
                                                                               error);
                         if (valobj_sp)
                         {
-                            if (m_option_variable.format != eFormatDefault)
-                                valobj_sp->SetFormat (m_option_variable.format);
+                            if (format != eFormatDefault)
+                                valobj_sp->SetFormat (format);
                             if (m_option_variable.show_decl && var_sp && var_sp->GetDeclaration ().GetFile())
                             {
                                 var_sp->GetDeclaration ().DumpStopContext (&s, false);
@@ -633,8 +639,8 @@
                                                                                m_varobj_options.use_dynamic);
                             if (valobj_sp)
                             {
-                                if (m_option_variable.format != eFormatDefault)
-                                    valobj_sp->SetFormat (m_option_variable.format);
+                                if (format != eFormatDefault)
+                                    valobj_sp->SetFormat (format);
 
                                 // When dumping all variables, don't print any variables
                                 // that are not in scope to avoid extra unneeded output
@@ -673,6 +679,7 @@
 
     OptionGroupOptions m_option_group;
     OptionGroupVariable m_option_variable;
+    OptionGroupFormat m_option_format;
     OptionGroupWatchpoint m_option_watchpoint;
     OptionGroupValueObjectDisplay m_varobj_options;
 };

Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=142911&r1=142910&r2=142911&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Tue Oct 25 01:44:01 2011
@@ -35,10 +35,6 @@
 static OptionDefinition
 g_option_table[] =
 {
-    { LLDB_OPT_SET_1|
-      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_1|
-      LLDB_OPT_SET_3, false, "count"        ,'c', required_argument, NULL, 0, eArgTypeCount         ,"The number of total items to display."},
     { LLDB_OPT_SET_1, false, "num-per-line" ,'l', required_argument, NULL, 0, eArgTypeNumberPerLine ,"The number of items per line to display."},
     { LLDB_OPT_SET_2, false, "binary"       ,'b', no_argument      , NULL, 0, eArgTypeNone          ,"If true, memory will be saved as binary. If false, the memory is saved save as an ASCII dump that uses the format, size, count and number per line settings."},
     { LLDB_OPT_SET_3, true , "view-as"      ,'t', required_argument, NULL, 0, eArgTypeNone          ,"The name of a type to view memory as."},
@@ -51,8 +47,6 @@
 public:
 
     OptionGroupReadMemory () :
-        m_byte_size (1,1),
-        m_count (8,8),
         m_num_per_line (1,1),
         m_output_as_binary (false),
         m_view_as_type()
@@ -92,19 +86,7 @@
                 if (m_num_per_line.GetCurrentValue() == 0)
                     error.SetErrorStringWithFormat("Invalid value for --num-per-line option '%s'. Must be positive integer value.\n", option_arg);
                 break;
-                
-            case 'c':
-                error = m_count.SetValueFromCString (option_arg);
-                if (m_count.GetCurrentValue() == 0)
-                    error.SetErrorStringWithFormat("Invalid value for --count option '%s'. Must be positive integer value.\n", option_arg);
-                break;
-                
-            case 's':
-                error = m_byte_size.SetValueFromCString (option_arg);
-                if (m_byte_size.GetCurrentValue() == 0)
-                    error.SetErrorStringWithFormat("Invalid value for --size option '%s'. Must be positive integer value.\n", option_arg);
-                break;
-                
+
             case 'b':
                 m_output_as_binary = true;
                 break;
@@ -123,22 +105,22 @@
     virtual void
     OptionParsingStarting (CommandInterpreter &interpreter)
     {
-        m_byte_size.Clear();
-        m_count.Clear();
         m_num_per_line.Clear();
         m_output_as_binary = false;
         m_view_as_type.Clear();
     }
     
     Error
-    FinalizeSettings (Target *target, const OptionGroupFormat& format_options)
+    FinalizeSettings (Target *target, OptionGroupFormat& format_options)
     {
         Error error;
-        bool byte_size_option_set = m_byte_size.OptionWasSet();
+        OptionValueUInt64 &byte_size_value = format_options.GetByteSizeValue();
+        OptionValueUInt64 &count_value = format_options.GetCountValue();
+        bool byte_size_option_set = byte_size_value.OptionWasSet();
         const bool num_per_line_option_set = m_num_per_line.OptionWasSet();
-        const bool count_option_set = m_count.OptionWasSet();
+        const bool count_option_set = format_options.GetCountValue().OptionWasSet();
         
-        uint32_t format_byte_size = format_options.GetByteSize();
+        uint32_t format_byte_size = byte_size_value.GetCurrentValue();
         if (byte_size_option_set)
         {
             if (format_byte_size > 0)
@@ -152,7 +134,7 @@
             if (format_byte_size != 0)
             {
                 byte_size_option_set = true;
-                m_byte_size = format_byte_size;
+                byte_size_value = format_byte_size;
             }
         }
     
@@ -163,22 +145,22 @@
                 
             case eFormatBoolean:
                 if (!byte_size_option_set)
-                    m_byte_size = 1;
+                    byte_size_value = 1;
                 if (!num_per_line_option_set)
                     m_num_per_line = 1;
                 if (!count_option_set)
-                    m_count = 8;
+                    format_options.GetCountValue() = 8;
                 break;
                 
             case eFormatCString:
                 break;
                 
             case eFormatPointer:
-                m_byte_size = target->GetArchitecture().GetAddressByteSize();
+                byte_size_value = target->GetArchitecture().GetAddressByteSize();
                 if (!num_per_line_option_set)
                     m_num_per_line = 4;
                 if (!count_option_set)
-                    m_count = 8;
+                    format_options.GetCountValue() = 8;
                 break;
                 
             case eFormatBinary:
@@ -190,51 +172,51 @@
             case eFormatUnicode32:
             case eFormatUnsigned:
                 if (!byte_size_option_set)
-                    m_byte_size = 4;
+                    byte_size_value = 4;
                 if (!num_per_line_option_set)
                     m_num_per_line = 1;
                 if (!count_option_set)
-                    m_count = 8;
+                    format_options.GetCountValue() = 8;
                 break;
                 
             case eFormatBytes:
             case eFormatBytesWithASCII:
-                if (m_byte_size.OptionWasSet())
+                if (byte_size_value.OptionWasSet())
                 {
-                    if (m_byte_size > 1)
+                    if (byte_size_value > 1)
                         error.SetErrorString ("use --count option to specify an end address to display a number of bytes");
                 }
                 else
-                    m_byte_size = 1;
+                    byte_size_value = 1;
                 if (!num_per_line_option_set)
                     m_num_per_line = 16;
                 if (!count_option_set)
-                    m_count = 32;
+                    format_options.GetCountValue() = 32;
                 break;
             case eFormatCharArray:
             case eFormatChar:
             case eFormatCharPrintable:
                 if (!byte_size_option_set)
-                    m_byte_size = 1;
+                    byte_size_value = 1;
                 if (!num_per_line_option_set)
                     m_num_per_line = 32;
                 if (!count_option_set)
-                    m_count = 64;
+                    format_options.GetCountValue() = 64;
                 break;
             case eFormatComplex:
                 if (!byte_size_option_set)
-                    m_byte_size = 8;
+                    byte_size_value = 8;
                 if (!num_per_line_option_set)
                     m_num_per_line = 1;
                 if (!count_option_set)
-                    m_count = 8;
+                    format_options.GetCountValue() = 8;
                 break;
             case eFormatHex:
                 if (!byte_size_option_set)
-                    m_byte_size = 4;
+                    byte_size_value = 4;
                 if (!num_per_line_option_set)
                 {
-                    switch (m_byte_size)
+                    switch (byte_size_value)
                     {
                         case 1:
                         case 2:
@@ -252,7 +234,7 @@
                     }
                 }
                 if (!count_option_set)
-                    m_count = 8;
+                    count_value = 8;
                 break;
                 
             case eFormatVectorOfChar:
@@ -268,18 +250,16 @@
             case eFormatVectorOfFloat64:
             case eFormatVectorOfUInt128:
                 if (!byte_size_option_set)
-                    m_byte_size = 128;
+                    byte_size_value = 128;
                 if (!num_per_line_option_set)
                     m_num_per_line = 1;
                 if (!count_option_set)
-                    m_count = 4;
+                    count_value = 4;
                 break;
         }
         return error;
     }
 
-    OptionValueUInt64 m_byte_size;
-    OptionValueUInt64 m_count;
     OptionValueUInt64 m_num_per_line;
     bool m_output_as_binary;
     OptionValueString m_view_as_type;
@@ -301,7 +281,7 @@
                        NULL,
                        eFlagProcessMustBePaused),
         m_option_group (interpreter),
-        m_format_options (eFormatBytesWithASCII, 0, true),
+        m_format_options (eFormatBytesWithASCII, 1, 8),
         m_memory_options (),
         m_outfile_options (),
         m_varobj_options()
@@ -329,7 +309,14 @@
         m_arguments.push_back (arg1);
         m_arguments.push_back (arg2);
         
-        m_option_group.Append (&m_format_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1 | LLDB_OPT_SET_3);
+        // Add the "--format" and "--count" options to group 1 and 3
+        m_option_group.Append (&m_format_options, 
+                               OptionGroupFormat::OPTION_GROUP_FORMAT | OptionGroupFormat::OPTION_GROUP_COUNT, 
+                               LLDB_OPT_SET_1 | LLDB_OPT_SET_3);
+        // Add the "--size" option to group 1 and 2
+        m_option_group.Append (&m_format_options, 
+                               OptionGroupFormat::OPTION_GROUP_SIZE, 
+                               LLDB_OPT_SET_1 | LLDB_OPT_SET_2);
         m_option_group.Append (&m_memory_options);
         m_option_group.Append (&m_outfile_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1 | LLDB_OPT_SET_2 | LLDB_OPT_SET_3);
         m_option_group.Append (&m_varobj_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_3);
@@ -491,9 +478,9 @@
                 --pointer_count;
             }
 
-            m_memory_options.m_byte_size = (clang_ast_type.GetClangTypeBitWidth () + 7) / 8;
+            m_format_options.GetByteSizeValue() = (clang_ast_type.GetClangTypeBitWidth () + 7) / 8;
             
-            if (m_memory_options.m_byte_size == 0)
+            if (m_format_options.GetByteSizeValue() == 0)
             {
                 result.AppendErrorWithFormat ("unable to get the byte size of the type '%s'\n", 
                                               view_as_type_cstr);
@@ -501,8 +488,8 @@
                 return false;
             }
             
-            if (!m_memory_options.m_count.OptionWasSet())
-                m_memory_options.m_count = 1;
+            if (!m_format_options.GetCountValue().OptionWasSet())
+                m_format_options.GetCountValue() = 1;
         }
         else
         {
@@ -517,8 +504,8 @@
             return false;
         }
 
-        size_t item_count = m_memory_options.m_count.GetCurrentValue();
-        const size_t item_byte_size = m_memory_options.m_byte_size;
+        size_t item_count = m_format_options.GetCountValue().GetCurrentValue();
+        const size_t item_byte_size = m_format_options.GetByteSizeValue().GetCurrentValue();
         const size_t num_per_line = m_memory_options.m_num_per_line.GetCurrentValue();
 
         size_t total_byte_size = item_count * item_byte_size;
@@ -549,7 +536,7 @@
                 result.SetStatus(eReturnStatusFailed);
                 return false;
             }
-            else if (m_memory_options.m_count.OptionWasSet())
+            else if (m_format_options.GetCountValue().OptionWasSet())
             {
                 result.AppendErrorWithFormat("specify either the end address (0x%llx) or the count (--count %lu), not both.\n", end_addr, item_count);
                 result.SetStatus(eReturnStatusFailed);
@@ -708,6 +695,15 @@
 
 };
 
+
+OptionDefinition
+g_memory_write_option_table[] =
+{
+{ LLDB_OPT_SET_1, true,  "infile", 'i', required_argument, NULL, 0, eArgTypeFilename, "Write memory using the contents of a file."},
+{ LLDB_OPT_SET_1, false, "offset", 'o', required_argument, NULL, 0, eArgTypeOffset,   "Start writng bytes from an offset within the input file."},
+};
+
+
 //----------------------------------------------------------------------
 // Write memory to the inferior process
 //----------------------------------------------------------------------
@@ -715,86 +711,75 @@
 {
 public:
 
-    class CommandOptions : public Options
+    class OptionGroupWriteMemory : public OptionGroup
     {
     public:
-        CommandOptions (CommandInterpreter &interpreter) :
-            Options(interpreter)
+        OptionGroupWriteMemory () :
+            OptionGroup()
         {
-            OptionParsingStarting();
         }
 
         virtual
-        ~CommandOptions ()
+        ~OptionGroupWriteMemory ()
         {
         }
 
+        virtual uint32_t
+        GetNumDefinitions ()
+        {
+            return sizeof (g_memory_write_option_table) / sizeof (OptionDefinition);
+        }
+        
+        virtual const OptionDefinition*
+        GetDefinitions ()
+        {
+            return g_memory_write_option_table;
+        }
+        
         virtual Error
-        SetOptionValue (uint32_t option_idx, const char *option_arg)
+        SetOptionValue (CommandInterpreter &interpreter,
+                        uint32_t option_idx,
+                        const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            char short_option = (char) g_memory_write_option_table[option_idx].short_option;
+            
             switch (short_option)
             {
-            case 'f':
-                error = Args::StringToFormat (option_arg, m_format, &m_byte_size);
-                break;
-
-            case 's':
-                m_byte_size = Args::StringToUInt32 (option_arg, 0);
-                if (m_byte_size == 0)
-                    error.SetErrorStringWithFormat("Invalid value for --size option '%s'.  Must be positive integer value.\n", option_arg);
-                break;
-
-            case 'i':
-                m_infile.SetFile (option_arg, true);
-                if (!m_infile.Exists())
-                {
-                    m_infile.Clear();
-                    error.SetErrorStringWithFormat("Input file does not exist: '%s'\n", option_arg);
-                }
-                break;
-            
-            case 'o':
-                {
-                    bool success;
-                    m_infile_offset = Args::StringToUInt64(option_arg, 0, 0, &success);
-                    if (!success)
+                case 'i':
+                    m_infile.SetFile (option_arg, true);
+                    if (!m_infile.Exists())
                     {
-                        error.SetErrorStringWithFormat("Invalid offset string '%s'\n", option_arg);
+                        m_infile.Clear();
+                        error.SetErrorStringWithFormat("Input file does not exist: '%s'\n", option_arg);
                     }
-                }
-                break;
-
-            default:
-                error.SetErrorStringWithFormat("Unrecognized short option '%c'\n", short_option);
-                break;
+                    break;
+                    
+                case 'o':
+                    {
+                        bool success;
+                        m_infile_offset = Args::StringToUInt64(option_arg, 0, 0, &success);
+                        if (!success)
+                        {
+                            error.SetErrorStringWithFormat("Invalid offset string '%s'\n", option_arg);
+                        }
+                    }
+                    break;
+                    
+                default:
+                    error.SetErrorStringWithFormat("Unrecognized short option '%c'.\n", short_option);
+                    break;
             }
             return error;
         }
-
-        void
-        OptionParsingStarting ()
+        
+        virtual void
+        OptionParsingStarting (CommandInterpreter &interpreter)
         {
-            m_format = eFormatBytes;
-            m_byte_size = 1;
             m_infile.Clear();
             m_infile_offset = 0;
         }
 
-        const OptionDefinition*
-        GetDefinitions ()
-        {
-            return g_option_table;
-        }
-
-        // Options table: Required for subclasses of Options.
-
-        static OptionDefinition g_option_table[];
-
-        // Instance variables to hold the values for command options.
-        lldb::Format m_format;
-        uint32_t m_byte_size;
         FileSpec m_infile;
         off_t m_infile_offset;
     };
@@ -806,7 +791,9 @@
                        //"memory write [<cmd-options>] <addr> [value1 value2 ...]",
                        NULL,
                        eFlagProcessMustBeLaunched),
-        m_options (interpreter)
+        m_option_group (interpreter),
+        m_format_options (eFormatBytes, 1, UINT64_MAX),
+        m_memory_options ()
     {
         CommandArgumentEntry arg1;
         CommandArgumentEntry arg2;
@@ -830,6 +817,12 @@
         // Push the data for the first argument into the m_arguments vector.
         m_arguments.push_back (arg1);
         m_arguments.push_back (arg2);
+        
+        m_option_group.Append (&m_format_options, OptionGroupFormat::OPTION_GROUP_FORMAT, LLDB_OPT_SET_1);
+        m_option_group.Append (&m_format_options, OptionGroupFormat::OPTION_GROUP_SIZE  , LLDB_OPT_SET_1|LLDB_OPT_SET_2);
+        m_option_group.Append (&m_memory_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_2);
+        m_option_group.Finalize();
+
     }
 
     virtual
@@ -840,7 +833,7 @@
     Options *
     GetOptions ()
     {
-        return &m_options;
+        return &m_option_group;
     }
 
     bool
@@ -884,7 +877,7 @@
 
         const size_t argc = command.GetArgumentCount();
 
-        if (m_options.m_infile)
+        if (m_memory_options.m_infile)
         {
             if (argc < 1)
             {
@@ -904,7 +897,8 @@
                              process->GetTarget().GetArchitecture().GetAddressByteSize(),
                              process->GetTarget().GetArchitecture().GetByteOrder());
 
-        size_t item_byte_size = m_options.m_byte_size;
+        OptionValueUInt64 &byte_size_value = m_format_options.GetByteSizeValue();
+        size_t item_byte_size = byte_size_value.GetCurrentValue();
 
         lldb::addr_t addr = Args::StringToUInt64(command.GetArgumentAtIndex(0), LLDB_INVALID_ADDRESS, 0);
 
@@ -915,12 +909,12 @@
             return false;
         }
         
-        if (m_options.m_infile)
+        if (m_memory_options.m_infile)
         {
             size_t length = SIZE_MAX;
-            if (m_options.m_byte_size > 0)
-                length = m_options.m_byte_size;
-            lldb::DataBufferSP data_sp (m_options.m_infile.ReadFileContents (m_options.m_infile_offset, length));
+            if (item_byte_size > 0)
+                length = item_byte_size;
+            lldb::DataBufferSP data_sp (m_memory_options.m_infile.ReadFileContents (m_memory_options.m_infile_offset, length));
             if (data_sp)
             {
                 length = data_sp->GetByteSize();
@@ -955,9 +949,9 @@
             }
             return result.Succeeded();
         }
-        else if (m_options.m_byte_size == 0)
+        else if (item_byte_size == 0)
         {
-            if (m_options.m_format == eFormatPointer)
+            if (m_format_options.GetFormat() == eFormatPointer)
                 item_byte_size = buffer.GetAddressByteSize();
             else
                 item_byte_size = 1;
@@ -973,7 +967,7 @@
         {
             const char *value_str = command.GetArgumentAtIndex(i);
 
-            switch (m_options.m_format)
+            switch (m_format_options.GetFormat())
             {
             case kNumFormats:
             case eFormatFloat:  // TODO: add support for floats soon
@@ -1058,7 +1052,7 @@
                 {
                     size_t len = strlen (value_str);
                     // Include the NULL for C strings...
-                    if (m_options.m_format == eFormatCString)
+                    if (m_format_options.GetFormat() == eFormatCString)
                         ++len;
                     Error error;
                     if (process->WriteMemory (addr, value_str, len, error) == len)
@@ -1143,24 +1137,12 @@
     }
 
 protected:
-    CommandOptions m_options;
-};
-
-#define SET1 LLDB_OPT_SET_1
-#define SET2 LLDB_OPT_SET_2
-
-OptionDefinition
-CommandObjectMemoryWrite::CommandOptions::g_option_table[] =
-{
-{ SET1       , false, "format", 'f', required_argument, NULL, 0, eArgTypeFormat,   "The format value types that will be decoded and written to memory."},
-{ SET1 | SET2, false, "size",   's', required_argument, NULL, 0, eArgTypeByteSize, "The size in bytes of the values to write to memory."},
-{        SET2, true,  "infile", 'i', required_argument, NULL, 0, eArgTypeFilename, "Write memory using the contents of a file."},
-{        SET2, false, "offset", 'o', required_argument, NULL, 0, eArgTypeOffset,   "Start writng bytes from an offset within the input file."},
-{ 0          , false, NULL    ,  0 , 0                , NULL, 0, eArgTypeNone,     NULL }
+    
+    OptionGroupOptions m_option_group;
+    OptionGroupFormat m_format_options;
+    OptionGroupWriteMemory m_memory_options;
 };
 
-#undef SET1
-#undef SET2
 
 //-------------------------------------------------------------------------
 // CommandObjectMemory

Modified: lldb/trunk/source/Commands/CommandObjectRegister.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectRegister.cpp?rev=142911&r1=142910&r2=142911&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectRegister.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectRegister.cpp Tue Oct 25 01:44:01 2011
@@ -22,6 +22,7 @@
 #include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Interpreter/NamedOptionValue.h"
 #include "lldb/Interpreter/Options.h"
+#include "lldb/Interpreter/OptionGroupFormat.h"
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
@@ -43,7 +44,9 @@
                        //"register read [<reg-name1> [<reg-name2> [...]]]",
                        NULL,
                        eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
-        m_options (interpreter)
+        m_option_group (interpreter),
+        m_format_options (eFormatDefault),
+        m_command_options ()
     {
         CommandArgumentEntry arg;
         CommandArgumentData register_arg;
@@ -57,6 +60,12 @@
         
         // Push the data for the first argument into the m_arguments vector.
         m_arguments.push_back (arg);
+
+        // Add the "--format"
+        m_option_group.Append (&m_format_options, OptionGroupFormat::OPTION_GROUP_FORMAT, LLDB_OPT_SET_ALL);
+        m_option_group.Append (&m_command_options);
+        m_option_group.Finalize();
+
     }
 
     virtual
@@ -67,7 +76,7 @@
     Options *
     GetOptions ()
     {
-        return &m_options;
+        return &m_option_group;
     }
 
     bool
@@ -83,15 +92,10 @@
             if (reg_ctx->ReadRegister (reg_info, reg_value))
             {
                 strm.Indent ();
-                Format format;
-                if (m_options.format == eFormatDefault)
-                    format = reg_info->format;
-                else
-                    format = m_options.format;
 
-                bool prefix_with_altname = m_options.alternate_name;
+                bool prefix_with_altname = m_command_options.alternate_name;
                 bool prefix_with_name = !prefix_with_altname;
-                reg_value.Dump(&strm, reg_info, prefix_with_name, prefix_with_altname, m_options.format);
+                reg_value.Dump(&strm, reg_info, prefix_with_name, prefix_with_altname, m_format_options.GetFormat());
                 if (((reg_info->encoding == eEncodingUint) || (reg_info->encoding == eEncodingSint)) && 
                     (reg_info->byte_size == reg_ctx->GetThread().GetProcess().GetAddressByteSize()))
                 {
@@ -165,12 +169,12 @@
                 uint32_t set_idx;
                 
                 uint32_t num_register_sets = 1;
-                const uint32_t set_array_size = m_options.set_indexes.GetSize();
+                const uint32_t set_array_size = m_command_options.set_indexes.GetSize();
                 if (set_array_size > 0)
                 {
                     for (uint32_t i=0; i<set_array_size; ++i)
                     {
-                        set_idx = m_options.set_indexes[i]->GetUInt64Value (UINT32_MAX, NULL);
+                        set_idx = m_command_options.set_indexes[i]->GetUInt64Value (UINT32_MAX, NULL);
                         if (set_idx != UINT32_MAX)
                         {
                             if (!DumpRegisterSet (exe_ctx, strm, reg_ctx, set_idx))
@@ -190,7 +194,7 @@
                 }
                 else
                 {
-                    if (m_options.dump_all_sets)
+                    if (m_command_options.dump_all_sets)
                         num_register_sets = reg_ctx->GetRegisterSetCount();
 
                     for (set_idx = 0; set_idx < num_register_sets; ++set_idx)
@@ -201,12 +205,12 @@
             }
             else
             {
-                if (m_options.dump_all_sets)
+                if (m_command_options.dump_all_sets)
                 {
                     result.AppendError ("the --all option can't be used when registers names are supplied as arguments\n");
                     result.SetStatus (eReturnStatusFailed);
                 }
-                else if (m_options.set_indexes.GetSize() > 0)
+                else if (m_command_options.set_indexes.GetSize() > 0)
                 {
                     result.AppendError ("the --set <set> option can't be used when registers names are supplied as arguments\n");
                     result.SetStatus (eReturnStatusFailed);
@@ -239,17 +243,15 @@
         return result.Succeeded();
     }
 
-protected:
-    class CommandOptions : public Options
+    class CommandOptions : public OptionGroup
     {
     public:
-        CommandOptions (CommandInterpreter &interpreter) :
-            Options(interpreter),
+        CommandOptions () :
+            OptionGroup(),
             set_indexes (OptionValue::ConvertTypeToMask (OptionValue::eTypeUInt64)),
             dump_all_sets (false, false), // Initial and default values are false
             alternate_name (false, false)
         {
-            OptionParsingStarting();
         }
         
         virtual
@@ -257,20 +259,36 @@
         {
         }
         
+        
+        virtual uint32_t
+        GetNumDefinitions ();
+
+        virtual const OptionDefinition*
+        GetDefinitions ()
+        {
+            return g_option_table;
+        }
+        
+        virtual void
+        OptionParsingStarting (CommandInterpreter &interpreter)
+        {
+            set_indexes.Clear();
+            dump_all_sets.Clear();
+            alternate_name.Clear();
+        }
+
         virtual Error
-        SetOptionValue (uint32_t option_idx, const char *option_arg)
+        SetOptionValue (CommandInterpreter &interpreter,
+                        uint32_t option_idx,
+                        const char *option_value)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const char short_option = (char) g_option_table[option_idx].short_option;
             switch (short_option)
             {
-                case 'f':
-                    error = Args::StringToFormat (option_arg, format, NULL);
-                    break;
-
                 case 's':
                     {
-                        OptionValueSP value_sp (OptionValueUInt64::Create (option_arg, error));
+                        OptionValueSP value_sp (OptionValueUInt64::Create (option_value, error));
                         if (value_sp)
                             set_indexes.AppendValue (value_sp);
                     }
@@ -299,45 +317,34 @@
             return error;
         }
         
-        void
-        OptionParsingStarting ()
-        {
-            format = eFormatDefault;
-            set_indexes.Clear();
-            dump_all_sets.Clear();
-            alternate_name.Clear();
-        }
-        
-        const OptionDefinition*
-        GetDefinitions ()
-        {
-            return g_option_table;
-        }
-        
         // Options table: Required for subclasses of Options.
         
-        static OptionDefinition g_option_table[];
+        static const OptionDefinition g_option_table[];
         
         // Instance variables to hold the values for command options.
-        lldb::Format format;
         OptionValueArray set_indexes;
         OptionValueBoolean dump_all_sets;
         OptionValueBoolean alternate_name;
     };
 
-    CommandOptions m_options;
+    OptionGroupOptions m_option_group;
+    OptionGroupFormat m_format_options;
+    CommandOptions m_command_options;
 };
 
 OptionDefinition
 CommandObjectRegisterRead::CommandOptions::g_option_table[] =
 {
-    { LLDB_OPT_SET_ALL, false, "format"   , 'f', required_argument, NULL, 0, eArgTypeExprFormat, "Specify the format to use when dumping register values."},
     { LLDB_OPT_SET_ALL, false, "alternate", 'A', no_argument      , NULL, 0, eArgTypeNone      , "Display register names using the alternate register name if there is one."},
     { LLDB_OPT_SET_1  , false, "set"      , 's', required_argument, NULL, 0, eArgTypeIndex     , "Specify which register sets to dump by index."},
     { LLDB_OPT_SET_2  , false, "all"      , 'a', no_argument      , NULL, 0, eArgTypeNone      , "Show all register sets."},
-    { 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL }
 };
 
+uint32_t
+CommandObjectRegisterRead::CommandOptions::GetNumDefinitions ()
+{
+    return sizeof(g_option_table)/sizeof(OptionDefinition);
+}
 
 
 //----------------------------------------------------------------------
@@ -350,7 +357,6 @@
         CommandObject (interpreter,
                        "register write",
                        "Modify a single register value.",
-                       //"register write <reg-name> <value>",
                        NULL,
                        eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
     {

Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=142911&r1=142910&r2=142911&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Tue Oct 25 01:44:01 2011
@@ -28,6 +28,7 @@
 #include "lldb/Interpreter/OptionGroupArchitecture.h"
 #include "lldb/Interpreter/OptionGroupBoolean.h"
 #include "lldb/Interpreter/OptionGroupFile.h"
+#include "lldb/Interpreter/OptionGroupFormat.h"
 #include "lldb/Interpreter/OptionGroupVariable.h"
 #include "lldb/Interpreter/OptionGroupPlatform.h"
 #include "lldb/Interpreter/OptionGroupUInt64.h"
@@ -504,6 +505,7 @@
                        0),
         m_option_group (interpreter),
         m_option_variable (false), // Don't include frame options
+        m_option_format (eFormatDefault),
         m_option_compile_units    (LLDB_OPT_SET_1, false, "file", 'f', 0, eArgTypePath, "A basename or fullpath to a file that contains global variables. This option can be specified multiple times."),
         m_option_shared_libraries (LLDB_OPT_SET_1, false, "shlib",'s', 0, eArgTypePath, "A basename or fullpath to a shared library to use in the search for global variables. This option can be specified multiple times."),
         m_varobj_options()
@@ -523,6 +525,7 @@
         
         m_option_group.Append (&m_varobj_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
         m_option_group.Append (&m_option_variable, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
+        m_option_group.Append (&m_option_format, OptionGroupFormat::OPTION_GROUP_FORMAT, LLDB_OPT_SET_1);
         m_option_group.Append (&m_option_compile_units, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);   
         m_option_group.Append (&m_option_shared_libraries, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);   
         m_option_group.Finalize();
@@ -549,9 +552,6 @@
                .SetOmitSummaryDepth(m_varobj_options.no_summary_depth)
                .SetIgnoreCap(m_varobj_options.ignore_cap);
                 
-        if (m_option_variable.format != eFormatDefault)
-            valobj_sp->SetFormat (m_option_variable.format);
-        
         switch (var_sp->GetScope())
         {
             case eValueTypeVariableGlobal:
@@ -586,7 +586,7 @@
                 s.PutCString (": ");
         }
         
-        const Format format = m_option_variable.format;
+        const Format format = m_option_format.GetFormat();
         if (format != eFormatDefault)
             valobj_sp->SetFormat (format);
         
@@ -765,6 +765,7 @@
 protected:
     OptionGroupOptions m_option_group;
     OptionGroupVariable m_option_variable;
+    OptionGroupFormat m_option_format;
     OptionGroupFileList m_option_compile_units;
     OptionGroupFileList m_option_shared_libraries;
     OptionGroupValueObjectDisplay m_varobj_options;

Modified: lldb/trunk/source/Commands/CommandObjectType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=142911&r1=142910&r2=142911&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectType.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectType.cpp Tue Oct 25 01:44:01 2011
@@ -26,15 +26,189 @@
 #include "lldb/Interpreter/CommandObject.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Interpreter/Options.h"
+#include "lldb/Interpreter/OptionGroupFormat.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
-//-------------------------------------------------------------------------
-// CommandObjectTypeFormatAdd
-//-------------------------------------------------------------------------
 
-class CommandObjectTypeFormatAdd : public CommandObject
+class ScriptAddOptions
+{
+    
+public:
+    
+    bool m_skip_pointers;
+    bool m_skip_references;
+    bool m_cascade;
+    StringList m_target_types;
+    StringList m_user_source;
+    
+    bool m_no_children;
+    bool m_no_value;
+    bool m_one_liner;
+    bool m_regex;
+    
+    ConstString* m_name;
+    
+    std::string m_category;
+    
+    ScriptAddOptions(bool sptr,
+                     bool sref,
+                     bool casc,
+                     bool noch,
+                     bool novl,
+                     bool onel,
+                     bool regx,
+                     ConstString* name,
+                     std::string catg) :
+    m_skip_pointers(sptr),
+    m_skip_references(sref),
+    m_cascade(casc),
+    m_target_types(),
+    m_user_source(),
+    m_no_children(noch),
+    m_no_value(novl),
+    m_one_liner(onel),
+    m_regex(regx),
+    m_name(name),
+    m_category(catg)
+    {
+    }
+    
+    typedef lldb::SharedPtr<ScriptAddOptions>::Type SharedPointer;
+    
+};
+
+class SynthAddOptions
+{
+    
+public:
+    
+    bool m_skip_pointers;
+    bool m_skip_references;
+    bool m_cascade;
+    bool m_regex;
+    StringList m_user_source;
+    StringList m_target_types;
+    
+    std::string m_category;
+    
+    SynthAddOptions(bool sptr,
+                    bool sref,
+                    bool casc,
+                    bool regx,
+                    std::string catg) :
+    m_skip_pointers(sptr),
+    m_skip_references(sref),
+    m_cascade(casc),
+    m_regex(regx),
+    m_user_source(),
+    m_target_types(),
+    m_category(catg)
+    {
+    }
+    
+    typedef lldb::SharedPtr<SynthAddOptions>::Type SharedPointer;
+    
+};
+
+
+
+class CommandObjectTypeSummaryAdd : public CommandObject
+{
+    
+private:
+    
+    class CommandOptions : public Options
+    {
+    public:
+        
+        CommandOptions (CommandInterpreter &interpreter) :
+        Options (interpreter)
+        {
+        }
+        
+        virtual
+        ~CommandOptions (){}
+        
+        virtual Error
+        SetOptionValue (uint32_t option_idx, const char *option_arg);
+        
+        void
+        OptionParsingStarting ();
+        
+        const OptionDefinition*
+        GetDefinitions ()
+        {
+            return g_option_table;
+        }
+        
+        // Options table: Required for subclasses of Options.
+        
+        static OptionDefinition g_option_table[];
+        
+        // Instance variables to hold the values for command options.
+        
+        bool m_cascade;
+        bool m_no_children;
+        bool m_no_value;
+        bool m_one_liner;
+        bool m_skip_references;
+        bool m_skip_pointers;
+        bool m_regex;
+        std::string m_format_string;
+        ConstString* m_name;
+        std::string m_python_script;
+        std::string m_python_function;
+        bool m_is_add_script;
+        std::string m_category;
+    };
+    
+    CommandOptions m_options;
+    
+    virtual Options *
+    GetOptions ()
+    {
+        return &m_options;
+    }
+    
+    void
+    CollectPythonScript(ScriptAddOptions *options,
+                        CommandReturnObject &result);
+    
+    bool
+    Execute_ScriptSummary (Args& command, CommandReturnObject &result);
+    
+    bool
+    Execute_StringSummary (Args& command, CommandReturnObject &result);
+    
+public:
+    
+    enum SummaryFormatType
+    {
+        eRegularSummary,
+        eRegexSummary,
+        eNamedSummary
+    };
+    
+    CommandObjectTypeSummaryAdd (CommandInterpreter &interpreter);
+    
+    ~CommandObjectTypeSummaryAdd ()
+    {
+    }
+    
+    bool
+    Execute (Args& command, CommandReturnObject &result);
+    
+    static bool
+    AddSummary(const ConstString& type_name,
+               lldb::SummaryFormatSP entry,
+               SummaryFormatType type,
+               std::string category,
+               Error* error = NULL);
+};
+
+class CommandObjectTypeSynthAdd : public CommandObject
 {
     
 private:
@@ -65,8 +239,12 @@
                     if (!success)
                         error.SetErrorStringWithFormat("Invalid value for cascade: %s.\n", option_arg);
                     break;
-                case 'f':
-                    error = Args::StringToFormat(option_arg, m_format, NULL);
+                case 'P':
+                    handwrite_python = true;
+                    break;
+                case 'l':
+                    m_class_name = std::string(option_arg);
+                    is_class_based = true;
                     break;
                 case 'p':
                     m_skip_pointers = true;
@@ -74,6 +252,12 @@
                 case 'r':
                     m_skip_references = true;
                     break;
+                case 'w':
+                    m_category = std::string(option_arg);
+                    break;
+                case 'x':
+                    m_regex = true;
+                    break;
                 default:
                     error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option);
                     break;
@@ -86,9 +270,13 @@
         OptionParsingStarting ()
         {
             m_cascade = true;
-            m_format = eFormatInvalid;
+            m_class_name = "";
             m_skip_pointers = false;
             m_skip_references = false;
+            m_category = "default";
+            is_class_based = false;
+            handwrite_python = false;
+            m_regex = false;
         }
         
         const OptionDefinition*
@@ -104,9 +292,18 @@
         // Instance variables to hold the values for command options.
         
         bool m_cascade;
-        lldb::Format m_format;
         bool m_skip_references;
         bool m_skip_pointers;
+        std::string m_class_name;
+        bool m_input_python;
+        std::string m_category;
+        
+        bool is_class_based;
+        
+        bool handwrite_python;
+        
+        bool m_regex;
+        
     };
     
     CommandOptions m_options;
@@ -117,12 +314,139 @@
         return &m_options;
     }
     
+    void
+    CollectPythonScript (SynthAddOptions *options,
+                         CommandReturnObject &result);    
+    bool
+    Execute_HandwritePython (Args& command, CommandReturnObject &result);    
+    
+    bool
+    Execute_PythonClass (Args& command, CommandReturnObject &result);
+    
+    bool
+    Execute (Args& command, CommandReturnObject &result);
+    
+public:
+    
+    enum SynthFormatType
+    {
+        eRegularSynth,
+        eRegexSynth
+    };
+    
+    CommandObjectTypeSynthAdd (CommandInterpreter &interpreter);
+    
+    ~CommandObjectTypeSynthAdd ()
+    {
+    }
+    
+    static bool
+    AddSynth(const ConstString& type_name,
+             lldb::SyntheticChildrenSP entry,
+             SynthFormatType type,
+             std::string category_name,
+             Error* error);
+};
+
+//-------------------------------------------------------------------------
+// CommandObjectTypeFormatAdd
+//-------------------------------------------------------------------------
+
+class CommandObjectTypeFormatAdd : public CommandObject
+{
+    
+private:
+    
+    class CommandOptions : public OptionGroup
+    {
+    public:
+        
+        CommandOptions () :
+            OptionGroup()
+        {
+        }
+        
+        virtual
+        ~CommandOptions ()
+        {
+        }
+        
+        virtual uint32_t
+        GetNumDefinitions ();
+        
+        virtual const OptionDefinition*
+        GetDefinitions ()
+        {
+            return g_option_table;
+        }
+        
+        virtual void
+        OptionParsingStarting (CommandInterpreter &interpreter)
+        {
+            m_cascade = true;
+            m_skip_pointers = false;
+            m_skip_references = false;
+        }
+        virtual Error
+        SetOptionValue (CommandInterpreter &interpreter,
+                        uint32_t option_idx,
+                        const char *option_value)
+        {
+            Error error;
+            const char short_option = (char) g_option_table[option_idx].short_option;
+            bool success;
+            
+            switch (short_option)
+            {
+                case 'C':
+                    m_cascade = Args::StringToBoolean(option_value, true, &success);
+                    if (!success)
+                        error.SetErrorStringWithFormat("Invalid value for cascade: %s.\n", option_value);
+                    break;
+                case 'p':
+                    m_skip_pointers = true;
+                    break;
+                case 'r':
+                    m_skip_references = true;
+                    break;
+                default:
+                    error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option);
+                    break;
+            }
+            
+            return error;
+        }
+        
+        // Options table: Required for subclasses of Options.
+        
+        static OptionDefinition g_option_table[];
+        
+        // Instance variables to hold the values for command options.
+        
+        bool m_cascade;
+        bool m_skip_references;
+        bool m_skip_pointers;
+    };
+    
+    OptionGroupOptions m_option_group;
+    OptionGroupFormat m_format_options;
+    CommandOptions m_command_options;
+    
+    virtual Options *
+    GetOptions ()
+    {
+        return &m_option_group;
+    }
+    
 public:
     CommandObjectTypeFormatAdd (CommandInterpreter &interpreter) :
     CommandObject (interpreter,
                    "type format add",
                    "Add a new formatting style for a type.",
-                   NULL), m_options (interpreter)
+                   NULL), 
+        m_option_group (interpreter),
+        m_format_options (eFormatInvalid),
+        m_command_options ()
     {
         CommandArgumentEntry type_arg;
         CommandArgumentData type_style_arg;
@@ -161,6 +485,12 @@
                     "which now prints all floats and float&s as hexadecimal, but does not format float*s\n"
                     "and does not change the default display for Afloat and Bfloat objects.\n"
                     );
+    
+        // Add the "--format" to all options groups
+        m_option_group.Append (&m_format_options, OptionGroupFormat::OPTION_GROUP_FORMAT, LLDB_OPT_SET_ALL);
+        m_option_group.Append (&m_command_options);
+        m_option_group.Finalize();
+
     }
     
     ~CommandObjectTypeFormatAdd ()
@@ -179,7 +509,8 @@
             return false;
         }
         
-        if (m_options.m_format == eFormatInvalid)
+        const Format format = m_format_options.GetFormat();
+        if (format == eFormatInvalid)
         {
             result.AppendErrorWithFormat ("%s needs a valid format.\n", m_cmd_name.c_str());
             result.SetStatus(eReturnStatusFailed);
@@ -188,10 +519,10 @@
         
         ValueFormatSP entry;
         
-        entry.reset(new ValueFormat(m_options.m_format,
-                                    m_options.m_cascade,
-                                    m_options.m_skip_pointers,
-                                    m_options.m_skip_references));
+        entry.reset(new ValueFormat(format,
+                                    m_command_options.m_cascade,
+                                    m_command_options.m_skip_pointers,
+                                    m_command_options.m_skip_references));
 
         // now I have a valid format, let's add it to every type
         
@@ -218,13 +549,18 @@
 CommandObjectTypeFormatAdd::CommandOptions::g_option_table[] =
 {
     { LLDB_OPT_SET_ALL, false, "cascade", 'C', required_argument, NULL, 0, eArgTypeBoolean,    "If true, cascade to derived typedefs."},
-    { LLDB_OPT_SET_ALL, false, "format", 'f', required_argument, NULL, 0, eArgTypeFormat,    "The format to use to display this type."},
     { LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', no_argument, NULL, 0, eArgTypeNone,         "Don't use this format for pointers-to-type objects."},
     { LLDB_OPT_SET_ALL, false, "skip-references", 'r', no_argument, NULL, 0, eArgTypeNone,         "Don't use this format for references-to-type objects."},
-    { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
 };
 
 
+uint32_t
+CommandObjectTypeFormatAdd::CommandOptions::GetNumDefinitions ()
+{
+    return sizeof(g_option_table) / sizeof (OptionDefinition);
+}
+
+
 //-------------------------------------------------------------------------
 // CommandObjectTypeFormatDelete
 //-------------------------------------------------------------------------

Modified: lldb/trunk/source/Commands/CommandObjectType.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.h?rev=142911&r1=142910&r2=142911&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectType.h (original)
+++ lldb/trunk/source/Commands/CommandObjectType.h Tue Oct 25 01:44:01 2011
@@ -23,87 +23,6 @@
 
 namespace lldb_private {
 
-class ScriptAddOptions
-{
-    
-public:
-    
-    bool m_skip_pointers;
-    bool m_skip_references;
-    bool m_cascade;
-    StringList m_target_types;
-    StringList m_user_source;
-    
-    bool m_no_children;
-    bool m_no_value;
-    bool m_one_liner;
-    bool m_regex;
-    
-    ConstString* m_name;
-    
-    std::string m_category;
-    
-    ScriptAddOptions(bool sptr,
-                     bool sref,
-                     bool casc,
-                     bool noch,
-                     bool novl,
-                     bool onel,
-                     bool regx,
-                     ConstString* name,
-                     std::string catg) :
-    m_skip_pointers(sptr),
-    m_skip_references(sref),
-    m_cascade(casc),
-    m_target_types(),
-    m_user_source(),
-    m_no_children(noch),
-    m_no_value(novl),
-    m_one_liner(onel),
-    m_regex(regx),
-    m_name(name),
-    m_category(catg)
-    {
-    }
-    
-    typedef lldb::SharedPtr<ScriptAddOptions>::Type SharedPointer;
-    
-};
-    
-class SynthAddOptions
-{
-    
-public:
-    
-    bool m_skip_pointers;
-    bool m_skip_references;
-    bool m_cascade;
-    bool m_regex;
-    StringList m_user_source;
-    StringList m_target_types;
-
-    std::string m_category;
-    
-    SynthAddOptions(bool sptr,
-                     bool sref,
-                     bool casc,
-                     bool regx,
-                     std::string catg) :
-    m_skip_pointers(sptr),
-    m_skip_references(sref),
-    m_cascade(casc),
-    m_regex(regx),
-    m_user_source(),
-    m_target_types(),
-    m_category(catg)
-    {
-    }
-    
-    typedef lldb::SharedPtr<SynthAddOptions>::Type SharedPointer;
-    
-};
-
-    
 class CommandObjectType : public CommandObjectMultiword
 {
 public:
@@ -113,239 +32,6 @@
     ~CommandObjectType ();
 };
 
-class CommandObjectTypeSummaryAdd : public CommandObject
-{
-    
-private:
-    
-    class CommandOptions : public Options
-    {
-    public:
-        
-        CommandOptions (CommandInterpreter &interpreter) :
-        Options (interpreter)
-        {
-        }
-        
-        virtual
-        ~CommandOptions (){}
-        
-        virtual Error
-        SetOptionValue (uint32_t option_idx, const char *option_arg);
-        
-        void
-        OptionParsingStarting ();
-        
-        const OptionDefinition*
-        GetDefinitions ()
-        {
-            return g_option_table;
-        }
-        
-        // Options table: Required for subclasses of Options.
-        
-        static OptionDefinition g_option_table[];
-        
-        // Instance variables to hold the values for command options.
-        
-        bool m_cascade;
-        bool m_no_children;
-        bool m_no_value;
-        bool m_one_liner;
-        bool m_skip_references;
-        bool m_skip_pointers;
-        bool m_regex;
-        std::string m_format_string;
-        ConstString* m_name;
-        std::string m_python_script;
-        std::string m_python_function;
-        bool m_is_add_script;
-        std::string m_category;
-    };
-    
-    CommandOptions m_options;
-    
-    virtual Options *
-    GetOptions ()
-    {
-        return &m_options;
-    }
-    
-    void
-    CollectPythonScript(ScriptAddOptions *options,
-                        CommandReturnObject &result);
-    
-    bool
-    Execute_ScriptSummary (Args& command, CommandReturnObject &result);
-
-    bool
-    Execute_StringSummary (Args& command, CommandReturnObject &result);
-    
-public:
-    
-    enum SummaryFormatType
-    {
-        eRegularSummary,
-        eRegexSummary,
-        eNamedSummary
-    };
-
-    CommandObjectTypeSummaryAdd (CommandInterpreter &interpreter);
-    
-    ~CommandObjectTypeSummaryAdd ()
-    {
-    }
-    
-    bool
-    Execute (Args& command, CommandReturnObject &result);
-    
-    static bool
-    AddSummary(const ConstString& type_name,
-               lldb::SummaryFormatSP entry,
-               SummaryFormatType type,
-               std::string category,
-               Error* error = NULL);
-};
-    
-class CommandObjectTypeSynthAdd : public CommandObject
-{
-    
-private:
-    
-    class CommandOptions : public Options
-    {
-    public:
-        
-        CommandOptions (CommandInterpreter &interpreter) :
-        Options (interpreter)
-        {
-        }
-        
-        virtual
-        ~CommandOptions (){}
-        
-        virtual Error
-        SetOptionValue (uint32_t option_idx, const char *option_arg)
-        {
-            Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
-            bool success;
-            
-            switch (short_option)
-            {
-                case 'C':
-                    m_cascade = Args::StringToBoolean(option_arg, true, &success);
-                    if (!success)
-                        error.SetErrorStringWithFormat("Invalid value for cascade: %s.\n", option_arg);
-                    break;
-                case 'P':
-                    handwrite_python = true;
-                    break;
-                case 'l':
-                    m_class_name = std::string(option_arg);
-                    is_class_based = true;
-                    break;
-                case 'p':
-                    m_skip_pointers = true;
-                    break;
-                case 'r':
-                    m_skip_references = true;
-                    break;
-                case 'w':
-                    m_category = std::string(option_arg);
-                    break;
-                case 'x':
-                    m_regex = true;
-                    break;
-                default:
-                    error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option);
-                    break;
-            }
-            
-            return error;
-        }
-        
-        void
-        OptionParsingStarting ()
-        {
-            m_cascade = true;
-            m_class_name = "";
-            m_skip_pointers = false;
-            m_skip_references = false;
-            m_category = "default";
-            is_class_based = false;
-            handwrite_python = false;
-            m_regex = false;
-        }
-        
-        const OptionDefinition*
-        GetDefinitions ()
-        {
-            return g_option_table;
-        }
-        
-        // Options table: Required for subclasses of Options.
-        
-        static OptionDefinition g_option_table[];
-        
-        // Instance variables to hold the values for command options.
-        
-        bool m_cascade;
-        bool m_skip_references;
-        bool m_skip_pointers;
-        std::string m_class_name;
-        bool m_input_python;
-        std::string m_category;
-        
-        bool is_class_based;
-        
-        bool handwrite_python;
-                
-        bool m_regex;
-        
-    };
-    
-    CommandOptions m_options;
-    
-    virtual Options *
-    GetOptions ()
-    {
-        return &m_options;
-    }
-    
-    void
-    CollectPythonScript (SynthAddOptions *options,
-                         CommandReturnObject &result);    
-    bool
-    Execute_HandwritePython (Args& command, CommandReturnObject &result);    
-
-    bool
-    Execute_PythonClass (Args& command, CommandReturnObject &result);
-    
-    bool
-    Execute (Args& command, CommandReturnObject &result);
-    
-public:
-    
-    enum SynthFormatType
-    {
-        eRegularSynth,
-        eRegexSynth
-    };
-    
-    CommandObjectTypeSynthAdd (CommandInterpreter &interpreter);
-    
-    ~CommandObjectTypeSynthAdd ()
-    {
-    }
-    
-    static bool
-    AddSynth(const ConstString& type_name,
-             lldb::SyntheticChildrenSP entry,
-             SynthFormatType type,
-             std::string category_name,
-             Error* error);
-};
 
 } // namespace lldb_private
 

Modified: lldb/trunk/source/Interpreter/NamedOptionValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/NamedOptionValue.cpp?rev=142911&r1=142910&r2=142911&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/NamedOptionValue.cpp (original)
+++ lldb/trunk/source/Interpreter/NamedOptionValue.cpp Tue Oct 25 01:44:01 2011
@@ -368,14 +368,11 @@
 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;
 }

Modified: lldb/trunk/source/Interpreter/OptionGroupFormat.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupFormat.cpp?rev=142911&r1=142910&r2=142911&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionGroupFormat.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionGroupFormat.cpp Tue Oct 25 01:44:01 2011
@@ -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 @@
 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 @@
             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 @@
 OptionGroupFormat::OptionParsingStarting (CommandInterpreter &interpreter)
 {
     m_format.Clear();
+    m_byte_size.Clear();
+    m_count.Clear();
 }
-

Modified: lldb/trunk/source/Interpreter/OptionGroupVariable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupVariable.cpp?rev=142911&r1=142910&r2=142911&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionGroupVariable.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionGroupVariable.cpp Tue Oct 25 01:44:01 2011
@@ -28,7 +28,6 @@
     { 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 @@
         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 @@
     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       = "";





More information about the lldb-commits mailing list