[Lldb-commits] [lldb] r192217 - <rdar://problem/11778815>

Enrico Granata egranata at apple.com
Tue Oct 8 12:03:23 PDT 2013


Author: enrico
Date: Tue Oct  8 14:03:22 2013
New Revision: 192217

URL: http://llvm.org/viewvc/llvm-project?rev=192217&view=rev
Log:
<rdar://problem/11778815>

Formats (as in "type format") are now included in categories
The only bit missing is caching formats along with synthetic children and summaries, which might be now desirable


Modified:
    lldb/trunk/include/lldb/DataFormatters/DataVisualization.h
    lldb/trunk/include/lldb/DataFormatters/FormatManager.h
    lldb/trunk/include/lldb/DataFormatters/TypeCategory.h
    lldb/trunk/include/lldb/DataFormatters/TypeCategoryMap.h
    lldb/trunk/include/lldb/lldb-private-enumerations.h
    lldb/trunk/source/API/SBTypeCategory.cpp
    lldb/trunk/source/Commands/CommandObjectType.cpp
    lldb/trunk/source/Core/ValueObject.cpp
    lldb/trunk/source/DataFormatters/DataVisualization.cpp
    lldb/trunk/source/DataFormatters/FormatManager.cpp
    lldb/trunk/source/DataFormatters/TypeCategory.cpp
    lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp
    lldb/trunk/source/DataFormatters/TypeFormat.cpp

Modified: lldb/trunk/include/lldb/DataFormatters/DataVisualization.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/DataVisualization.h?rev=192217&r1=192216&r2=192217&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/DataVisualization.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/DataVisualization.h Tue Oct  8 14:03:22 2013
@@ -39,40 +39,16 @@ public:
     static bool
     ShouldPrintAsOneLiner (ValueObject& valobj);
     
-    class ValueFormats
-    {
-    public:
-        static lldb::TypeFormatImplSP
-        GetFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic);
-        
-        static lldb::TypeFormatImplSP
-        GetFormat (const ConstString &type);
-        
-        static void
-        Add (const ConstString &type, const lldb::TypeFormatImplSP &entry);
-        
-        static bool
-        Delete (const ConstString &type);
-        
-        static void
-        Clear ();
-        
-        static void
-        LoopThrough (TypeFormatImpl::ValueCallback callback, void* callback_baton);
-        
-        static size_t
-        GetCount ();
-        
-        static lldb::TypeNameSpecifierImplSP
-        GetTypeNameSpecifierForFormatAtIndex (size_t);
-        
-        static lldb::TypeFormatImplSP
-        GetFormatAtIndex (size_t);
-    };
+    static lldb::TypeFormatImplSP
+    GetFormat (ValueObject& valobj,
+               lldb::DynamicValueType use_dynamic);
+    
+    static lldb::TypeFormatImplSP
+    GetFormatForType (lldb::TypeNameSpecifierImplSP type_sp);
     
     static lldb::TypeSummaryImplSP
-    GetSummaryFormat(ValueObject& valobj,
-                     lldb::DynamicValueType use_dynamic);
+    GetSummaryFormat (ValueObject& valobj,
+                      lldb::DynamicValueType use_dynamic);
 
     static lldb::TypeSummaryImplSP
     GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp);

Modified: lldb/trunk/include/lldb/DataFormatters/FormatManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormatManager.h?rev=192217&r1=192216&r2=192217&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/FormatManager.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/FormatManager.h Tue Oct  8 14:03:22 2013
@@ -34,8 +34,6 @@ namespace lldb_private {
 
 class FormatManager : public IFormatChangeListener
 {
-    typedef FormatNavigator<ConstString, TypeFormatImpl> ValueNavigator;
-    typedef ValueNavigator::MapType ValueMap;
     typedef FormatMap<ConstString, TypeSummaryImpl> NamedSummariesMap;
     typedef TypeCategoryMap::MapType::iterator CategoryMapIterator;
 public:
@@ -44,12 +42,6 @@ public:
     
     FormatManager ();
     
-    ValueNavigator&
-    GetValueNavigator ()
-    {
-        return m_value_nav;
-    }
-    
     NamedSummariesMap&
     GetNamedSummaryNavigator ()
     {
@@ -126,6 +118,9 @@ public:
     lldb::TypeCategoryImplSP
     GetCategory (const ConstString& category_name,
                  bool can_create = true);
+
+    lldb::TypeFormatImplSP
+    GetFormatForType (lldb::TypeNameSpecifierImplSP type_sp);
     
     lldb::TypeSummaryImplSP
     GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp);
@@ -143,6 +138,10 @@ public:
     GetSyntheticChildrenForType (lldb::TypeNameSpecifierImplSP type_sp);
 #endif
     
+    lldb::TypeFormatImplSP
+    GetFormat (ValueObject& valobj,
+               lldb::DynamicValueType use_dynamic);
+    
     lldb::TypeSummaryImplSP
     GetSummaryFormat (ValueObject& valobj,
                       lldb::DynamicValueType use_dynamic);
@@ -216,7 +215,6 @@ public:
     
 private:
     FormatCache m_format_cache;
-    ValueNavigator m_value_nav;
     NamedSummariesMap m_named_summaries_map;
     uint32_t m_last_revision;
     TypeCategoryMap m_categories_map;

Modified: lldb/trunk/include/lldb/DataFormatters/TypeCategory.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/TypeCategory.h?rev=192217&r1=192216&r2=192217&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/TypeCategory.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/TypeCategory.h Tue Oct  8 14:03:22 2013
@@ -24,6 +24,8 @@ namespace lldb_private {
     class TypeCategoryImpl
     {
     private:
+        typedef FormatNavigator<ConstString, TypeFormatImpl> ValueNavigator;
+        typedef FormatNavigator<lldb::RegularExpressionSP, TypeFormatImpl> RegexValueNavigator;
         
         typedef FormatNavigator<ConstString, TypeSummaryImpl> SummaryNavigator;
         typedef FormatNavigator<lldb::RegularExpressionSP, TypeSummaryImpl> RegexSummaryNavigator;
@@ -35,11 +37,16 @@ namespace lldb_private {
         typedef FormatNavigator<ConstString, ScriptedSyntheticChildren> SynthNavigator;
         typedef FormatNavigator<lldb::RegularExpressionSP, ScriptedSyntheticChildren> RegexSynthNavigator;
 #endif // #ifndef LLDB_DISABLE_PYTHON
-        
+
+        typedef ValueNavigator::MapType ValueMap;
+        typedef RegexValueNavigator::MapType RegexValueMap;
+
         typedef SummaryNavigator::MapType SummaryMap;
         typedef RegexSummaryNavigator::MapType RegexSummaryMap;
+        
         typedef FilterNavigator::MapType FilterMap;
         typedef RegexFilterNavigator::MapType RegexFilterMap;
+
 #ifndef LLDB_DISABLE_PYTHON
         typedef SynthNavigator::MapType SynthMap;
         typedef RegexSynthNavigator::MapType RegexSynthMap;
@@ -49,9 +56,13 @@ namespace lldb_private {
         
         typedef uint16_t FormatCategoryItems;
         static const uint16_t ALL_ITEM_TYPES = UINT16_MAX;
+
+        typedef ValueNavigator::SharedPointer ValueNavigatorSP;
+        typedef RegexValueNavigator::SharedPointer RegexValueNavigatorSP;
         
         typedef SummaryNavigator::SharedPointer SummaryNavigatorSP;
         typedef RegexSummaryNavigator::SharedPointer RegexSummaryNavigatorSP;
+
         typedef FilterNavigator::SharedPointer FilterNavigatorSP;
         typedef RegexFilterNavigator::SharedPointer RegexFilterNavigatorSP;
 #ifndef LLDB_DISABLE_PYTHON
@@ -62,6 +73,18 @@ namespace lldb_private {
         TypeCategoryImpl (IFormatChangeListener* clist,
                           ConstString name);
         
+        ValueNavigatorSP
+        GetValueNavigator ()
+        {
+            return ValueNavigatorSP(m_value_nav);
+        }
+        
+        RegexValueNavigatorSP
+        GetRegexValueNavigator ()
+        {
+            return RegexValueNavigatorSP(m_regex_value_nav);
+        }
+        
         SummaryNavigatorSP
         GetSummaryNavigator ()
         {
@@ -85,6 +108,9 @@ namespace lldb_private {
         {
             return RegexFilterNavigatorSP(m_regex_filter_nav);
         }
+
+        ValueNavigator::MapValueType
+        GetFormatForType (lldb::TypeNameSpecifierImplSP type_sp);
         
         SummaryNavigator::MapValueType
         GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp);
@@ -98,7 +124,13 @@ namespace lldb_private {
 #endif
         
         lldb::TypeNameSpecifierImplSP
+        GetTypeNameSpecifierForFormatAtIndex (size_t index);
+        
+        lldb::TypeNameSpecifierImplSP
         GetTypeNameSpecifierForSummaryAtIndex (size_t index);
+
+        ValueNavigator::MapValueType
+        GetFormatAtIndex (size_t index);
         
         SummaryNavigator::MapValueType
         GetSummaryAtIndex (size_t index);
@@ -145,6 +177,13 @@ namespace lldb_private {
                 return m_enabled_position;
         }
         
+        
+        bool
+        Get (ValueObject& valobj,
+             lldb::TypeFormatImplSP& entry,
+             lldb::DynamicValueType use_dynamic,
+             uint32_t* reason = NULL);
+        
         bool
         Get (ValueObject& valobj,
              lldb::TypeSummaryImplSP& entry,
@@ -183,10 +222,15 @@ namespace lldb_private {
         typedef std::shared_ptr<TypeCategoryImpl> SharedPointer;
         
     private:
+        ValueNavigator::SharedPointer m_value_nav;
+        RegexValueNavigator::SharedPointer m_regex_value_nav;
+        
         SummaryNavigator::SharedPointer m_summary_nav;
         RegexSummaryNavigator::SharedPointer m_regex_summary_nav;
+
         FilterNavigator::SharedPointer m_filter_nav;
         RegexFilterNavigator::SharedPointer m_regex_filter_nav;
+
 #ifndef LLDB_DISABLE_PYTHON
         SynthNavigator::SharedPointer m_synth_nav;
         RegexSynthNavigator::SharedPointer m_regex_synth_nav;
@@ -213,6 +257,9 @@ namespace lldb_private {
         
         friend class TypeCategoryMap;
         
+        friend class FormatNavigator<ConstString, TypeFormatImpl>;
+        friend class FormatNavigator<lldb::RegularExpressionSP, TypeFormatImpl>;
+        
         friend class FormatNavigator<ConstString, TypeSummaryImpl>;
         friend class FormatNavigator<lldb::RegularExpressionSP, TypeSummaryImpl>;
         

Modified: lldb/trunk/include/lldb/DataFormatters/TypeCategoryMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/TypeCategoryMap.h?rev=192217&r1=192216&r2=192217&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/TypeCategoryMap.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/TypeCategoryMap.h Tue Oct  8 14:03:22 2013
@@ -93,6 +93,10 @@ namespace lldb_private {
         {
             return m_map.size();
         }
+
+        lldb::TypeFormatImplSP
+        GetFormat (ValueObject& valobj,
+                   lldb::DynamicValueType use_dynamic);
         
         lldb::TypeSummaryImplSP
         GetSummaryFormat (ValueObject& valobj,

Modified: lldb/trunk/include/lldb/lldb-private-enumerations.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-enumerations.h?rev=192217&r1=192216&r2=192217&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-private-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-private-enumerations.h Tue Oct  8 14:03:22 2013
@@ -192,7 +192,9 @@ typedef enum FormatCategoryItem
     eFormatCategoryItemFilter =          0x0004,
     eFormatCategoryItemRegexFilter =     0x0008,
     eFormatCategoryItemSynth =           0x0010,
-    eFormatCategoryItemRegexSynth =      0x0020
+    eFormatCategoryItemRegexSynth =      0x0020,
+    eFormatCategoryItemValue =           0x0040,
+    eFormatCategoryItemRegexValue =      0x0080
 } FormatCategoryItem;
 
 //------------------------------------------------------------------

Modified: lldb/trunk/source/API/SBTypeCategory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTypeCategory.cpp?rev=192217&r1=192216&r2=192217&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTypeCategory.cpp (original)
+++ lldb/trunk/source/API/SBTypeCategory.cpp Tue Oct  8 14:03:22 2013
@@ -84,10 +84,10 @@ SBTypeCategory::GetName()
 uint32_t
 SBTypeCategory::GetNumFormats ()
 {
-    if (!IsDefaultCategory())
+    if (!IsValid())
         return 0;
     
-    return DataVisualization::ValueFormats::GetCount();
+    return m_opaque_sp->GetValueNavigator()->GetCount() + m_opaque_sp->GetRegexValueNavigator()->GetCount();
 }
 
 uint32_t
@@ -127,9 +127,9 @@ SBTypeCategory::GetTypeNameSpecifierForF
 lldb::SBTypeNameSpecifier
 SBTypeCategory::GetTypeNameSpecifierForFormatAtIndex (uint32_t index)
 {
-    if (!IsDefaultCategory())
+    if (!IsValid())
         return SBTypeNameSpecifier();
-    return SBTypeNameSpecifier(DataVisualization::ValueFormats::GetTypeNameSpecifierForFormatAtIndex(index));
+    return SBTypeNameSpecifier(m_opaque_sp->GetTypeNameSpecifierForFormatAtIndex(index));
 }
 
 lldb::SBTypeNameSpecifier
@@ -177,16 +177,23 @@ SBTypeCategory::GetFilterForType (SBType
 SBTypeFormat
 SBTypeCategory::GetFormatForType (SBTypeNameSpecifier spec)
 {
-    if (!IsDefaultCategory())
+    if (!IsValid())
         return SBTypeFormat();
         
     if (!spec.IsValid())
         return SBTypeFormat();
     
+    lldb::TypeFormatImplSP format_sp;
+    
     if (spec.IsRegex())
-        return SBTypeFormat();
+        m_opaque_sp->GetRegexValueNavigator()->GetExact(ConstString(spec.GetName()), format_sp);
+    else
+        m_opaque_sp->GetValueNavigator()->GetExact(ConstString(spec.GetName()), format_sp);
     
-    return SBTypeFormat(DataVisualization::ValueFormats::GetFormat(ConstString(spec.GetName())));
+    if (!format_sp)
+        return lldb::SBTypeFormat();
+    
+    return lldb::SBTypeFormat(format_sp);
 }
 
 #ifndef LLDB_DISABLE_PYTHON
@@ -259,9 +266,9 @@ SBTypeCategory::GetFilterAtIndex (uint32
 SBTypeFormat
 SBTypeCategory::GetFormatAtIndex (uint32_t index)
 {
-    if (!IsDefaultCategory())
+    if (!IsValid())
         return SBTypeFormat();
-    return SBTypeFormat(DataVisualization::ValueFormats::GetFormatAtIndex((index)));
+    return SBTypeFormat(m_opaque_sp->GetFormatAtIndex((index)));
 }
 
 #ifndef LLDB_DISABLE_PYTHON
@@ -295,7 +302,7 @@ bool
 SBTypeCategory::AddTypeFormat (SBTypeNameSpecifier type_name,
                                SBTypeFormat format)
 {
-    if (!IsDefaultCategory())
+    if (!IsValid())
         return false;
     
     if (!type_name.IsValid())
@@ -305,9 +312,9 @@ SBTypeCategory::AddTypeFormat (SBTypeNam
         return false;
     
     if (type_name.IsRegex())
-        return false;
-    
-    DataVisualization::ValueFormats::Add(ConstString(type_name.GetName()), format.GetSP());
+        m_opaque_sp->GetRegexValueNavigator()->Add(lldb::RegularExpressionSP(new RegularExpression(type_name.GetName())), format.GetSP());
+    else
+        m_opaque_sp->GetValueNavigator()->Add(ConstString(type_name.GetName()), format.GetSP());
     
     return true;
 }
@@ -315,16 +322,16 @@ SBTypeCategory::AddTypeFormat (SBTypeNam
 bool
 SBTypeCategory::DeleteTypeFormat (SBTypeNameSpecifier type_name)
 {
-    if (!IsDefaultCategory())
+    if (!IsValid())
         return false;
     
     if (!type_name.IsValid())
         return false;
     
     if (type_name.IsRegex())
-        return false;
-
-    return DataVisualization::ValueFormats::Delete(ConstString(type_name.GetName()));
+        return m_opaque_sp->GetRegexValueNavigator()->Delete(ConstString(type_name.GetName()));
+    else
+        return m_opaque_sp->GetValueNavigator()->Delete(ConstString(type_name.GetName()));
 }
 
 #ifndef LLDB_DISABLE_PYTHON

Modified: lldb/trunk/source/Commands/CommandObjectType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=192217&r1=192216&r2=192217&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectType.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectType.cpp Tue Oct  8 14:03:22 2013
@@ -369,6 +369,8 @@ private:
             m_cascade = true;
             m_skip_pointers = false;
             m_skip_references = false;
+            m_regex = false;
+            m_category.assign("default");
         }
         virtual Error
         SetOptionValue (CommandInterpreter &interpreter,
@@ -389,9 +391,15 @@ private:
                 case 'p':
                     m_skip_pointers = true;
                     break;
+                case 'w':
+                    m_category.assign(option_value);
+                    break;
                 case 'r':
                     m_skip_references = true;
                     break;
+                case 'x':
+                    m_regex = true;
+                    break;
                 default:
                     error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
                     break;
@@ -409,6 +417,8 @@ private:
         bool m_cascade;
         bool m_skip_references;
         bool m_skip_pointers;
+        bool m_regex;
+        std::string m_category;
     };
     
     OptionGroupOptions m_option_group;
@@ -510,12 +520,32 @@ protected:
 
         // now I have a valid format, let's add it to every type
         
+        TypeCategoryImplSP category_sp;
+        DataVisualization::Categories::GetCategory(ConstString(m_command_options.m_category), category_sp);
+        if (!category_sp)
+            return false;
+        
         for (size_t i = 0; i < argc; i++)
         {
             const char* typeA = command.GetArgumentAtIndex(i);
             ConstString typeCS(typeA);
             if (typeCS)
-                DataVisualization::ValueFormats::Add(typeCS, entry);
+            {
+                if (m_command_options.m_regex)
+                {
+                    RegularExpressionSP typeRX(new RegularExpression());
+                    if (!typeRX->Compile(typeCS.GetCString()))
+                    {
+                        result.AppendError("regex format error (maybe this is not really a regex?)");
+                        result.SetStatus(eReturnStatusFailed);
+                        return false;
+                    }
+                    category_sp->GetRegexSummaryNavigator()->Delete(typeCS);
+                    category_sp->GetRegexValueNavigator()->Add(typeRX, entry);
+                }
+                else
+                    category_sp->GetValueNavigator()->Add(typeCS, entry);
+            }
             else
             {
                 result.AppendError("empty typenames not allowed");
@@ -532,9 +562,12 @@ protected:
 OptionDefinition
 CommandObjectTypeFormatAdd::CommandOptions::g_option_table[] =
 {
+    { LLDB_OPT_SET_ALL, false, "category", 'w', OptionParser::eRequiredArgument, NULL, 0, eArgTypeName,    "Add this to the given category instead of the default one."},
     { LLDB_OPT_SET_ALL, false, "cascade", 'C', OptionParser::eRequiredArgument, NULL, 0, eArgTypeBoolean,    "If true, cascade through typedef chains."},
     { LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', OptionParser::eNoArgument, NULL, 0, eArgTypeNone,         "Don't use this format for pointers-to-type objects."},
     { LLDB_OPT_SET_ALL, false, "skip-references", 'r', OptionParser::eNoArgument, NULL, 0, eArgTypeNone,         "Don't use this format for references-to-type objects."},
+    { LLDB_OPT_SET_ALL, false,  "regex", 'x', OptionParser::eNoArgument, NULL, 0, eArgTypeNone,    "Type names are actually regular expressions."},
+    { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
 };
 
 
@@ -551,12 +584,89 @@ CommandObjectTypeFormatAdd::CommandOptio
 
 class CommandObjectTypeFormatDelete : public CommandObjectParsed
 {
+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;
+            const int short_option = m_getopt_table[option_idx].val;
+            
+            switch (short_option)
+            {
+                case 'a':
+                    m_delete_all = true;
+                    break;
+                case 'w':
+                    m_category = std::string(option_arg);
+                    break;
+                default:
+                    error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
+                    break;
+            }
+            
+            return error;
+        }
+        
+        void
+        OptionParsingStarting ()
+        {
+            m_delete_all = false;
+            m_category = "default";
+        }
+        
+        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_delete_all;
+        std::string m_category;
+        
+    };
+    
+    CommandOptions m_options;
+    
+    virtual Options *
+    GetOptions ()
+    {
+        return &m_options;
+    }
+    
+    static bool
+    PerCategoryCallback(void* param,
+                        const lldb::TypeCategoryImplSP& category_sp)
+    {
+		ConstString *name = (ConstString*)param;
+		category_sp->Delete(*name, eFormatCategoryItemValue | eFormatCategoryItemRegexValue);
+		return true;
+    }
+
 public:
     CommandObjectTypeFormatDelete (CommandInterpreter &interpreter) :
         CommandObjectParsed (interpreter,
                              "type format delete",
                              "Delete an existing formatting style for a type.",
-                             NULL)
+                             NULL),
+    m_options(interpreter)
     {
         CommandArgumentEntry type_arg;
         CommandArgumentData type_style_arg;
@@ -597,8 +707,20 @@ protected:
             return false;
         }
         
+        if (m_options.m_delete_all)
+        {
+            DataVisualization::Categories::LoopThrough(PerCategoryCallback, &typeCS);
+            result.SetStatus(eReturnStatusSuccessFinishNoResult);
+            return result.Succeeded();
+        }
+        
+        lldb::TypeCategoryImplSP category;
+        DataVisualization::Categories::GetCategory(ConstString(m_options.m_category.c_str()), category);
+        
+        bool delete_category = category->Delete(typeCS,
+                                                eFormatCategoryItemValue | eFormatCategoryItemRegexValue);
         
-        if (DataVisualization::ValueFormats::Delete(typeCS))
+        if (delete_category)
         {
             result.SetStatus(eReturnStatusSuccessFinishNoResult);
             return result.Succeeded();
@@ -614,18 +736,100 @@ protected:
     
 };
 
+OptionDefinition
+CommandObjectTypeFormatDelete::CommandOptions::g_option_table[] =
+{
+    { LLDB_OPT_SET_1, false, "all", 'a', OptionParser::eNoArgument, NULL, 0, eArgTypeNone,  "Delete from every category."},
+    { LLDB_OPT_SET_2, false, "category", 'w', OptionParser::eRequiredArgument, NULL, 0, eArgTypeName,  "Delete from given category."},
+    { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
+};
+
 //-------------------------------------------------------------------------
 // CommandObjectTypeFormatClear
 //-------------------------------------------------------------------------
 
 class CommandObjectTypeFormatClear : public CommandObjectParsed
 {
+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;
+            const int short_option = m_getopt_table[option_idx].val;
+            
+            switch (short_option)
+            {
+                case 'a':
+                    m_delete_all = true;
+                    break;
+                default:
+                    error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
+                    break;
+            }
+            
+            return error;
+        }
+        
+        void
+        OptionParsingStarting ()
+        {
+            m_delete_all = 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_delete_all;
+        bool m_delete_named;
+    };
+    
+    CommandOptions m_options;
+    
+    virtual Options *
+    GetOptions ()
+    {
+        return &m_options;
+    }
+    
+    static bool
+    PerCategoryCallback(void* param,
+                        const lldb::TypeCategoryImplSP& cate)
+    {
+        cate->GetValueNavigator()->Clear();
+        cate->GetRegexValueNavigator()->Clear();
+        return true;
+        
+    }
+    
 public:
     CommandObjectTypeFormatClear (CommandInterpreter &interpreter) :
         CommandObjectParsed (interpreter,
                              "type format clear",
                              "Delete all existing format styles.",
-                             NULL)
+                             NULL),
+    m_options(interpreter)
     {
     }
     
@@ -637,18 +841,42 @@ protected:
     bool
     DoExecute (Args& command, CommandReturnObject &result)
     {
-        DataVisualization::ValueFormats::Clear();
+        if (m_options.m_delete_all)
+            DataVisualization::Categories::LoopThrough(PerCategoryCallback, NULL);
+        
+        else
+        {
+            lldb::TypeCategoryImplSP category;
+            if (command.GetArgumentCount() > 0)
+            {
+                const char* cat_name = command.GetArgumentAtIndex(0);
+                ConstString cat_nameCS(cat_name);
+                DataVisualization::Categories::GetCategory(cat_nameCS, category);
+            }
+            else
+                DataVisualization::Categories::GetCategory(ConstString(NULL), category);
+            category->Clear(eFormatCategoryItemValue | eFormatCategoryItemRegexValue);
+        }
+        
         result.SetStatus(eReturnStatusSuccessFinishResult);
         return result.Succeeded();
     }
     
 };
 
+OptionDefinition
+CommandObjectTypeFormatClear::CommandOptions::g_option_table[] =
+{
+    { LLDB_OPT_SET_ALL, false, "all", 'a', OptionParser::eNoArgument, NULL, 0, eArgTypeNone,  "Clear every category."},
+    { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
+};
+
 //-------------------------------------------------------------------------
 // CommandObjectTypeFormatList
 //-------------------------------------------------------------------------
 
 bool CommandObjectTypeFormatList_LoopCallback(void* pt2self, ConstString type, const lldb::TypeFormatImplSP& entry);
+bool CommandObjectTypeRXFormatList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const lldb::TypeFormatImplSP& entry);
 
 class CommandObjectTypeFormatList;
 
@@ -656,18 +884,81 @@ struct CommandObjectTypeFormatList_LoopC
     CommandObjectTypeFormatList* self;
     CommandReturnObject* result;
     RegularExpression* regex;
+    RegularExpression* cate_regex;
     CommandObjectTypeFormatList_LoopCallbackParam(CommandObjectTypeFormatList* S, CommandReturnObject* R,
-                                            RegularExpression* X = NULL) : self(S), result(R), regex(X) {}
+                                            RegularExpression* X = NULL, RegularExpression* CX = NULL) : self(S), result(R), regex(X), cate_regex(CX) {}
 };
 
 class CommandObjectTypeFormatList : public CommandObjectParsed
 {
+    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;
+            const int short_option = m_getopt_table[option_idx].val;
+            
+            switch (short_option)
+            {
+                case 'w':
+                    m_category_regex = std::string(option_arg);
+                    break;
+                default:
+                    error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
+                    break;
+            }
+            
+            return error;
+        }
+        
+        void
+        OptionParsingStarting ()
+        {
+            m_category_regex = "";
+        }
+        
+        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.
+        
+        std::string m_category_regex;
+        
+    };
+    
+    CommandOptions m_options;
+    
+    virtual Options *
+    GetOptions ()
+    {
+        return &m_options;
+    }
+
 public:
     CommandObjectTypeFormatList (CommandInterpreter &interpreter) :
         CommandObjectParsed (interpreter,
                              "type format list",
                              "Show a list of current formatting styles.",
-                             NULL)
+                             NULL),
+    m_options(interpreter)
     {
         CommandArgumentEntry type_arg;
         CommandArgumentData type_style_arg;
@@ -691,38 +982,77 @@ protected:
         const size_t argc = command.GetArgumentCount();
         
         CommandObjectTypeFormatList_LoopCallbackParam *param;
+        RegularExpression* cate_regex =
+        m_options.m_category_regex.empty() ? NULL :
+        new RegularExpression(m_options.m_category_regex.c_str());
         
         if (argc == 1)
         {
             RegularExpression* regex = new RegularExpression(command.GetArgumentAtIndex(0));
             regex->Compile(command.GetArgumentAtIndex(0));
-            param = new CommandObjectTypeFormatList_LoopCallbackParam(this,&result,regex);
+            param = new CommandObjectTypeFormatList_LoopCallbackParam(this,&result,regex,cate_regex);
         }
         else
-            param = new CommandObjectTypeFormatList_LoopCallbackParam(this,&result);
-        DataVisualization::ValueFormats::LoopThrough(CommandObjectTypeFormatList_LoopCallback, param);
-        delete param;
+            param = new CommandObjectTypeFormatList_LoopCallbackParam(this,&result,NULL,cate_regex);
+        
+        DataVisualization::Categories::LoopThrough(PerCategoryCallback,param);
+
+        if (cate_regex)
+            delete cate_regex;
+        
         result.SetStatus(eReturnStatusSuccessFinishResult);
         return result.Succeeded();
     }
     
 private:
     
+    static bool
+    PerCategoryCallback(void* param_vp,
+                        const lldb::TypeCategoryImplSP& cate)
+    {
+        
+        CommandObjectTypeFormatList_LoopCallbackParam* param =
+        (CommandObjectTypeFormatList_LoopCallbackParam*)param_vp;
+        CommandReturnObject* result = param->result;
+        
+        const char* cate_name = cate->GetName();
+        
+        // if the category is disabled or empty and there is no regex, just skip it
+        if ((cate->IsEnabled() == false || cate->GetCount(eFormatCategoryItemValue | eFormatCategoryItemRegexValue) == 0) && param->cate_regex == NULL)
+            return true;
+        
+        // if we have a regex and this category does not match it, just skip it
+        if(param->cate_regex != NULL && strcmp(cate_name,param->cate_regex->GetText()) != 0 && param->cate_regex->Execute(cate_name) == false)
+            return true;
+        
+        result->GetOutputStream().Printf("-----------------------\nCategory: %s (%s)\n-----------------------\n",
+                                         cate_name,
+                                         (cate->IsEnabled() ? "enabled" : "disabled"));
+        
+        cate->GetValueNavigator()->LoopThrough(CommandObjectTypeFormatList_LoopCallback, param_vp);
+        
+        if (cate->GetRegexSummaryNavigator()->GetCount() > 0)
+        {
+            result->GetOutputStream().Printf("Regex-based summaries (slower):\n");
+            cate->GetRegexValueNavigator()->LoopThrough(CommandObjectTypeRXFormatList_LoopCallback, param_vp);
+        }
+        return true;
+    }
+    
+    
     bool
-    LoopCallback (ConstString type,
+    LoopCallback (const char* type,
                   const lldb::TypeFormatImplSP& entry,
                   RegularExpression* regex,
                   CommandReturnObject *result)
     {
-        if (regex == NULL || regex->Execute(type.AsCString())) 
-        {
-            result->GetOutputStream().Printf ("%s: %s\n", type.AsCString(), 
-                                              entry->GetDescription().c_str());
-        }
+        if (regex == NULL || strcmp(type,regex->GetText()) == 0 || regex->Execute(type))
+            result->GetOutputStream().Printf ("%s: %s\n", type, entry->GetDescription().c_str());
         return true;
     }
     
     friend bool CommandObjectTypeFormatList_LoopCallback(void* pt2self, ConstString type, const lldb::TypeFormatImplSP& entry);
+    friend bool CommandObjectTypeRXFormatList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const lldb::TypeFormatImplSP& entry);
     
 };
 
@@ -733,9 +1063,25 @@ CommandObjectTypeFormatList_LoopCallback
                                     const lldb::TypeFormatImplSP& entry)
 {
     CommandObjectTypeFormatList_LoopCallbackParam* param = (CommandObjectTypeFormatList_LoopCallbackParam*)pt2self;
-    return param->self->LoopCallback(type, entry, param->regex, param->result);
+    return param->self->LoopCallback(type.AsCString(), entry, param->regex, param->result);
+}
+
+bool
+CommandObjectTypeRXFormatList_LoopCallback (
+                                             void* pt2self,
+                                             lldb::RegularExpressionSP regex,
+                                             const lldb::TypeFormatImplSP& entry)
+{
+    CommandObjectTypeFormatList_LoopCallbackParam* param = (CommandObjectTypeFormatList_LoopCallbackParam*)pt2self;
+    return param->self->LoopCallback(regex->GetText(), entry, param->regex, param->result);
 }
 
+OptionDefinition
+CommandObjectTypeFormatList::CommandOptions::g_option_table[] =
+{
+    { LLDB_OPT_SET_ALL, false, "category-regex", 'w', OptionParser::eRequiredArgument, NULL, 0, eArgTypeName,  "Only show categories matching this filter."},
+    { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
+};
 
 #ifndef LLDB_DISABLE_PYTHON
 

Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=192217&r1=192216&r2=192217&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Tue Oct  8 14:03:22 2013
@@ -246,7 +246,7 @@ ValueObject::UpdateFormatsIfNeeded()
     
     if ( (m_last_format_mgr_revision != DataVisualization::GetCurrentRevision()))
     {
-        SetValueFormat(DataVisualization::ValueFormats::GetFormat (*this, eNoDynamicValues));
+        SetValueFormat(DataVisualization::GetFormat (*this, eNoDynamicValues));
         SetSummaryFormat(DataVisualization::GetSummaryFormat (*this, GetDynamicValueType()));
 #ifndef LLDB_DISABLE_PYTHON
         SetSyntheticChildren(DataVisualization::GetSyntheticChildren (*this, GetDynamicValueType()));

Modified: lldb/trunk/source/DataFormatters/DataVisualization.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/DataVisualization.cpp?rev=192217&r1=192216&r2=192217&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/DataVisualization.cpp (original)
+++ lldb/trunk/source/DataFormatters/DataVisualization.cpp Tue Oct  8 14:03:22 2013
@@ -47,66 +47,19 @@ DataVisualization::ShouldPrintAsOneLiner
 }
 
 lldb::TypeFormatImplSP
-DataVisualization::ValueFormats::GetFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic)
+DataVisualization::GetFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic)
 {
-    lldb::TypeFormatImplSP entry;
-    GetFormatManager().GetValueNavigator().Get(valobj, entry, use_dynamic);
-    return entry;
+    return GetFormatManager().GetFormat(valobj, use_dynamic);
 }
 
 lldb::TypeFormatImplSP
-DataVisualization::ValueFormats::GetFormat (const ConstString &type)
+DataVisualization::GetFormatForType (lldb::TypeNameSpecifierImplSP type_sp)
 {
-    lldb::TypeFormatImplSP entry;
-    GetFormatManager().GetValueNavigator().Get(type, entry);
-    return entry;
-}
-
-void
-DataVisualization::ValueFormats::Add (const ConstString &type, const lldb::TypeFormatImplSP &entry)
-{
-    GetFormatManager().GetValueNavigator().Add(FormatManager::GetValidTypeName(type),entry);
-}
-
-bool
-DataVisualization::ValueFormats::Delete (const ConstString &type)
-{
-    return GetFormatManager().GetValueNavigator().Delete(type);
-}
-
-void
-DataVisualization::ValueFormats::Clear ()
-{
-    GetFormatManager().GetValueNavigator().Clear();
-}
-
-void
-DataVisualization::ValueFormats::LoopThrough (TypeFormatImpl::ValueCallback callback, void* callback_baton)
-{
-    GetFormatManager().GetValueNavigator().LoopThrough(callback, callback_baton);
-}
-
-size_t
-DataVisualization::ValueFormats::GetCount ()
-{
-    return GetFormatManager().GetValueNavigator().GetCount();
-}
-
-lldb::TypeNameSpecifierImplSP
-DataVisualization::ValueFormats::GetTypeNameSpecifierForFormatAtIndex (size_t index)
-{
-    return GetFormatManager().GetValueNavigator().GetTypeNameSpecifierAtIndex(index);
-}
-
-lldb::TypeFormatImplSP
-DataVisualization::ValueFormats::GetFormatAtIndex (size_t index)
-{
-    return GetFormatManager().GetValueNavigator().GetAtIndex(index);
+    return GetFormatManager().GetFormatForType(type_sp);
 }
 
 lldb::TypeSummaryImplSP
-DataVisualization::GetSummaryFormat (ValueObject& valobj,
-                                     lldb::DynamicValueType use_dynamic)
+DataVisualization::GetSummaryFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic)
 {
     return GetFormatManager().GetSummaryFormat(valobj, use_dynamic);
 }

Modified: lldb/trunk/source/DataFormatters/FormatManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/FormatManager.cpp?rev=192217&r1=192216&r2=192217&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/FormatManager.cpp (original)
+++ lldb/trunk/source/DataFormatters/FormatManager.cpp Tue Oct  8 14:03:22 2013
@@ -163,6 +163,32 @@ FormatManager::GetFormatAsCString (Forma
     return NULL;
 }
 
+lldb::TypeFormatImplSP
+FormatManager::GetFormatForType (lldb::TypeNameSpecifierImplSP type_sp)
+{
+    if (!type_sp)
+        return lldb::TypeFormatImplSP();
+    lldb::TypeFormatImplSP format_chosen_sp;
+    uint32_t num_categories = m_categories_map.GetCount();
+    lldb::TypeCategoryImplSP category_sp;
+    uint32_t prio_category = UINT32_MAX;
+    for (uint32_t category_id = 0;
+         category_id < num_categories;
+         category_id++)
+    {
+        category_sp = GetCategoryAtIndex(category_id);
+        if (category_sp->IsEnabled() == false)
+            continue;
+        lldb::TypeFormatImplSP format_current_sp = category_sp->GetFormatForType(type_sp);
+        if (format_current_sp && (format_chosen_sp.get() == NULL || (prio_category > category_sp->GetEnabledPosition())))
+        {
+            prio_category = category_sp->GetEnabledPosition();
+            format_chosen_sp = format_current_sp;
+        }
+    }
+    return format_chosen_sp;
+}
+
 lldb::TypeSummaryImplSP
 FormatManager::GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp)
 {
@@ -394,6 +420,42 @@ GetTypeForCache (ValueObject& valobj,
     return ConstString();
 }
 
+lldb::TypeFormatImplSP
+FormatManager::GetFormat (ValueObject& valobj,
+                          lldb::DynamicValueType use_dynamic)
+{
+    TypeFormatImplSP retval;
+//    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
+//    ConstString valobj_type(GetTypeForCache(valobj, use_dynamic));
+//    if (valobj_type)
+//    {
+//        if (log)
+//            log->Printf("\n\n[FormatManager::GetSummaryFormat] Looking into cache for type %s", valobj_type.AsCString("<invalid>"));
+//        if (m_format_cache.GetSummary(valobj_type,retval))
+//        {
+//            if (log)
+//            {
+//                log->Printf("[FormatManager::GetSummaryFormat] Cache search success. Returning.");
+//                if (log->GetDebug())
+//                    log->Printf("[FormatManager::GetSummaryFormat] Cache hits: %" PRIu64 " - Cache Misses: %" PRIu64, m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
+//            }
+//            return retval;
+//        }
+//        if (log)
+//            log->Printf("[FormatManager::GetSummaryFormat] Cache search failed. Going normal route");
+//    }
+    retval = m_categories_map.GetFormat(valobj, use_dynamic);
+//    if (valobj_type)
+//    {
+//        if (log)
+//            log->Printf("[FormatManager::GetSummaryFormat] Caching %p for type %s",retval.get(),valobj_type.AsCString("<invalid>"));
+//        m_format_cache.SetSummary(valobj_type,retval);
+//    }
+//    if (log && log->GetDebug())
+//        log->Printf("[FormatManager::GetSummaryFormat] Cache hits: %" PRIu64 " - Cache Misses: %" PRIu64, m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
+    return retval;
+}
+
 lldb::TypeSummaryImplSP
 FormatManager::GetSummaryFormat (ValueObject& valobj,
                                  lldb::DynamicValueType use_dynamic)
@@ -470,7 +532,6 @@ FormatManager::GetSyntheticChildren (Val
 
 FormatManager::FormatManager() :
     m_format_cache(),
-    m_value_nav("format",this),
     m_named_summaries_map(this),
     m_last_revision(0),
     m_categories_map(this),

Modified: lldb/trunk/source/DataFormatters/TypeCategory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/TypeCategory.cpp?rev=192217&r1=192216&r2=192217&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/TypeCategory.cpp (original)
+++ lldb/trunk/source/DataFormatters/TypeCategory.cpp Tue Oct  8 14:03:22 2013
@@ -21,6 +21,8 @@ using namespace lldb_private;
 
 TypeCategoryImpl::TypeCategoryImpl(IFormatChangeListener* clist,
                                    ConstString name) :
+m_value_nav(new ValueNavigator("format",clist)),
+m_regex_value_nav(new RegexValueNavigator("regex-format",clist)),
 m_summary_nav(new SummaryNavigator("summary",clist)),
 m_regex_summary_nav(new RegexSummaryNavigator("regex-summary",clist)),
 m_filter_nav(new FilterNavigator("filter",clist)),
@@ -37,6 +39,22 @@ m_name(name)
 
 bool
 TypeCategoryImpl::Get (ValueObject& valobj,
+                       lldb::TypeFormatImplSP& entry,
+                       lldb::DynamicValueType use_dynamic,
+                       uint32_t* reason)
+{
+    if (!IsEnabled())
+        return false;
+    if (GetValueNavigator()->Get(valobj, entry, use_dynamic, reason))
+        return true;
+    bool regex = GetRegexValueNavigator()->Get(valobj, entry, use_dynamic, reason);
+    if (regex && reason)
+        *reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionSummary;
+    return regex;
+}
+
+bool
+TypeCategoryImpl::Get (ValueObject& valobj,
                        lldb::TypeSummaryImplSP& entry,
                        lldb::DynamicValueType use_dynamic,
                        uint32_t* reason)
@@ -119,14 +137,21 @@ TypeCategoryImpl::Get(ValueObject& valob
 void
 TypeCategoryImpl::Clear (FormatCategoryItems items)
 {
+    if ( (items & eFormatCategoryItemValue)  == eFormatCategoryItemValue )
+        m_value_nav->Clear();
+    if ( (items & eFormatCategoryItemRegexValue) == eFormatCategoryItemRegexValue )
+        m_regex_value_nav->Clear();
+
     if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary )
         m_summary_nav->Clear();
     if ( (items & eFormatCategoryItemRegexSummary) == eFormatCategoryItemRegexSummary )
         m_regex_summary_nav->Clear();
+
     if ( (items & eFormatCategoryItemFilter)  == eFormatCategoryItemFilter )
         m_filter_nav->Clear();
     if ( (items & eFormatCategoryItemRegexFilter) == eFormatCategoryItemRegexFilter )
         m_regex_filter_nav->Clear();
+
 #ifndef LLDB_DISABLE_PYTHON
     if ( (items & eFormatCategoryItemSynth)  == eFormatCategoryItemSynth )
         m_synth_nav->Clear();
@@ -140,14 +165,22 @@ TypeCategoryImpl::Delete (ConstString na
                           FormatCategoryItems items)
 {
     bool success = false;
+    
+    if ( (items & eFormatCategoryItemValue)  == eFormatCategoryItemValue )
+        success = m_value_nav->Delete(name) || success;
+    if ( (items & eFormatCategoryItemRegexValue) == eFormatCategoryItemRegexValue )
+        success = m_regex_value_nav->Delete(name) || success;
+
     if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary )
         success = m_summary_nav->Delete(name) || success;
     if ( (items & eFormatCategoryItemRegexSummary) == eFormatCategoryItemRegexSummary )
         success = m_regex_summary_nav->Delete(name) || success;
+
     if ( (items & eFormatCategoryItemFilter)  == eFormatCategoryItemFilter )
         success = m_filter_nav->Delete(name) || success;
     if ( (items & eFormatCategoryItemRegexFilter) == eFormatCategoryItemRegexFilter )
         success = m_regex_filter_nav->Delete(name) || success;
+
 #ifndef LLDB_DISABLE_PYTHON
     if ( (items & eFormatCategoryItemSynth)  == eFormatCategoryItemSynth )
         success = m_synth_nav->Delete(name) || success;
@@ -161,14 +194,22 @@ uint32_t
 TypeCategoryImpl::GetCount (FormatCategoryItems items)
 {
     uint32_t count = 0;
+
+    if ( (items & eFormatCategoryItemValue) == eFormatCategoryItemValue )
+        count += m_value_nav->GetCount();
+    if ( (items & eFormatCategoryItemRegexValue) == eFormatCategoryItemRegexValue )
+        count += m_regex_value_nav->GetCount();
+    
     if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary )
         count += m_summary_nav->GetCount();
     if ( (items & eFormatCategoryItemRegexSummary) == eFormatCategoryItemRegexSummary )
         count += m_regex_summary_nav->GetCount();
+
     if ( (items & eFormatCategoryItemFilter)  == eFormatCategoryItemFilter )
         count += m_filter_nav->GetCount();
     if ( (items & eFormatCategoryItemRegexFilter) == eFormatCategoryItemRegexFilter )
         count += m_regex_filter_nav->GetCount();
+
 #ifndef LLDB_DISABLE_PYTHON
     if ( (items & eFormatCategoryItemSynth)  == eFormatCategoryItemSynth )
         count += m_synth_nav->GetCount();
@@ -188,15 +229,39 @@ TypeCategoryImpl::AnyMatches(ConstString
     if (!IsEnabled() && only_enabled)
         return false;
     
-    lldb::TypeSummaryImplSP summary;
-    TypeFilterImpl::SharedPointer filter;
+    lldb::TypeFormatImplSP format_sp;
+    lldb::TypeSummaryImplSP summary_sp;
+    TypeFilterImpl::SharedPointer filter_sp;
 #ifndef LLDB_DISABLE_PYTHON
-    ScriptedSyntheticChildren::SharedPointer synth;
+    ScriptedSyntheticChildren::SharedPointer synth_sp;
 #endif
     
+    if ( (items & eFormatCategoryItemValue) == eFormatCategoryItemValue )
+    {
+        if (m_value_nav->Get(type_name, format_sp))
+        {
+            if (matching_category)
+                *matching_category = m_name.GetCString();
+            if (matching_type)
+                *matching_type = eFormatCategoryItemValue;
+            return true;
+        }
+    }
+    if ( (items & eFormatCategoryItemRegexValue) == eFormatCategoryItemRegexValue )
+    {
+        if (m_regex_value_nav->Get(type_name, format_sp))
+        {
+            if (matching_category)
+                *matching_category = m_name.GetCString();
+            if (matching_type)
+                *matching_type = eFormatCategoryItemRegexValue;
+            return true;
+        }
+    }
+    
     if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary )
     {
-        if (m_summary_nav->Get(type_name, summary))
+        if (m_summary_nav->Get(type_name, summary_sp))
         {
             if (matching_category)
                 *matching_category = m_name.GetCString();
@@ -207,7 +272,7 @@ TypeCategoryImpl::AnyMatches(ConstString
     }
     if ( (items & eFormatCategoryItemRegexSummary) == eFormatCategoryItemRegexSummary )
     {
-        if (m_regex_summary_nav->Get(type_name, summary))
+        if (m_regex_summary_nav->Get(type_name, summary_sp))
         {
             if (matching_category)
                 *matching_category = m_name.GetCString();
@@ -216,9 +281,10 @@ TypeCategoryImpl::AnyMatches(ConstString
             return true;
         }
     }
+    
     if ( (items & eFormatCategoryItemFilter)  == eFormatCategoryItemFilter )
     {
-        if (m_filter_nav->Get(type_name, filter))
+        if (m_filter_nav->Get(type_name, filter_sp))
         {
             if (matching_category)
                 *matching_category = m_name.GetCString();
@@ -229,7 +295,7 @@ TypeCategoryImpl::AnyMatches(ConstString
     }
     if ( (items & eFormatCategoryItemRegexFilter) == eFormatCategoryItemRegexFilter )
     {
-        if (m_regex_filter_nav->Get(type_name, filter))
+        if (m_regex_filter_nav->Get(type_name, filter_sp))
         {
             if (matching_category)
                 *matching_category = m_name.GetCString();
@@ -238,10 +304,11 @@ TypeCategoryImpl::AnyMatches(ConstString
             return true;
         }
     }
+    
 #ifndef LLDB_DISABLE_PYTHON
     if ( (items & eFormatCategoryItemSynth)  == eFormatCategoryItemSynth )
     {
-        if (m_synth_nav->Get(type_name, synth))
+        if (m_synth_nav->Get(type_name, synth_sp))
         {
             if (matching_category)
                 *matching_category = m_name.GetCString();
@@ -252,7 +319,7 @@ TypeCategoryImpl::AnyMatches(ConstString
     }
     if ( (items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth )
     {
-        if (m_regex_synth_nav->Get(type_name, synth))
+        if (m_regex_synth_nav->Get(type_name, synth_sp))
         {
             if (matching_category)
                 *matching_category = m_name.GetCString();
@@ -265,6 +332,22 @@ TypeCategoryImpl::AnyMatches(ConstString
     return false;
 }
 
+TypeCategoryImpl::ValueNavigator::MapValueType
+TypeCategoryImpl::GetFormatForType (lldb::TypeNameSpecifierImplSP type_sp)
+{
+    ValueNavigator::MapValueType retval;
+    
+    if (type_sp)
+    {
+        if (type_sp->IsRegex())
+            m_regex_value_nav->GetExact(ConstString(type_sp->GetName()),retval);
+        else
+            m_value_nav->GetExact(ConstString(type_sp->GetName()),retval);
+    }
+    
+    return retval;
+}
+
 TypeCategoryImpl::SummaryNavigator::MapValueType
 TypeCategoryImpl::GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp)
 {
@@ -324,6 +407,15 @@ TypeCategoryImpl::GetTypeNameSpecifierFo
         return m_regex_summary_nav->GetTypeNameSpecifierAtIndex(index-m_summary_nav->GetCount());
 }
 
+TypeCategoryImpl::ValueNavigator::MapValueType
+TypeCategoryImpl::GetFormatAtIndex (size_t index)
+{
+    if (index < m_value_nav->GetCount())
+        return m_value_nav->GetAtIndex(index);
+    else
+        return m_regex_value_nav->GetAtIndex(index-m_value_nav->GetCount());
+}
+
 TypeCategoryImpl::SummaryNavigator::MapValueType
 TypeCategoryImpl::GetSummaryAtIndex (size_t index)
 {
@@ -343,6 +435,15 @@ TypeCategoryImpl::GetFilterAtIndex (size
 }
 
 lldb::TypeNameSpecifierImplSP
+TypeCategoryImpl::GetTypeNameSpecifierForFormatAtIndex (size_t index)
+{
+    if (index < m_value_nav->GetCount())
+        return m_value_nav->GetTypeNameSpecifierAtIndex(index);
+    else
+        return m_regex_value_nav->GetTypeNameSpecifierAtIndex(index-m_value_nav->GetCount());
+}
+
+lldb::TypeNameSpecifierImplSP
 TypeCategoryImpl::GetTypeNameSpecifierForFilterAtIndex (size_t index)
 {
     if (index < m_filter_nav->GetCount())

Modified: lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp?rev=192217&r1=192216&r2=192217&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp (original)
+++ lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp Tue Oct  8 14:03:22 2013
@@ -176,6 +176,32 @@ TypeCategoryMap::AnyMatches (ConstString
     return false;
 }
 
+lldb::TypeFormatImplSP
+TypeCategoryMap::GetFormat (ValueObject& valobj,
+                            lldb::DynamicValueType use_dynamic)
+{
+    Mutex::Locker locker(m_map_mutex);
+    
+    uint32_t reason_why;
+    ActiveCategoriesIterator begin, end = m_active_categories.end();
+    
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
+    
+    for (begin = m_active_categories.begin(); begin != end; begin++)
+    {
+        lldb::TypeCategoryImplSP category_sp = *begin;
+        lldb::TypeFormatImplSP current_format;
+        if (log)
+            log->Printf("\n[TypeCategoryMap::GetFormat] Trying to use category %s", category_sp->GetName());
+        if (!category_sp->Get(valobj, current_format, use_dynamic, &reason_why))
+            continue;
+        return current_format;
+    }
+    if (log)
+        log->Printf("[TypeCategoryMap::GetFormat] nothing found - returning empty SP");
+    return lldb::TypeFormatImplSP();
+}
+
 lldb::TypeSummaryImplSP
 TypeCategoryMap::GetSummaryFormat (ValueObject& valobj,
                                    lldb::DynamicValueType use_dynamic)

Modified: lldb/trunk/source/DataFormatters/TypeFormat.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/TypeFormat.cpp?rev=192217&r1=192216&r2=192217&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/TypeFormat.cpp (original)
+++ lldb/trunk/source/DataFormatters/TypeFormat.cpp Tue Oct  8 14:03:22 2013
@@ -42,7 +42,7 @@ std::string
 TypeFormatImpl::GetDescription()
 {
     StreamString sstr;
-    sstr.Printf ("%s%s%s%s\n",
+    sstr.Printf ("%s%s%s%s",
                  FormatManager::GetFormatAsCString (GetFormat()),
                  Cascades() ? "" : " (not cascading)",
                  SkipsPointers() ? " (skip pointers)" : "",





More information about the lldb-commits mailing list