Skip to content

Commit 4eabb12

Browse files
committed
Add support for the NSMutableDictionary variant: "__NSFrozenDictionaryM"
This was an oversight of the commit: bb93483 that added support for the Frozen variants. Also added a test case for the way that currently produces one of these variants (a copy).
1 parent 8d5bf07 commit 4eabb12

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

lldb/source/Plugins/Language/ObjC/NSDictionary.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ bool lldb_private::formatters::NSDictionarySummaryProvider(
410410
static const ConstString g_DictionaryM("__NSDictionaryM");
411411
static const ConstString g_DictionaryMLegacy("__NSDictionaryM_Legacy");
412412
static const ConstString g_DictionaryMImmutable("__NSDictionaryM_Immutable");
413+
static const ConstString g_DictionaryMFrozen("__NSFrozenDictionaryM");
413414
static const ConstString g_Dictionary1("__NSSingleEntryDictionaryI");
414415
static const ConstString g_Dictionary0("__NSDictionary0");
415416
static const ConstString g_DictionaryCF("__CFDictionary");
@@ -427,7 +428,8 @@ bool lldb_private::formatters::NSDictionarySummaryProvider(
427428
return false;
428429

429430
value &= (is_64bit ? ~0xFC00000000000000UL : ~0xFC000000U);
430-
} else if (class_name == g_DictionaryM || class_name == g_DictionaryMLegacy) {
431+
} else if (class_name == g_DictionaryM || class_name == g_DictionaryMLegacy
432+
|| class_name == g_DictionaryMFrozen) {
431433
AppleObjCRuntime *apple_runtime =
432434
llvm::dyn_cast_or_null<AppleObjCRuntime>(runtime);
433435
Status error;
@@ -509,6 +511,7 @@ lldb_private::formatters::NSDictionarySyntheticFrontEndCreator(
509511
static const ConstString g_DictionaryM("__NSDictionaryM");
510512
static const ConstString g_Dictionary1("__NSSingleEntryDictionaryI");
511513
static const ConstString g_DictionaryImmutable("__NSDictionaryM_Immutable");
514+
static const ConstString g_DictionaryMFrozen("__NSFrozenDictionaryM");
512515
static const ConstString g_DictionaryMLegacy("__NSDictionaryM_Legacy");
513516
static const ConstString g_Dictionary0("__NSDictionary0");
514517
static const ConstString g_DictionaryCF("__CFDictionary");
@@ -520,7 +523,7 @@ lldb_private::formatters::NSDictionarySyntheticFrontEndCreator(
520523

521524
if (class_name == g_DictionaryI) {
522525
return (new NSDictionaryISyntheticFrontEnd(valobj_sp));
523-
} else if (class_name == g_DictionaryM) {
526+
} else if (class_name == g_DictionaryM || class_name == g_DictionaryMFrozen) {
524527
if (runtime->GetFoundationVersion() >= 1437) {
525528
return (new Foundation1437::NSDictionaryMSyntheticFrontEnd(valobj_sp));
526529
} else if (runtime->GetFoundationVersion() >= 1428) {

lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSContainer.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def test_nscontainers_with_run_command(self):
2020

2121
def nscontainers_data_formatter_commands(self):
2222
self.expect(
23-
'frame variable newArray nsDictionary newDictionary nscfDictionary cfDictionaryRef newMutableDictionary newMutableDictionaryRef cfarray_ref mutable_array_ref',
23+
'frame variable newArray nsDictionary newDictionary nscfDictionary cfDictionaryRef newMutableDictionary copyDictionary newMutableDictionaryRef cfarray_ref mutable_array_ref',
2424
substrs=[
2525
'(NSArray *) newArray = ',
2626
' @"50 elements"',
@@ -34,6 +34,8 @@ def nscontainers_data_formatter_commands(self):
3434
' 2 key/value pairs',
3535
'(NSDictionary *) newMutableDictionary = ',
3636
' 21 key/value pairs',
37+
'(NSMutableDictionary *) copyDictionary = ',
38+
' 21 key/value pairs',
3739
'(CFMutableDictionaryRef) newMutableDictionaryRef = ',
3840
' 21 key/value pairs',
3941
'(CFArrayRef) cfarray_ref = ',
@@ -42,6 +44,9 @@ def nscontainers_data_formatter_commands(self):
4244
' @"11 elements"',
4345
])
4446

47+
self.expect('frame var -d run-target copyDictionary[10]',
48+
substrs=['@"bar9"', '@"foo"'])
49+
4550
self.expect(
4651
'frame variable -d run-target *nscfDictionary',
4752
patterns=[

lldb/test/API/functionalities/data-formatter/data-formatter-objc/main.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,10 @@ int main(int argc, const char *argv[]) {
476476
[newMutableDictionary setObject:@"foo" forKey:@"bar19"];
477477
[newMutableDictionary setObject:@"foo" forKey:@"bar20"];
478478

479+
/* Copying an NSMutableDictionary makes a different member of the
480+
class cluster, so let's also make a copy of this one: */
481+
NSMutableDictionary *copyDictionary = [newMutableDictionary copy];
482+
479483
CFMutableDictionaryRef newMutableDictionaryRef = CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, newMutableDictionary);
480484

481485
id cfKeys[4] = {@"foo", @"bar", @"baz", @"quux"};

0 commit comments

Comments
 (0)