[Lldb-commits] [PATCH] D104893: Add data formatter support for a missing NSDictionary variant
Jim Ingham via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Jun 24 19:09:19 PDT 2021
jingham updated this revision to Diff 354418.
jingham added a comment.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
Formatting
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D104893/new/
https://reviews.llvm.org/D104893
Files:
lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSContainer.py
lldb/test/API/functionalities/data-formatter/data-formatter-objc/main.m
Index: lldb/test/API/functionalities/data-formatter/data-formatter-objc/main.m
===================================================================
--- lldb/test/API/functionalities/data-formatter/data-formatter-objc/main.m
+++ lldb/test/API/functionalities/data-formatter/data-formatter-objc/main.m
@@ -476,6 +476,10 @@
[newMutableDictionary setObject:@"foo" forKey:@"bar19"];
[newMutableDictionary setObject:@"foo" forKey:@"bar20"];
+ /* Copying an NSMutableDictionary makes a different member of the
+ class cluster, so let's also make a copy of this one: */
+ NSMutableDictionary *copyDictionary = [newMutableDictionary copy];
+
CFMutableDictionaryRef newMutableDictionaryRef = CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, newMutableDictionary);
id cfKeys[4] = {@"foo", @"bar", @"baz", @"quux"};
Index: lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSContainer.py
===================================================================
--- lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSContainer.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSContainer.py
@@ -20,7 +20,7 @@
def nscontainers_data_formatter_commands(self):
self.expect(
- 'frame variable newArray nsDictionary newDictionary nscfDictionary cfDictionaryRef newMutableDictionary newMutableDictionaryRef cfarray_ref mutable_array_ref',
+ 'frame variable newArray nsDictionary newDictionary nscfDictionary cfDictionaryRef newMutableDictionary copyDictionary newMutableDictionaryRef cfarray_ref mutable_array_ref',
substrs=[
'(NSArray *) newArray = ',
' @"50 elements"',
@@ -34,6 +34,8 @@
' 2 key/value pairs',
'(NSDictionary *) newMutableDictionary = ',
' 21 key/value pairs',
+ '(NSMutableDictionary *) copyDictionary = ',
+ ' 21 key/value pairs',
'(CFMutableDictionaryRef) newMutableDictionaryRef = ',
' 21 key/value pairs',
'(CFArrayRef) cfarray_ref = ',
@@ -42,6 +44,9 @@
' @"11 elements"',
])
+ self.expect('frame var -d run-target copyDictionary[10]',
+ substrs=['@"bar9"', '@"foo"'])
+
self.expect(
'frame variable -d run-target *nscfDictionary',
patterns=[
Index: lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
===================================================================
--- lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
+++ lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
@@ -410,6 +410,7 @@
static const ConstString g_DictionaryM("__NSDictionaryM");
static const ConstString g_DictionaryMLegacy("__NSDictionaryM_Legacy");
static const ConstString g_DictionaryMImmutable("__NSDictionaryM_Immutable");
+ static const ConstString g_DictionaryMFrozen("__NSFrozenDictionaryM");
static const ConstString g_Dictionary1("__NSSingleEntryDictionaryI");
static const ConstString g_Dictionary0("__NSDictionary0");
static const ConstString g_DictionaryCF("__CFDictionary");
@@ -427,7 +428,8 @@
return false;
value &= (is_64bit ? ~0xFC00000000000000UL : ~0xFC000000U);
- } else if (class_name == g_DictionaryM || class_name == g_DictionaryMLegacy) {
+ } else if (class_name == g_DictionaryM || class_name == g_DictionaryMLegacy
+ || class_name == g_DictionaryMFrozen) {
AppleObjCRuntime *apple_runtime =
llvm::dyn_cast_or_null<AppleObjCRuntime>(runtime);
Status error;
@@ -509,6 +511,7 @@
static const ConstString g_DictionaryM("__NSDictionaryM");
static const ConstString g_Dictionary1("__NSSingleEntryDictionaryI");
static const ConstString g_DictionaryImmutable("__NSDictionaryM_Immutable");
+ static const ConstString g_DictionaryMFrozen("__NSFrozenDictionaryM");
static const ConstString g_DictionaryMLegacy("__NSDictionaryM_Legacy");
static const ConstString g_Dictionary0("__NSDictionary0");
static const ConstString g_DictionaryCF("__CFDictionary");
@@ -520,7 +523,7 @@
if (class_name == g_DictionaryI) {
return (new NSDictionaryISyntheticFrontEnd(valobj_sp));
- } else if (class_name == g_DictionaryM) {
+ } else if (class_name == g_DictionaryM || class_name == g_DictionaryMFrozen) {
if (runtime->GetFoundationVersion() >= 1437) {
return (new Foundation1437::NSDictionaryMSyntheticFrontEnd(valobj_sp));
} else if (runtime->GetFoundationVersion() >= 1428) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104893.354418.patch
Type: text/x-patch
Size: 4632 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210625/73454fc9/attachment-0001.bin>
More information about the lldb-commits
mailing list