[Lldb-commits] [lldb] r253455 - Revert 2 commits breaking the MSVC build

Tamas Berghammer via lldb-commits lldb-commits at lists.llvm.org
Wed Nov 18 04:11:34 PST 2015


Author: tberghammer
Date: Wed Nov 18 06:11:34 2015
New Revision: 253455

URL: http://llvm.org/viewvc/llvm-project?rev=253455&view=rev
Log:
Revert 2 commits breaking the MSVC build

Revert "Remove a few vestigial typedefs from the old world"
This reverts commit 05872cda2a00fbd988c4fc761b1f87fe9edce224.

Revert "Cleanup the type X list commands to use the new ForEach goodness"
This reverts commit 85b1d83819a22cdc9ef12f58fd4fa92b473a4f81.

Modified:
    lldb/trunk/include/lldb/DataFormatters/DataVisualization.h
    lldb/trunk/include/lldb/DataFormatters/FormatManager.h
    lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h
    lldb/trunk/include/lldb/DataFormatters/TypeCategory.h
    lldb/trunk/include/lldb/DataFormatters/TypeCategoryMap.h
    lldb/trunk/include/lldb/DataFormatters/TypeFormat.h
    lldb/trunk/include/lldb/DataFormatters/TypeSummary.h
    lldb/trunk/include/lldb/DataFormatters/TypeSynthetic.h
    lldb/trunk/include/lldb/DataFormatters/TypeValidator.h
    lldb/trunk/source/API/SBTypeCategory.cpp
    lldb/trunk/source/Commands/CommandObjectType.cpp
    lldb/trunk/source/DataFormatters/DataVisualization.cpp
    lldb/trunk/source/DataFormatters/FormatManager.cpp
    lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp

Modified: lldb/trunk/include/lldb/DataFormatters/DataVisualization.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/DataVisualization.h?rev=253455&r1=253454&r2=253455&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/DataVisualization.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/DataVisualization.h Wed Nov 18 06:11:34 2015
@@ -101,7 +101,7 @@ public:
         Clear ();
         
         static void
-        ForEach (std::function<bool(ConstString, const lldb::TypeSummaryImplSP&)> callback);
+        LoopThrough (TypeSummaryImpl::SummaryCallback callback, void* callback_baton);
         
         static uint32_t
         GetCount ();
@@ -158,6 +158,9 @@ public:
         DisableStar ();
         
         static void
+        LoopThrough (FormatManager::CategoryCallback callback, void* callback_baton);
+        
+        static void
         ForEach (TypeCategoryMap::ForEachCallback callback);
         
         static uint32_t

Modified: lldb/trunk/include/lldb/DataFormatters/FormatManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormatManager.h?rev=253455&r1=253454&r2=253455&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/FormatManager.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/FormatManager.h Wed Nov 18 06:11:34 2015
@@ -43,6 +43,8 @@ class FormatManager : public IFormatChan
 public:
     typedef std::map<lldb::LanguageType, LanguageCategory::UniquePointer> LanguageCategories;
     
+    typedef TypeCategoryMap::CallbackType CategoryCallback;
+    
     FormatManager();
     
     ~FormatManager() override = default;
@@ -138,6 +140,9 @@ public:
     }
     
     void
+    LoopThroughCategories (CategoryCallback callback, void* param);
+
+    void
     ForEachCategory (TypeCategoryMap::ForEachCallback callback);
     
     lldb::TypeCategoryImplSP

Modified: lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h?rev=253455&r1=253454&r2=253455&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h Wed Nov 18 06:11:34 2015
@@ -80,6 +80,8 @@ public:
     typedef typename ValueType::SharedPointer ValueSP;
     typedef std::map<KeyType, ValueSP> MapType;
     typedef typename MapType::iterator MapIterator;
+    typedef std::function<bool(void*, KeyType, const ValueSP&)> CallbackType;
+    
     typedef std::function<bool(KeyType, const ValueSP&)> ForEachCallback;
     
     FormatMap(IFormatChangeListener* lst) :
@@ -139,6 +141,22 @@ public:
     }
     
     void
+    LoopThrough (CallbackType callback, void* param)
+    {
+        if (callback)
+        {
+            Mutex::Locker locker(m_map_mutex);
+            MapIterator pos, end = m_map.end();
+            for (pos = m_map.begin(); pos != end; pos++)
+            {
+                KeyType type = pos->first;
+                if (!callback(param, type, pos->second))
+                    break;
+            }
+        }
+    }
+    
+    void
     ForEach (ForEachCallback callback)
     {
         if (callback)
@@ -224,6 +242,7 @@ public:
     typedef typename MapType::iterator MapIterator;
     typedef typename MapType::key_type MapKeyType;
     typedef typename MapType::mapped_type MapValueType;
+    typedef typename BackEndType::CallbackType CallbackType;
     typedef typename BackEndType::ForEachCallback ForEachCallback;
     typedef typename std::shared_ptr<FormattersContainer<KeyType, ValueType> > SharedPointer;
     
@@ -297,6 +316,12 @@ public:
     }
     
     void
+    LoopThrough (CallbackType callback, void* param)
+    {
+        m_format_map.LoopThrough(callback,param);
+    }
+    
+    void
     ForEach (ForEachCallback callback)
     {
         m_format_map.ForEach(callback);

Modified: lldb/trunk/include/lldb/DataFormatters/TypeCategory.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/TypeCategory.h?rev=253455&r1=253454&r2=253455&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/TypeCategory.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/TypeCategory.h Wed Nov 18 06:11:34 2015
@@ -67,6 +67,14 @@ namespace lldb_private {
             return m_regex_sp;
         }
         
+        void
+        LoopThrough (typename ExactMatchContainer::CallbackType exact_callback,
+                     typename RegexMatchContainer::CallbackType regex_callback)
+        {
+            GetExactMatch()->LoopThrough(exact_callback);
+            GetRegexMatch()->LoopThrough(regex_callback);
+        }
+        
         uint32_t
         GetCount ()
         {
@@ -87,7 +95,7 @@ namespace lldb_private {
         typedef FormatterContainerPair<TypeValidatorImpl> ValidatorContainer;
         
 #ifndef LLDB_DISABLE_PYTHON
-        typedef FormatterContainerPair<SyntheticChildren> SynthContainer;
+        typedef FormatterContainerPair<ScriptedSyntheticChildren> SynthContainer;
 #endif // LLDB_DISABLE_PYTHON
 
     public:
@@ -110,84 +118,74 @@ namespace lldb_private {
         typedef ValidatorContainer::ExactMatchContainerSP ValidatorContainerSP;
         typedef ValidatorContainer::RegexMatchContainerSP RegexValidatorContainerSP;
         
-        template <typename T>
-        class ForEachCallbacks
+        class ForEach
         {
         public:
-            ForEachCallbacks () = default;
-            ~ForEachCallbacks () = default;
+            ForEach () = default;
+            ~ForEach () = default;
             
-            template<typename U = TypeFormatImpl>
-            typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
-            Set (FormatContainer::ExactMatchForEachCallback callback)
+            ForEach&
+            SetFormatExactCallback (FormatContainer::ExactMatchForEachCallback callback)
             {
                 m_format_exact = callback;
                 return *this;
             }
-            template<typename U = TypeFormatImpl>
-            typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
-            Set (FormatContainer::RegexMatchForEachCallback callback)
+            ForEach&
+            SetFormatRegexCallback (FormatContainer::RegexMatchForEachCallback callback)
             {
                 m_format_regex = callback;
                 return *this;
             }
 
-            template<typename U = TypeSummaryImpl>
-            typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
-            Set (SummaryContainer::ExactMatchForEachCallback callback)
+            ForEach&
+            SetSummaryExactCallback (SummaryContainer::ExactMatchForEachCallback callback)
             {
                 m_summary_exact = callback;
                 return *this;
             }
-            template<typename U = TypeSummaryImpl>
-            typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
-            Set (SummaryContainer::RegexMatchForEachCallback callback)
+            ForEach&
+            SetSummaryRegexCallback (SummaryContainer::RegexMatchForEachCallback callback)
             {
                 m_summary_regex = callback;
                 return *this;
             }
 
-            template<typename U = TypeFilterImpl>
-            typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
-            Set (FilterContainer::ExactMatchForEachCallback callback)
+            ForEach&
+            SetFilterExactCallback (FilterContainer::ExactMatchForEachCallback callback)
             {
                 m_filter_exact = callback;
                 return *this;
             }
-            template<typename U = TypeFilterImpl>
-            typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
-            Set (FilterContainer::RegexMatchForEachCallback callback)
+            ForEach&
+            SetFilterRegexCallback (FilterContainer::RegexMatchForEachCallback callback)
             {
                 m_filter_regex = callback;
                 return *this;
             }
 
 #ifndef LLDB_DISABLE_PYTHON
-            template<typename U = SyntheticChildren>
-            typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
-            Set (SynthContainer::ExactMatchForEachCallback callback)
+            ForEach&
+            SetSynthExactCallback (SynthContainer::ExactMatchForEachCallback callback)
             {
                 m_synth_exact = callback;
                 return *this;
             }
-            template<typename U = SyntheticChildren>
-            typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
-            Set (SynthContainer::RegexMatchForEachCallback callback)
+            ForEach&
+            SetSynthRegexCallback (SynthContainer::RegexMatchForEachCallback callback)
             {
                 m_synth_regex = callback;
                 return *this;
             }
 #endif // LLDB_DISABLE_PYTHON
-            template<typename U = TypeValidatorImpl>
-            typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
-            Set (ValidatorContainer::ExactMatchForEachCallback callback)
+
+            ForEach&
+            SetValidatorExactCallback (ValidatorContainer::ExactMatchForEachCallback callback)
             {
                 m_validator_exact = callback;
                 return *this;
             }
-            template<typename U = TypeValidatorImpl>
-            typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
-            Set (ValidatorContainer::RegexMatchForEachCallback callback)
+            ForEach&
+            SetValidatorRegexCallback (ValidatorContainer::RegexMatchForEachCallback callback)
             {
                 m_validator_regex = callback;
                 return *this;
@@ -273,9 +271,8 @@ namespace lldb_private {
                           ConstString name,
                           std::initializer_list<lldb::LanguageType> langs = {});
         
-        template <typename T>
         void
-        ForEach (const ForEachCallbacks<T> &foreach)
+        ForEach (const ForEach &foreach)
         {
             GetTypeFormatsContainer()->ForEach(foreach.GetFormatExactCallback());
             GetRegexTypeFormatsContainer()->ForEach(foreach.GetFormatRegexCallback());

Modified: lldb/trunk/include/lldb/DataFormatters/TypeCategoryMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/TypeCategoryMap.h?rev=253455&r1=253454&r2=253455&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/TypeCategoryMap.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/TypeCategoryMap.h Wed Nov 18 06:11:34 2015
@@ -37,6 +37,8 @@ namespace lldb_private {
     public:
         typedef std::map<KeyType, ValueSP> MapType;
         typedef MapType::iterator MapIterator;
+        typedef bool(*CallbackType)(void*, const ValueSP&);
+        
         typedef std::function<bool(const ValueSP&)> ForEachCallback;
         
         typedef uint32_t Position;
@@ -86,6 +88,9 @@ namespace lldb_private {
              ValueSP& entry);
         
         void
+        LoopThrough (CallbackType callback, void* param);
+        
+        void
         ForEach (ForEachCallback callback);
         
         lldb::TypeCategoryImplSP

Modified: lldb/trunk/include/lldb/DataFormatters/TypeFormat.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/TypeFormat.h?rev=253455&r1=253454&r2=253455&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/TypeFormat.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/TypeFormat.h Wed Nov 18 06:11:34 2015
@@ -151,6 +151,7 @@ namespace lldb_private {
         TypeFormatImpl (const Flags& flags = Flags());
         
         typedef std::shared_ptr<TypeFormatImpl> SharedPointer;
+        typedef std::function<bool(void*, ConstString, lldb::TypeFormatImplSP)> ValueCallback;
         
         virtual ~TypeFormatImpl ();
         
@@ -258,6 +259,7 @@ namespace lldb_private {
                                const TypeFormatImpl::Flags& flags = Flags());
         
         typedef std::shared_ptr<TypeFormatImpl_Format> SharedPointer;
+        typedef std::function<bool(void*, ConstString, TypeFormatImpl_Format::SharedPointer)> ValueCallback;
         
         ~TypeFormatImpl_Format() override;
         
@@ -300,6 +302,7 @@ namespace lldb_private {
                                  const TypeFormatImpl::Flags& flags = Flags());
         
         typedef std::shared_ptr<TypeFormatImpl_EnumType> SharedPointer;
+        typedef std::function<bool(void*, ConstString, TypeFormatImpl_EnumType::SharedPointer)> ValueCallback;
         
         ~TypeFormatImpl_EnumType() override;
         

Modified: lldb/trunk/include/lldb/DataFormatters/TypeSummary.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/TypeSummary.h?rev=253455&r1=253454&r2=253455&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/TypeSummary.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/TypeSummary.h Wed Nov 18 06:11:34 2015
@@ -406,6 +406,8 @@ namespace lldb_private {
         }
         
         typedef std::shared_ptr<TypeSummaryImpl> SharedPointer;
+        typedef std::function<bool(void*, ConstString, TypeSummaryImpl::SharedPointer)> SummaryCallback;
+        typedef std::function<bool(void*, lldb::RegularExpressionSP, TypeSummaryImpl::SharedPointer)> RegexSummaryCallback;
         
     protected:
         uint32_t m_my_revision;

Modified: lldb/trunk/include/lldb/DataFormatters/TypeSynthetic.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/TypeSynthetic.h?rev=253455&r1=253454&r2=253455&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/TypeSynthetic.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/TypeSynthetic.h Wed Nov 18 06:11:34 2015
@@ -348,6 +348,7 @@ namespace lldb_private {
         GetFrontEnd (ValueObject &backend) = 0;
         
         typedef std::shared_ptr<SyntheticChildren> SharedPointer;
+        typedef std::function<bool(void*, ConstString, SyntheticChildren::SharedPointer)> SyntheticChildrenCallback;
         
         uint32_t&
         GetRevision ()
@@ -478,8 +479,6 @@ namespace lldb_private {
             return SyntheticChildrenFrontEnd::AutoPointer(new FrontEnd(this, backend));
         }
         
-        typedef std::shared_ptr<TypeFilterImpl> SharedPointer;
-        
     private:
         DISALLOW_COPY_AND_ASSIGN(TypeFilterImpl);
     };

Modified: lldb/trunk/include/lldb/DataFormatters/TypeValidator.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/TypeValidator.h?rev=253455&r1=253454&r2=253455&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/TypeValidator.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/TypeValidator.h Wed Nov 18 06:11:34 2015
@@ -150,6 +150,7 @@ public:
     TypeValidatorImpl (const Flags& flags = Flags());
     
     typedef std::shared_ptr<TypeValidatorImpl> SharedPointer;
+    typedef std::function<bool(void*, ConstString, TypeValidatorImpl::SharedPointer)> ValueCallback;
     
     virtual ~TypeValidatorImpl ();
     
@@ -264,6 +265,7 @@ public:
     TypeValidatorImpl_CXX (ValidatorFunction f, std::string d, const TypeValidatorImpl::Flags& flags = Flags());
     
     typedef std::shared_ptr<TypeValidatorImpl_CXX> SharedPointer;
+    typedef std::function<bool(void*, ConstString, TypeValidatorImpl_CXX::SharedPointer)> ValueCallback;
     
     ~TypeValidatorImpl_CXX() override;
     

Modified: lldb/trunk/source/API/SBTypeCategory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTypeCategory.cpp?rev=253455&r1=253454&r2=253455&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTypeCategory.cpp (original)
+++ lldb/trunk/source/API/SBTypeCategory.cpp Wed Nov 18 06:11:34 2015
@@ -180,7 +180,7 @@ SBTypeCategory::GetFilterForType (SBType
     if (!spec.IsValid())
         return SBTypeFilter();
     
-    lldb::TypeFilterImplSP children_sp;
+    lldb::SyntheticChildrenSP children_sp;
     
     if (spec.IsRegex())
         m_opaque_sp->GetRegexTypeFiltersContainer()->GetExact(ConstString(spec.GetName()), children_sp);

Modified: lldb/trunk/source/Commands/CommandObjectType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=253455&r1=253454&r2=253455&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectType.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectType.cpp Wed Nov 18 06:11:34 2015
@@ -1089,6 +1089,13 @@ CommandObjectTypeFormatterDelete::Comman
     { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
 };
 
+
+
+
+
+
+
+
 class CommandObjectTypeFormatterClear : public CommandObjectParsed
 {
 private:
@@ -1217,6 +1224,10 @@ CommandObjectTypeFormatterClear::Command
     { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
 };
 
+
+
+
+
 //-------------------------------------------------------------------------
 // CommandObjectTypeFormatDelete
 //-------------------------------------------------------------------------
@@ -1253,8 +1264,25 @@ public:
     }
 };
 
-template <typename FormatterType>
-class CommandObjectTypeFormatterList : public CommandObjectParsed
+//-------------------------------------------------------------------------
+// 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;
+
+struct CommandObjectTypeFormatList_LoopCallbackParam {
+    CommandObjectTypeFormatList* self;
+    CommandReturnObject* result;
+    RegularExpression* regex;
+    RegularExpression* cate_regex;
+    CommandObjectTypeFormatList_LoopCallbackParam(CommandObjectTypeFormatList* S, CommandReturnObject* R,
+                                            RegularExpression* X = NULL, RegularExpression* CX = NULL) : self(S), result(R), regex(X), cate_regex(CX) {}
+};
+
+class CommandObjectTypeFormatList : public CommandObjectParsed
 {
     class CommandOptions : public Options
     {
@@ -1295,12 +1323,6 @@ class CommandObjectTypeFormatterList : p
         const OptionDefinition*
         GetDefinitions () override
         {
-            static OptionDefinition g_option_table[] =
-            {
-                { LLDB_OPT_SET_ALL, false, "category-regex", 'w', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName,  "Only show categories matching this filter."},
-                { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
-            };
-
             return g_option_table;
         }
         
@@ -1323,12 +1345,10 @@ class CommandObjectTypeFormatterList : p
     }
 
 public:
-    CommandObjectTypeFormatterList (CommandInterpreter &interpreter,
-                                    const char* name,
-                                    const char* help) :
+    CommandObjectTypeFormatList (CommandInterpreter &interpreter) :
         CommandObjectParsed (interpreter,
-                             name,
-                             help,
+                             "type format list",
+                             "Show a list of current formatting styles.",
                              NULL),
     m_options(interpreter)
     {
@@ -1343,137 +1363,115 @@ public:
         m_arguments.push_back (type_arg);
     }
     
-    ~CommandObjectTypeFormatterList () override
+    ~CommandObjectTypeFormatList () override
     {
     }
     
 protected:
-    virtual void
-    FormatterSpecificList (CommandReturnObject &result)
-    {
-    }
-    
     bool
     DoExecute (Args& command, CommandReturnObject &result) override
     {
         const size_t argc = command.GetArgumentCount();
         
-        std::unique_ptr<RegularExpression> category_regex;
-        std::unique_ptr<RegularExpression> formatter_regex;
-        
-        if (m_options.m_category_regex.size() > 0)
-        {
-            category_regex.reset(new RegularExpression());
-            if (!category_regex->Compile(m_options.m_category_regex.c_str()))
-            {
-                result.AppendErrorWithFormat("syntax error in category regular expression '%s'", m_options.m_category_regex.c_str());
-                result.SetStatus(eReturnStatusFailed);
-                return false;
-            }
-        }
+        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)
         {
-            const char* arg = command.GetArgumentAtIndex(1);
-            formatter_regex.reset(new RegularExpression());
-            if (!formatter_regex->Compile(arg))
-            {
-                result.AppendErrorWithFormat("syntax error in regular expression '%s'", arg);
-                result.SetStatus(eReturnStatusFailed);
-                return false;
-            }
+            RegularExpression* regex = new RegularExpression(command.GetArgumentAtIndex(0));
+            regex->Compile(command.GetArgumentAtIndex(0));
+            param = new CommandObjectTypeFormatList_LoopCallbackParam(this,&result,regex,cate_regex);
         }
+        else
+            param = new CommandObjectTypeFormatList_LoopCallbackParam(this,&result,NULL,cate_regex);
         
-        DataVisualization::Categories::ForEach( [this, &command, &result, &category_regex, &formatter_regex] (const lldb::TypeCategoryImplSP& category) -> bool {
-            if (category_regex)
-            {
-                bool escape = true;
-                if (0 == strcmp(category->GetName(), category_regex->GetText()))
-                {
-                    escape = false;
-                }
-                else if (category_regex->Execute(category->GetName()))
-                {
-                    escape = false;
-                }
-                
-                if (escape)
-                    return true;
-            }
-
-            result.GetOutputStream().Printf("-----------------------\nCategory: %s\n-----------------------\n", category->GetName());
-            
-            TypeCategoryImpl::ForEachCallbacks<FormatterType> foreach;
-            foreach.Set( [&result, &formatter_regex] (ConstString name, const typename FormatterType::SharedPointer& format_sp) -> bool {
-                if (formatter_regex)
-                {
-                    bool escape = true;
-                    if (0 == strcmp(name.AsCString(), formatter_regex->GetText()))
-                    {
-                        escape = false;
-                    }
-                    else if (formatter_regex->Execute(name.AsCString()))
-                    {
-                        escape = false;
-                    }
-                    
-                    if (escape)
-                        return true;
-                }
-
-                result.GetOutputStream().Printf ("%s: %s\n", name.AsCString(), format_sp->GetDescription().c_str());
-                
-                return true;
-            });
-
-            foreach.Set( [&result, &formatter_regex] (RegularExpressionSP regex_sp, const typename FormatterType::SharedPointer& format_sp) -> bool {
-                if (formatter_regex)
-                {
-                    bool escape = true;
-                    if (0 == strcmp(regex_sp->GetText(), formatter_regex->GetText()))
-                    {
-                        escape = false;
-                    }
-                    else if (formatter_regex->Execute(regex_sp->GetText()))
-                    {
-                        escape = false;
-                    }
-                    
-                    if (escape)
-                        return true;
-                }
-                
-                result.GetOutputStream().Printf ("%s: %s\n", regex_sp->GetText(), format_sp->GetDescription().c_str());
-                
-                return true;
-            });
+        DataVisualization::Categories::LoopThrough(PerCategoryCallback,param);
+        delete param;
 
-            category->ForEach(foreach);
-            
-            return true;
-        });
+        if (cate_regex)
+            delete cate_regex;
         
-        FormatterSpecificList(result);
-
         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\n-----------------------\n", cate->GetDescription().c_str());
+        
+        cate->GetTypeFormatsContainer()->LoopThrough(CommandObjectTypeFormatList_LoopCallback, param_vp);
+        
+        if (cate->GetRegexTypeFormatsContainer()->GetCount() > 0)
+        {
+            result->GetOutputStream().Printf("Regex-based formats (slower):\n");
+            cate->GetRegexTypeFormatsContainer()->LoopThrough(CommandObjectTypeRXFormatList_LoopCallback, param_vp);
+        }
+        return true;
+    }
+    
+    
+    bool
+    LoopCallback (const char* type,
+                  const lldb::TypeFormatImplSP& entry,
+                  RegularExpression* regex,
+                  CommandReturnObject *result)
+    {
+        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);
+    
 };
 
-//-------------------------------------------------------------------------
-// CommandObjectTypeFormatList
-//-------------------------------------------------------------------------
+bool
+CommandObjectTypeFormatList_LoopCallback (
+                                    void* pt2self,
+                                    ConstString type,
+                                    const lldb::TypeFormatImplSP& entry)
+{
+    CommandObjectTypeFormatList_LoopCallbackParam* param = (CommandObjectTypeFormatList_LoopCallbackParam*)pt2self;
+    return param->self->LoopCallback(type.AsCString(), entry, param->regex, param->result);
+}
 
-class CommandObjectTypeFormatList : public CommandObjectTypeFormatterList<TypeFormatImpl>
+bool
+CommandObjectTypeRXFormatList_LoopCallback (
+                                             void* pt2self,
+                                             lldb::RegularExpressionSP regex,
+                                             const lldb::TypeFormatImplSP& entry)
 {
-public:
-    
-    CommandObjectTypeFormatList (CommandInterpreter &interpreter) :
-        CommandObjectTypeFormatterList(interpreter,
-                                       "type format list",
-                                       "Show a list of current formats.")
-    {
-    }
+    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, NULL, 0, eArgTypeName,  "Only show categories matching this filter."},
+    { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
 };
 
 #ifndef LLDB_DISABLE_PYTHON
@@ -2048,30 +2046,226 @@ protected:
 // CommandObjectTypeSummaryList
 //-------------------------------------------------------------------------
 
-class CommandObjectTypeSummaryList : public CommandObjectTypeFormatterList<TypeSummaryImpl>
+bool CommandObjectTypeSummaryList_LoopCallback(void* pt2self, ConstString type, const StringSummaryFormat::SharedPointer& entry);
+bool CommandObjectTypeRXSummaryList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const StringSummaryFormat::SharedPointer& entry);
+
+class CommandObjectTypeSummaryList;
+
+struct CommandObjectTypeSummaryList_LoopCallbackParam {
+    CommandObjectTypeSummaryList* self;
+    CommandReturnObject* result;
+    RegularExpression* regex;
+    RegularExpression* cate_regex;
+    CommandObjectTypeSummaryList_LoopCallbackParam(CommandObjectTypeSummaryList* S, CommandReturnObject* R,
+                                                  RegularExpression* X = NULL,
+                                                  RegularExpression* CX = NULL) : self(S), result(R), regex(X), cate_regex(CX) {}
+};
+
+class CommandObjectTypeSummaryList : public CommandObjectParsed
 {
-public:
     
+    class CommandOptions : public Options
+    {
+    public:
+        
+        CommandOptions (CommandInterpreter &interpreter) :
+        Options (interpreter)
+        {
+        }
+        
+        ~CommandOptions () override {}
+        
+        Error
+        SetOptionValue (uint32_t option_idx, const char *option_arg) override
+        {
+            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 () override
+        {
+            m_category_regex = "";
+        }
+        
+        const OptionDefinition*
+        GetDefinitions () override
+        {
+            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;
+    
+    Options *
+    GetOptions () override
+    {
+        return &m_options;
+    }
+    
+public:
     CommandObjectTypeSummaryList (CommandInterpreter &interpreter) :
-    CommandObjectTypeFormatterList(interpreter,
-                                   "type summary list",
-                                   "Show a list of current summaries.")
+        CommandObjectParsed (interpreter,
+                             "type summary list",
+                             "Show a list of current summary styles.",
+                             NULL),
+        m_options(interpreter)
+    {
+        CommandArgumentEntry type_arg;
+        CommandArgumentData type_style_arg;
+        
+        type_style_arg.arg_type = eArgTypeName;
+        type_style_arg.arg_repetition = eArgRepeatOptional;
+        
+        type_arg.push_back (type_style_arg);
+        
+        m_arguments.push_back (type_arg);
+    }
+    
+    ~CommandObjectTypeSummaryList () override
     {
     }
     
 protected:
-    void
-    FormatterSpecificList (CommandReturnObject &result) override
+    bool
+    DoExecute (Args& command, CommandReturnObject &result) override
     {
+        const size_t argc = command.GetArgumentCount();
+        
+        CommandObjectTypeSummaryList_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 CommandObjectTypeSummaryList_LoopCallbackParam(this,&result,regex,cate_regex);
+        }
+        else
+            param = new CommandObjectTypeSummaryList_LoopCallbackParam(this,&result,NULL,cate_regex);
+        
+        DataVisualization::Categories::LoopThrough(PerCategoryCallback,param);
+        delete param;
+
         if (DataVisualization::NamedSummaryFormats::GetCount() > 0)
         {
             result.GetOutputStream().Printf("Named summaries:\n");
-            DataVisualization::NamedSummaryFormats::ForEach( [&result] (ConstString name, const TypeSummaryImplSP& summary_sp) -> bool {
-                result.GetOutputStream().Printf ("%s: %s\n", name.AsCString(), summary_sp->GetDescription().c_str());
-                return true;
-            });
+            if (argc == 1)
+            {
+                RegularExpression* regex = new RegularExpression(command.GetArgumentAtIndex(0));
+                regex->Compile(command.GetArgumentAtIndex(0));
+                param = new CommandObjectTypeSummaryList_LoopCallbackParam(this,&result,regex);
+            }
+            else
+                param = new CommandObjectTypeSummaryList_LoopCallbackParam(this,&result);
+            DataVisualization::NamedSummaryFormats::LoopThrough(CommandObjectTypeSummaryList_LoopCallback, param);
+            delete param;
+        }
+        
+        if (cate_regex)
+            delete cate_regex;
+        
+        result.SetStatus(eReturnStatusSuccessFinishResult);
+        return result.Succeeded();
+    }
+    
+private:
+    
+    static bool
+    PerCategoryCallback(void* param_vp,
+                        const lldb::TypeCategoryImplSP& cate)
+    {
+        
+        CommandObjectTypeSummaryList_LoopCallbackParam* param = 
+            (CommandObjectTypeSummaryList_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(eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary) == 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\n-----------------------\n", cate->GetDescription().c_str());
+
+        cate->GetTypeSummariesContainer()->LoopThrough(CommandObjectTypeSummaryList_LoopCallback, param_vp);
+        
+        if (cate->GetRegexTypeSummariesContainer()->GetCount() > 0)
+        {
+            result->GetOutputStream().Printf("Regex-based summaries (slower):\n");
+            cate->GetRegexTypeSummariesContainer()->LoopThrough(CommandObjectTypeRXSummaryList_LoopCallback, param_vp);
         }
+        return true;
+    }
+
+    
+    bool
+    LoopCallback (const char* type,
+                  const lldb::TypeSummaryImplSP& entry,
+                  RegularExpression* regex,
+                  CommandReturnObject *result)
+    {
+        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 CommandObjectTypeSummaryList_LoopCallback(void* pt2self, ConstString type, const lldb::TypeSummaryImplSP& entry);
+    friend bool CommandObjectTypeRXSummaryList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const lldb::TypeSummaryImplSP& entry);
+};
+
+bool
+CommandObjectTypeSummaryList_LoopCallback (
+                                          void* pt2self,
+                                          ConstString type,
+                                          const lldb::TypeSummaryImplSP& entry)
+{
+    CommandObjectTypeSummaryList_LoopCallbackParam* param = (CommandObjectTypeSummaryList_LoopCallbackParam*)pt2self;
+    return param->self->LoopCallback(type.AsCString(), entry, param->regex, param->result);
+}
+
+bool
+CommandObjectTypeRXSummaryList_LoopCallback (
+                                           void* pt2self,
+                                           lldb::RegularExpressionSP regex,
+                                           const lldb::TypeSummaryImplSP& entry)
+{
+    CommandObjectTypeSummaryList_LoopCallbackParam* param = (CommandObjectTypeSummaryList_LoopCallbackParam*)pt2self;
+    return param->self->LoopCallback(regex->GetText(), entry, param->regex, param->result);
+}
+
+OptionDefinition
+CommandObjectTypeSummaryList::CommandOptions::g_option_table[] =
+{
+    { LLDB_OPT_SET_ALL, false, "category-regex", 'w', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName,  "Only show categories matching this filter."},
+    { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
 };
 
 //-------------------------------------------------------------------------
@@ -2592,7 +2786,38 @@ CommandObjectTypeCategoryDisable::Comman
 
 class CommandObjectTypeCategoryList : public CommandObjectParsed
 {
-public:
+private:
+    
+    struct CommandObjectTypeCategoryList_CallbackParam
+    {
+        CommandReturnObject* result;
+        RegularExpression* regex;
+        
+        CommandObjectTypeCategoryList_CallbackParam(CommandReturnObject* res,
+                                                    RegularExpression* rex = NULL) :
+        result(res),
+        regex(rex)
+        {
+        }
+        
+    };
+    
+    static bool
+    PerCategoryCallback(void* param_vp,
+                        const lldb::TypeCategoryImplSP& cate)
+    {
+        CommandObjectTypeCategoryList_CallbackParam* param =
+            (CommandObjectTypeCategoryList_CallbackParam*)param_vp;
+        CommandReturnObject* result = param->result;
+        RegularExpression* regex = param->regex;
+        
+        const char* cate_name = cate->GetName();
+        
+        if (regex == NULL || strcmp(cate_name, regex->GetText()) == 0 || regex->Execute(cate_name))
+            result->GetOutputStream().Printf("Category: %s\n", cate->GetDescription().c_str());
+        return true;
+    }
+public:
     CommandObjectTypeCategoryList (CommandInterpreter &interpreter) :
         CommandObjectParsed (interpreter,
                              "type category list",
@@ -2619,48 +2844,26 @@ protected:
     DoExecute (Args& command, CommandReturnObject &result) override
     {
         const size_t argc = command.GetArgumentCount();
-
-        std::unique_ptr<RegularExpression> regex;
+        RegularExpression* regex = NULL;
         
-        if (argc == 1)
-        {
-            regex.reset(new RegularExpression());
-            const char* arg = command.GetArgumentAtIndex(0);
-            if (!regex->Compile(arg))
-            {
-                result.AppendErrorWithFormat("syntax error in category regular expression '%s'", arg);
-                result.SetStatus(eReturnStatusFailed);
-                return false;
-            }
-        }
-        else if (argc != 0)
+        if (argc == 0)
+            ;
+        else if (argc == 1)
+            regex = new RegularExpression(command.GetArgumentAtIndex(0));
+        else
         {
             result.AppendErrorWithFormat ("%s takes 0 or one arg.\n", m_cmd_name.c_str());
             result.SetStatus(eReturnStatusFailed);
             return false;
         }
         
-        DataVisualization::Categories::ForEach( [&regex, &result] (const lldb::TypeCategoryImplSP& category_sp) -> bool {
-            if (regex)
-            {
-                bool escape = true;
-                if (0 == strcmp(category_sp->GetName(), regex->GetText()))
-                {
-                    escape = false;
-                }
-                else if (regex->Execute(category_sp->GetName()))
-                {
-                    escape = false;
-                }
-                
-                if (escape)
-                    return true;
-            }
-            
-            result.GetOutputStream().Printf("Category: %s\n", category_sp->GetDescription().c_str());
-            
-            return true;
-        });
+        CommandObjectTypeCategoryList_CallbackParam param(&result,
+                                                          regex);
+        
+        DataVisualization::Categories::LoopThrough(PerCategoryCallback, &param);
+        
+        if (regex)
+            delete regex;
         
         result.SetStatus(eReturnStatusSuccessFinishResult);
         return result.Succeeded();
@@ -2672,16 +2875,210 @@ protected:
 // CommandObjectTypeFilterList
 //-------------------------------------------------------------------------
 
-class CommandObjectTypeFilterList : public CommandObjectTypeFormatterList<TypeFilterImpl>
+bool CommandObjectTypeFilterList_LoopCallback(void* pt2self, ConstString type, const SyntheticChildren::SharedPointer& entry);
+bool CommandObjectTypeFilterRXList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const SyntheticChildren::SharedPointer& entry);
+
+class CommandObjectTypeFilterList;
+
+struct CommandObjectTypeFilterList_LoopCallbackParam {
+    CommandObjectTypeFilterList* self;
+    CommandReturnObject* result;
+    RegularExpression* regex;
+    RegularExpression* cate_regex;
+    CommandObjectTypeFilterList_LoopCallbackParam(CommandObjectTypeFilterList* S, CommandReturnObject* R,
+                                                  RegularExpression* X = NULL,
+                                                  RegularExpression* CX = NULL) : self(S), result(R), regex(X), cate_regex(CX) {}
+};
+
+class CommandObjectTypeFilterList : public CommandObjectParsed
 {
-public:
     
+    class CommandOptions : public Options
+    {
+    public:
+        
+        CommandOptions (CommandInterpreter &interpreter) :
+        Options (interpreter)
+        {
+        }
+        
+        ~CommandOptions () override {}
+        
+        Error
+        SetOptionValue (uint32_t option_idx, const char *option_arg) override
+        {
+            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 () override
+        {
+            m_category_regex = "";
+        }
+        
+        const OptionDefinition*
+        GetDefinitions () override
+        {
+            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;
+    
+    Options *
+    GetOptions () override
+    {
+        return &m_options;
+    }
+    
+public:
     CommandObjectTypeFilterList (CommandInterpreter &interpreter) :
-    CommandObjectTypeFormatterList(interpreter,
-                                   "type filter list",
-                                   "Show a list of current filters.")
+        CommandObjectParsed (interpreter,
+                             "type filter list",
+                             "Show a list of current filters.",
+                             NULL),
+        m_options(interpreter)
+    {
+        CommandArgumentEntry type_arg;
+        CommandArgumentData type_style_arg;
+        
+        type_style_arg.arg_type = eArgTypeName;
+        type_style_arg.arg_repetition = eArgRepeatOptional;
+        
+        type_arg.push_back (type_style_arg);
+        
+        m_arguments.push_back (type_arg);
+    }
+    
+    ~CommandObjectTypeFilterList () override
+    {
+    }
+    
+protected:
+    bool
+    DoExecute (Args& command, CommandReturnObject &result) override
     {
+        const size_t argc = command.GetArgumentCount();
+        
+        CommandObjectTypeFilterList_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 CommandObjectTypeFilterList_LoopCallbackParam(this,&result,regex,cate_regex);
+        }
+        else
+            param = new CommandObjectTypeFilterList_LoopCallbackParam(this,&result,NULL,cate_regex);
+        
+        DataVisualization::Categories::LoopThrough(PerCategoryCallback,param);
+        delete param;
+        
+        if (cate_regex)
+            delete cate_regex;
+        
+        result.SetStatus(eReturnStatusSuccessFinishResult);
+        return result.Succeeded();
+    }
+    
+private:
+    
+    static bool
+    PerCategoryCallback(void* param_vp,
+                        const lldb::TypeCategoryImplSP& cate)
+    {
+        
+        const char* cate_name = cate->GetName();
+        
+        CommandObjectTypeFilterList_LoopCallbackParam* param = 
+        (CommandObjectTypeFilterList_LoopCallbackParam*)param_vp;
+        CommandReturnObject* result = param->result;
+        
+        // if the category is disabled or empty and there is no regex, just skip it
+        if ((cate->IsEnabled() == false || cate->GetCount(eFormatCategoryItemFilter | eFormatCategoryItemRegexFilter) == 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\n-----------------------\n", cate->GetDescription().c_str());
+        
+        cate->GetTypeFiltersContainer()->LoopThrough(CommandObjectTypeFilterList_LoopCallback, param_vp);
+        
+        if (cate->GetRegexTypeFiltersContainer()->GetCount() > 0)
+        {
+            result->GetOutputStream().Printf("Regex-based filters (slower):\n");
+            cate->GetRegexTypeFiltersContainer()->LoopThrough(CommandObjectTypeFilterRXList_LoopCallback, param_vp);
+        }
+        
+        return true;
+    }
+    
+    bool
+    LoopCallback (const char* type,
+                  const SyntheticChildren::SharedPointer& entry,
+                  RegularExpression* regex,
+                  CommandReturnObject *result)
+    {
+        if (regex == NULL || regex->Execute(type))
+            result->GetOutputStream().Printf ("%s: %s\n", type, entry->GetDescription().c_str());
+        return true;
     }
+    
+    friend bool CommandObjectTypeFilterList_LoopCallback(void* pt2self, ConstString type, const SyntheticChildren::SharedPointer& entry);
+    friend bool CommandObjectTypeFilterRXList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const SyntheticChildren::SharedPointer& entry);
+};
+
+bool
+CommandObjectTypeFilterList_LoopCallback (void* pt2self,
+                                         ConstString type,
+                                         const SyntheticChildren::SharedPointer& entry)
+{
+    CommandObjectTypeFilterList_LoopCallbackParam* param = (CommandObjectTypeFilterList_LoopCallbackParam*)pt2self;
+    return param->self->LoopCallback(type.AsCString(), entry, param->regex, param->result);
+}
+
+bool
+CommandObjectTypeFilterRXList_LoopCallback (void* pt2self,
+                                           lldb::RegularExpressionSP regex,
+                                           const SyntheticChildren::SharedPointer& entry)
+{
+    CommandObjectTypeFilterList_LoopCallbackParam* param = (CommandObjectTypeFilterList_LoopCallbackParam*)pt2self;
+    return param->self->LoopCallback(regex->GetText(), entry, param->regex, param->result);
+}
+
+
+OptionDefinition
+CommandObjectTypeFilterList::CommandOptions::g_option_table[] =
+{
+    { LLDB_OPT_SET_ALL, false, "category-regex", 'w', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName,  "Only show categories matching this filter."},
+    { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
 };
 
 #ifndef LLDB_DISABLE_PYTHON
@@ -2690,16 +3087,210 @@ public:
 // CommandObjectTypeSynthList
 //-------------------------------------------------------------------------
 
-class CommandObjectTypeSynthList : public CommandObjectTypeFormatterList<SyntheticChildren>
+bool CommandObjectTypeSynthList_LoopCallback(void* pt2self, ConstString type, const SyntheticChildren::SharedPointer& entry);
+bool CommandObjectTypeSynthRXList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const SyntheticChildren::SharedPointer& entry);
+
+class CommandObjectTypeSynthList;
+
+struct CommandObjectTypeSynthList_LoopCallbackParam {
+    CommandObjectTypeSynthList* self;
+    CommandReturnObject* result;
+    RegularExpression* regex;
+    RegularExpression* cate_regex;
+    CommandObjectTypeSynthList_LoopCallbackParam(CommandObjectTypeSynthList* S, CommandReturnObject* R,
+                                                 RegularExpression* X = NULL,
+                                                 RegularExpression* CX = NULL) : self(S), result(R), regex(X), cate_regex(CX) {}
+};
+
+class CommandObjectTypeSynthList : public CommandObjectParsed
 {
-public:
     
+    class CommandOptions : public Options
+    {
+    public:
+        
+        CommandOptions (CommandInterpreter &interpreter) :
+        Options (interpreter)
+        {
+        }
+        
+        ~CommandOptions () override {}
+        
+        Error
+        SetOptionValue (uint32_t option_idx, const char *option_arg) override
+        {
+            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 () override
+        {
+            m_category_regex = "";
+        }
+        
+        const OptionDefinition*
+        GetDefinitions () override
+        {
+            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;
+    
+    Options *
+    GetOptions () override
+    {
+        return &m_options;
+    }
+    
+public:
     CommandObjectTypeSynthList (CommandInterpreter &interpreter) :
-    CommandObjectTypeFormatterList(interpreter,
-                                   "type synthetic list",
-                                   "Show a list of current synthetic providers.")
+        CommandObjectParsed (interpreter,
+                             "type synthetic list",
+                             "Show a list of current synthetic providers.",
+                             NULL),
+        m_options(interpreter)
+    {
+        CommandArgumentEntry type_arg;
+        CommandArgumentData type_style_arg;
+        
+        type_style_arg.arg_type = eArgTypeName;
+        type_style_arg.arg_repetition = eArgRepeatOptional;
+        
+        type_arg.push_back (type_style_arg);
+        
+        m_arguments.push_back (type_arg);
+    }
+    
+    ~CommandObjectTypeSynthList () override
+    {
+    }
+    
+protected:
+    bool
+    DoExecute (Args& command, CommandReturnObject &result) override
+    {
+        const size_t argc = command.GetArgumentCount();
+        
+        CommandObjectTypeSynthList_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 CommandObjectTypeSynthList_LoopCallbackParam(this,&result,regex,cate_regex);
+        }
+        else
+            param = new CommandObjectTypeSynthList_LoopCallbackParam(this,&result,NULL,cate_regex);
+        
+        DataVisualization::Categories::LoopThrough(PerCategoryCallback,param);
+        delete param;
+
+        if (cate_regex)
+            delete cate_regex;
+        
+        result.SetStatus(eReturnStatusSuccessFinishResult);
+        return result.Succeeded();
+    }
+    
+private:
+    
+    static bool
+    PerCategoryCallback(void* param_vp,
+                        const lldb::TypeCategoryImplSP& cate)
+    {
+        
+        CommandObjectTypeSynthList_LoopCallbackParam* param = 
+        (CommandObjectTypeSynthList_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(eFormatCategoryItemSynth | eFormatCategoryItemRegexSynth) == 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\n-----------------------\n", cate->GetDescription().c_str());
+        
+        cate->GetTypeSyntheticsContainer()->LoopThrough(CommandObjectTypeSynthList_LoopCallback, param_vp);
+        
+        if (cate->GetRegexTypeSyntheticsContainer()->GetCount() > 0)
+        {
+            result->GetOutputStream().Printf("Regex-based synthetic providers (slower):\n");
+            cate->GetRegexTypeSyntheticsContainer()->LoopThrough(CommandObjectTypeSynthRXList_LoopCallback, param_vp);
+        }
+        
+        return true;
+    }
+    
+    bool
+    LoopCallback (const char* type,
+                  const SyntheticChildren::SharedPointer& entry,
+                  RegularExpression* regex,
+                  CommandReturnObject *result)
     {
+        if (regex == NULL || regex->Execute(type))
+            result->GetOutputStream().Printf ("%s: %s\n", type, entry->GetDescription().c_str());
+        return true;
     }
+    
+    friend bool CommandObjectTypeSynthList_LoopCallback(void* pt2self, ConstString type, const SyntheticChildren::SharedPointer& entry);
+    friend bool CommandObjectTypeSynthRXList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const SyntheticChildren::SharedPointer& entry);
+};
+
+bool
+CommandObjectTypeSynthList_LoopCallback (void* pt2self,
+                                         ConstString type,
+                                         const SyntheticChildren::SharedPointer& entry)
+{
+    CommandObjectTypeSynthList_LoopCallbackParam* param = (CommandObjectTypeSynthList_LoopCallbackParam*)pt2self;
+    return param->self->LoopCallback(type.AsCString(), entry, param->regex, param->result);
+}
+
+bool
+CommandObjectTypeSynthRXList_LoopCallback (void* pt2self,
+                                         lldb::RegularExpressionSP regex,
+                                         const SyntheticChildren::SharedPointer& entry)
+{
+    CommandObjectTypeSynthList_LoopCallbackParam* param = (CommandObjectTypeSynthList_LoopCallbackParam*)pt2self;
+    return param->self->LoopCallback(regex->GetText(), entry, param->regex, param->result);
+}
+
+
+OptionDefinition
+CommandObjectTypeSynthList::CommandOptions::g_option_table[] =
+{
+    { LLDB_OPT_SET_ALL, false, "category-regex", 'w', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName,  "Only show categories matching this filter."},
+    { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
 };
 
 #endif // #ifndef LLDB_DISABLE_PYTHON
@@ -3073,7 +3664,7 @@ private:
     
     bool
     AddFilter(ConstString type_name,
-              TypeFilterImplSP entry,
+              SyntheticChildrenSP entry,
               FilterFormatType type,
               std::string category_name,
               Error* error)
@@ -3196,15 +3787,19 @@ protected:
             return false;
         }
         
-        TypeFilterImplSP entry(new TypeFilterImpl(SyntheticChildren::Flags().SetCascades(m_options.m_cascade).
-                                       SetSkipPointers(m_options.m_skip_pointers).
-                                                  SetSkipReferences(m_options.m_skip_references)));
+        SyntheticChildrenSP entry;
+        
+        TypeFilterImpl* impl = new TypeFilterImpl(SyntheticChildren::Flags().SetCascades(m_options.m_cascade).
+                                                    SetSkipPointers(m_options.m_skip_pointers).
+                                                    SetSkipReferences(m_options.m_skip_references));
+        
+        entry.reset(impl);
         
         // go through the expression paths
         CommandOptions::ExpressionPathsIterator begin, end = m_options.m_expr_paths.end();
         
         for (begin = m_options.m_expr_paths.begin(); begin != end; begin++)
-            entry->AddExpressionPath(*begin);
+            impl->AddExpressionPath(*begin);
         
         
         // now I have a valid provider, let's add it to every type
@@ -3694,3 +4289,5 @@ CommandObjectType::CommandObjectType (Co
 CommandObjectType::~CommandObjectType ()
 {
 }
+
+

Modified: lldb/trunk/source/DataFormatters/DataVisualization.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/DataVisualization.cpp?rev=253455&r1=253454&r2=253455&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/DataVisualization.cpp (original)
+++ lldb/trunk/source/DataFormatters/DataVisualization.cpp Wed Nov 18 06:11:34 2015
@@ -226,6 +226,12 @@ DataVisualization::Categories::DisableSt
 }
 
 void
+DataVisualization::Categories::LoopThrough (FormatManager::CategoryCallback callback, void* callback_baton)
+{
+    GetFormatManager().LoopThroughCategories(callback, callback_baton);
+}
+
+void
 DataVisualization::Categories::ForEach (TypeCategoryMap::ForEachCallback callback)
 {
     GetFormatManager().ForEachCategory(callback);
@@ -268,9 +274,9 @@ DataVisualization::NamedSummaryFormats::
 }
 
 void
-DataVisualization::NamedSummaryFormats::ForEach (std::function<bool(ConstString, const lldb::TypeSummaryImplSP&)> callback)
+DataVisualization::NamedSummaryFormats::LoopThrough (TypeSummaryImpl::SummaryCallback callback, void* callback_baton)
 {
-    GetFormatManager().GetNamedSummaryContainer().ForEach(callback);
+    GetFormatManager().GetNamedSummaryContainer().LoopThrough(callback, callback_baton);
 }
 
 uint32_t

Modified: lldb/trunk/source/DataFormatters/FormatManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/FormatManager.cpp?rev=253455&r1=253454&r2=253455&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/FormatManager.cpp (original)
+++ lldb/trunk/source/DataFormatters/FormatManager.cpp Wed Nov 18 06:11:34 2015
@@ -486,6 +486,21 @@ FormatManager::GetValidatorForType (lldb
 }
 
 void
+FormatManager::LoopThroughCategories (CategoryCallback callback, void* param)
+{
+    m_categories_map.LoopThrough(callback, param);
+    Mutex::Locker locker(m_language_categories_mutex);
+    for (const auto& entry : m_language_categories_map)
+    {
+        if (auto category_sp = entry.second->GetCategory())
+        {
+            if (!callback(param, category_sp))
+                break;
+        }
+    }
+}
+
+void
 FormatManager::ForEachCategory(TypeCategoryMap::ForEachCallback callback)
 {
     m_categories_map.ForEach(callback);

Modified: lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp?rev=253455&r1=253454&r2=253455&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp (original)
+++ lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp Wed Nov 18 06:11:34 2015
@@ -373,6 +373,39 @@ TypeCategoryMap::GetValidator (Formatter
 }
 
 void
+TypeCategoryMap::LoopThrough(CallbackType callback, void* param)
+{
+    if (callback)
+    {
+        Mutex::Locker locker(m_map_mutex);
+        
+        // loop through enabled categories in respective order
+        {
+            ActiveCategoriesIterator begin, end = m_active_categories.end();
+            for (begin = m_active_categories.begin(); begin != end; begin++)
+            {
+                lldb::TypeCategoryImplSP category = *begin;
+                if (!callback(param, category))
+                    break;
+            }
+        }
+        
+        // loop through disabled categories in just any order
+        {
+            MapIterator pos, end = m_map.end();
+            for (pos = m_map.begin(); pos != end; pos++)
+            {
+                if (pos->second->IsEnabled())
+                    continue;
+                KeyType type = pos->first;
+                if (!callback(param, pos->second))
+                    break;
+            }
+        }
+    }
+}
+
+void
 TypeCategoryMap::ForEach(ForEachCallback callback)
 {
     if (callback)




More information about the lldb-commits mailing list