[Lldb-commits] [lldb] r250341 - Add a data formatter for __NSArray0, the type of empty arrays

Enrico Granata via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 14 15:45:04 PDT 2015


Author: enrico
Date: Wed Oct 14 17:45:04 2015
New Revision: 250341

URL: http://llvm.org/viewvc/llvm-project?rev=250341&view=rev
Log:
Add a data formatter for __NSArray0, the type of empty arrays

Modified:
    lldb/trunk/source/Plugins/Language/ObjC/NSArray.cpp
    lldb/trunk/source/Plugins/Language/ObjC/ObjCLanguage.cpp
    lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py

Modified: lldb/trunk/source/Plugins/Language/ObjC/NSArray.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/ObjC/NSArray.cpp?rev=250341&r1=250340&r2=250341&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/ObjC/NSArray.cpp (original)
+++ lldb/trunk/source/Plugins/Language/ObjC/NSArray.cpp Wed Oct 14 17:45:04 2015
@@ -202,6 +202,31 @@ namespace  lldb_private {
             std::vector<lldb::ValueObjectSP> m_children;
         };
         
+        class NSArray0SyntheticFrontEnd : public SyntheticChildrenFrontEnd
+        {
+        public:
+            NSArray0SyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
+            
+            virtual size_t
+            CalculateNumChildren ();
+            
+            virtual lldb::ValueObjectSP
+            GetChildAtIndex (size_t idx);
+            
+            virtual bool
+            Update();
+            
+            virtual bool
+            MightHaveChildren ();
+            
+            virtual size_t
+            GetIndexOfChildWithName (const ConstString &name);
+            
+            virtual
+            ~NSArray0SyntheticFrontEnd ();
+        private:
+        };
+        
         class NSArrayCodeRunningSyntheticFrontEnd : public SyntheticChildrenFrontEnd
         {
         public:
@@ -275,6 +300,10 @@ lldb_private::formatters::NSArraySummary
         if (error.Fail())
             return false;
     }
+    else if (!strcmp(class_name,"__NSArray0"))
+    {
+        value = 0;
+    }
     else if (!strcmp(class_name,"__NSCFArray"))
     {
         Error error;
@@ -632,6 +661,45 @@ lldb_private::formatters::NSArrayISynthe
     return retval_sp;
 }
 
+lldb_private::formatters::NSArray0SyntheticFrontEnd::NSArray0SyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
+SyntheticChildrenFrontEnd (*valobj_sp.get())
+{
+}
+
+lldb_private::formatters::NSArray0SyntheticFrontEnd::~NSArray0SyntheticFrontEnd ()
+{
+}
+
+size_t
+lldb_private::formatters::NSArray0SyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
+{
+    return UINT32_MAX;
+}
+
+size_t
+lldb_private::formatters::NSArray0SyntheticFrontEnd::CalculateNumChildren ()
+{
+    return 0;
+}
+
+bool
+lldb_private::formatters::NSArray0SyntheticFrontEnd::Update()
+{
+    return false;
+}
+
+bool
+lldb_private::formatters::NSArray0SyntheticFrontEnd::MightHaveChildren ()
+{
+    return false;
+}
+
+lldb::ValueObjectSP
+lldb_private::formatters::NSArray0SyntheticFrontEnd::GetChildAtIndex (size_t idx)
+{
+    return lldb::ValueObjectSP();
+}
+
 SyntheticChildrenFrontEnd* lldb_private::formatters::NSArraySyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
 {
     if (!valobj_sp)
@@ -669,6 +737,10 @@ SyntheticChildrenFrontEnd* lldb_private:
     {
         return (new NSArrayISyntheticFrontEnd(valobj_sp));
     }
+    else if (!strcmp(class_name,"__NSArray0"))
+    {
+        return (new NSArray0SyntheticFrontEnd(valobj_sp));
+    }
     else if (!strcmp(class_name,"__NSArrayM"))
     {
         if (runtime->GetFoundationVersion() >= 1100)

Modified: lldb/trunk/source/Plugins/Language/ObjC/ObjCLanguage.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/ObjC/ObjCLanguage.cpp?rev=250341&r1=250340&r2=250341&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/ObjC/ObjCLanguage.cpp (original)
+++ lldb/trunk/source/Plugins/Language/ObjC/ObjCLanguage.cpp Wed Oct 14 17:45:04 2015
@@ -446,6 +446,7 @@ LoadObjCFormatters(TypeCategoryImplSP ob
     AddCXXSummary(objc_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("NSArray"), appkit_flags);
     AddCXXSummary(objc_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("NSMutableArray"), appkit_flags);
     AddCXXSummary(objc_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("__NSArrayI"), appkit_flags);
+    AddCXXSummary(objc_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("__NSArray0"), appkit_flags);
     AddCXXSummary(objc_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("__NSArrayM"), appkit_flags);
     AddCXXSummary(objc_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("__NSCFArray"), appkit_flags);
     AddCXXSummary(objc_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("CFArrayRef"), appkit_flags);
@@ -478,6 +479,7 @@ LoadObjCFormatters(TypeCategoryImplSP ob
     
     AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("__NSArrayM"), ScriptedSyntheticChildren::Flags());
     AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("__NSArrayI"), ScriptedSyntheticChildren::Flags());
+    AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("__NSArray0"), ScriptedSyntheticChildren::Flags());
     AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("NSArray"), ScriptedSyntheticChildren::Flags());
     AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("NSMutableArray"), ScriptedSyntheticChildren::Flags());
     AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("__NSCFArray"), ScriptedSyntheticChildren::Flags());

Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py?rev=250341&r1=250340&r2=250341&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py (original)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py Wed Oct 14 17:45:04 2015
@@ -229,6 +229,8 @@ class ObjCDataFormatterTestCase(TestBase
                     substrs = ['(CFMutableBagRef) mutable_bag_ref = ','@"17 values"',
                     '(CFBagRef) cfbag_ref = ','@"15 values"',
                     '(CFBinaryHeapRef) binheap_ref = ','@"21 items"'])
+                    
+        self.expect('expression -d run -- [NSArray new]', substrs=['@"0 elements"'])
 
     def nsdata_data_formatter_commands(self):
         self.expect('frame variable immutableData mutableData data_ref mutable_data_ref mutable_string_ref',




More information about the lldb-commits mailing list