Author: Jonas Devlieghere Date: 2020-08-10T09:38:37-07:00 New Revision: b8ff0daeac0752689ffca9345686845d1b7cfed8
URL: https://github.com/llvm/llvm-project/commit/b8ff0daeac0752689ffca9345686845d1b7cfed8 DIFF: https://github.com/llvm/llvm-project/commit/b8ff0daeac0752689ffca9345686845d1b7cfed8.diff LOG: [lldb] Fix NSArray0 data formatter and add test Fixes PR47089 Added: Modified: lldb/source/Plugins/Language/ObjC/NSArray.cpp lldb/test/API/functionalities/data-formatter/nsarraysynth/TestNSArraySynthetic.py lldb/test/API/functionalities/data-formatter/nsarraysynth/main.m Removed: ################################################################################ diff --git a/lldb/source/Plugins/Language/ObjC/NSArray.cpp b/lldb/source/Plugins/Language/ObjC/NSArray.cpp index 8d648d8a0861..26dea77c2e49 100644 --- a/lldb/source/Plugins/Language/ObjC/NSArray.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSArray.cpp @@ -96,7 +96,7 @@ class GenericNSArrayMSyntheticFrontEnd : public NSArrayMSyntheticFrontEndBase { D32 *m_data_32; D64 *m_data_64; }; - + namespace Foundation1010 { namespace { struct DataDescriptor_32 { @@ -107,7 +107,7 @@ namespace Foundation1010 { uint32_t _priv2; uint32_t _data; }; - + struct DataDescriptor_64 { uint64_t _used; uint64_t _offset; @@ -117,11 +117,11 @@ namespace Foundation1010 { uint64_t _data; }; } - + using NSArrayMSyntheticFrontEnd = GenericNSArrayMSyntheticFrontEnd<DataDescriptor_32, DataDescriptor_64>; } - + namespace Foundation1428 { namespace { struct DataDescriptor_32 { @@ -130,7 +130,7 @@ namespace Foundation1428 { uint32_t _size; uint32_t _data; }; - + struct DataDescriptor_64 { uint64_t _used; uint64_t _offset; @@ -138,11 +138,11 @@ namespace Foundation1428 { uint64_t _data; }; } - + using NSArrayMSyntheticFrontEnd = GenericNSArrayMSyntheticFrontEnd<DataDescriptor_32, DataDescriptor_64>; } - + namespace Foundation1437 { template <typename PtrType> struct DataDescriptor { @@ -154,11 +154,11 @@ namespace Foundation1437 { uint32_t _muts; uint32_t _used; }; - + using NSArrayMSyntheticFrontEnd = GenericNSArrayMSyntheticFrontEnd< DataDescriptor<uint32_t>, DataDescriptor<uint64_t>>; - + template <typename DD> uint64_t __NSArrayMSize_Impl(lldb_private::Process &process, @@ -173,7 +173,7 @@ namespace Foundation1437 { } return descriptor._used; } - + uint64_t __NSArrayMSize(lldb_private::Process &process, lldb::addr_t valobj_addr, Status &error) { @@ -227,23 +227,23 @@ class GenericNSArrayISyntheticFrontEnd : public SyntheticChildrenFrontEnd { private: ExecutionContextRef m_exe_ctx_ref; uint8_t m_ptr_size; - + D32 *m_data_32; D64 *m_data_64; CompilerType m_id_type; }; - + namespace Foundation1300 { struct IDD32 { uint32_t used; uint32_t list; }; - + struct IDD64 { uint64_t used; uint64_t list; }; - + using NSArrayISyntheticFrontEnd = GenericNSArrayISyntheticFrontEnd<IDD32, IDD64, true>; } @@ -258,18 +258,18 @@ namespace Foundation1436 { uint32_t used; uint32_t list; // in Inline cases, this is the first element }; - + struct IDD64 { uint64_t used; uint64_t list; // in Inline cases, this is the first element }; - + using NSArrayI_TransferSyntheticFrontEnd = GenericNSArrayISyntheticFrontEnd<IDD32, IDD64, false>; using NSArrayISyntheticFrontEnd = GenericNSArrayISyntheticFrontEnd<IDD32, IDD64, true>; - + using NSFrozenArrayMSyntheticFrontEnd = Foundation1437::NSArrayMSyntheticFrontEnd; @@ -820,11 +820,9 @@ lldb_private::formatters::NSArraySyntheticFrontEndCreator( return (new Foundation1436::NSArrayISyntheticFrontEnd(valobj_sp)); if (runtime->GetFoundationVersion() >= 1430) return (new Foundation1430::NSArrayISyntheticFrontEnd(valobj_sp)); - else - return (new Foundation1300::NSArrayISyntheticFrontEnd(valobj_sp)); + return (new Foundation1300::NSArrayISyntheticFrontEnd(valobj_sp)); } else if (class_name == g_NSArrayI_Transfer) { return (new Foundation1436::NSArrayI_TransferSyntheticFrontEnd(valobj_sp)); - } else if (class_name == g_NSArray0) { } else if (class_name == g_NSFrozenArrayM) { return (new Foundation1436::NSFrozenArrayMSyntheticFrontEnd(valobj_sp)); } else if (class_name == g_NSArray0) { diff --git a/lldb/test/API/functionalities/data-formatter/nsarraysynth/TestNSArraySynthetic.py b/lldb/test/API/functionalities/data-formatter/nsarraysynth/TestNSArraySynthetic.py index 466eb5d5b7f3..a9b96bb02a8d 100644 --- a/lldb/test/API/functionalities/data-formatter/nsarraysynth/TestNSArraySynthetic.py +++ b/lldb/test/API/functionalities/data-formatter/nsarraysynth/TestNSArraySynthetic.py @@ -51,6 +51,8 @@ def cleanup(): substrs=['@"6 elements"']) self.expect('frame variable other_arr', substrs=['@"4 elements"']) + self.expect('frame variable empty_arr', + substrs=['@"0 elements"']) self.expect( 'frame variable arr --ptr-depth 1', substrs=[ @@ -69,6 +71,10 @@ def cleanup(): '[1] = 0x', '[2] = 0x', '[3] = 0x']) + self.expect( + 'frame variable empty_arr --ptr-depth 1', + substrs=[ + '@"0 elements"']) self.expect( 'frame variable arr --ptr-depth 1 -d no-run-target', substrs=[ @@ -104,3 +110,6 @@ def cleanup(): self.assertTrue( self.frame().FindVariable("other_arr").MightHaveChildren(), "arr says it does not have children!") + self.assertFalse( + self.frame().FindVariable("empty_arr").MightHaveChildren(), + "arr says it does have children!") diff --git a/lldb/test/API/functionalities/data-formatter/nsarraysynth/main.m b/lldb/test/API/functionalities/data-formatter/nsarraysynth/main.m index cdb612f67f09..4a267706a093 100644 --- a/lldb/test/API/functionalities/data-formatter/nsarraysynth/main.m +++ b/lldb/test/API/functionalities/data-formatter/nsarraysynth/main.m @@ -2,7 +2,7 @@ int main (int argc, const char * argv[]) { - + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; @@ -19,6 +19,7 @@ int main (int argc, const char * argv[]) NSString *aString = @"a string"; NSArray *other_arr = [NSArray arrayWithObjects:aDate, aValue, aString, arr, nil]; + NSArray *empty_arr = @[]; [pool drain];// Set break point at this line. return 0; _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits